This is TFCE TFCE1.3.1 (r334) from 2026-07-15
You can update your copy of TFCE here: Check for update.
If you find any bug, please report them at vbmweb@gmail.com.
Description
This toolbox is an extension to SPM12 (Wellcome Department of Cognitive Neurology) providing non-parametric permutation inference with threshold-free cluster enhancement (TFCE), for 3D volume and surface data.
TFCE combines focal effects of large height with broad effects of large extent, and needs no cluster-forming threshold - the arbitrary choice that cluster-based inference forces on you, and that the result can depend on heavily. It is also fairly robust to the nonstationarity that is common in VBM data.
The toolbox runs on any existing second-level SPM design. Point it at an SPM.mat from a parametric analysis you have already estimated, and it re-does the inference non-parametrically. It can be applied to (almost) any existing statistical (parametric) SPM design for 3D volume or surface data.
An interesting additional feature of that toolbox is that it also allows to use voxel-wise covariates, similar to the approach here. These voxel-wise covariates can be GM maps, which can be used to assess the extent to which functional activation can be explained by underlying anatomical differences, and at the same time to assess the amount of functional activation that cannot be attributed to anatomical differences and is therefore likely to be due to functional differences alone.
The toolbox is developed by Christian Gaser (University of Jena, Departments of Psychiatry and Neurology) and free but copyright software, distributed under the terms of the GNU General Public Licence as published by the Free Software Foundation; either version 2 of the Licence, or (at your option) any later version. If you use any TFCE code for commercial application, please send a mail.
Features
Inference
- Exact TFCE, with no step size. Most implementations approximate the TFCE integral by sampling the height on a grid and summing, which introduces a discretisation error that depends on a step size dh you have to choose. This toolbox does not. It builds a max-tree (component tree) with union-find, and because the extent function is piecewise constant, integrates each piece in closed form. The result is the exact integral, with no precision parameter to get wrong.
- Permutation inference throughout. No parametric assumptions about the distribution of the statistic, and no random field theory.
- FWE, FDR and uncorrected p-values, for both the TFCE map and the raw t/F statistic.
- t- and F-contrasts, on volumes and on surfaces.
Designs it understands
- Any second-level SPM design: one-sample, two-sample, paired, correlation, one-way and factorial ANOVA, repeated-measures ANOVA, ANCOVA, interactions.
- Three ways of handling nuisance variables: Draper-Stoneman, Smith (the default when nuisance variables are present), and Freedman-Lane. See Winkler et al. 2014.
- Exchangeability blocks for longitudinal and repeated-measures designs, so that data are only ever permuted within the blocks they may be permuted within.
- Sign-flipping for one-sample designs, permutation for everything else - chosen automatically.
- Voxel- and vertex-wise covariates, so that the design matrix may differ at every element.
- Surfaces and TBSS: surface meshes use the mesh adjacency rather than a voxel grid, and TBSS data use the 2D-optimised TFCE parameters.
- Small volume correction by supplying an additional mask.
Fewer permutations
The number of permutations you need is set by the smallest p-value you want to resolve. Counting exceedances cannot report a p-value below 1/n_perm - that floor, not the statistic, is what forces a permutation test to run many thousands of permutations. Three things remove it:
- Gamma approximation of the maximum distribution, for FWE-corrected p-values. The distribution of the maximum statistic is fitted from its first three moments rather than counted, so corrected p-values are not floored at 1/n_perm and converge with far fewer permutations.
- Generalised Pareto tail approximation of the element-wise distributions, for uncorrected p-values and with them FDR, which is computed from them. Its shape is pooled across elements: they all carry the same statistic under the same design, so they differ in scale, not in shape. From 1000 permutations this recovers p of about 1e-4 with the median right, where plain counting returns zero for 91% of elements and says nothing at all.
- Sequential stopping (optional, off by default). Stops as soon as it is certain that nothing in the image can become significant. A null image reaches that almost at once; an image with a real effect, or one sitting anywhere near alpha, never does and runs the full count.
Faster permutations
- The permuted GLM never forms the permuted data. Under Freedman-Lane the nuisance columns are part of the full design, so the residual-forming matrix already annihilates them and the large multiply that builds the permuted dataset disappears entirely. The whole permutation collapses into one small projection.
- Permutations are TFCE'd in parallel, a block at a time, one permutation per thread. They are independent of one another, so this is where the parallelism belongs.
- The max-tree sorts by radix, not by comparison, which is the single largest cost of the transform.
- The voxel-wise covariate path takes no pseudoinverse per voxel. The normal equations are assembled for every element at once and batch-solved, bringing that path to roughly the cost of an ordinary design, where it used to be an order of magnitude slower.
- Half the permutations, for free, in balanced two-sample designs, where the mirrored permutation provably gives the negated statistic.
- Multiple SPM.mat files in parallel across cores.
Safety nets
A permutation test is only as good as its exchangeability assumptions, and a wrong design gives a confidently wrong answer rather than an error. The toolbox therefore checks itself as it goes:
- The permutations are verified before use: data may only ever be exchanged inside their own exchangeability block.
- The permutation null is checked for width. Under a valid permutation the uncorrected p-values are uniform, so about 5% of them land in the upper tail. True effects only produce small p-values and cannot inflate that tail, which makes it a clean check. A null that is too narrow pushes the p-values down and empties the tail, which makes the test anti-conservative, and is reported.
- The parametric and the non-parametric statistic are compared. A large discrepancy points to a misspecified permutation scheme and is reported at the MATLAB command line.
A validation suite ships with the toolbox and establishes, rather than assumes, that the above is true. Run validation/run_all from the toolbox directory.
Download
Download the latest release from GitHub and unpack it into your SPM toolbox directory. The compiled mex-files ship with the release. See also all releases and the source repository.
