5.3. Second level models#
5.3.1. Fitting a second level model#
As with first level models, a design matrix needs to be defined before fitting a second level model.
Again, similar to first level models, Nilearn provides a function
nilearn.glm.second_level.make_second_level_design_matrix for this purpose. Once
the design matrix has been setup, it can be visualized using the same function as before,
To fit the second level model, the tools to use are within the class
nilearn.glm.second_level.SecondLevelModel. Specifically, the function that
fits the model is
- Some examples to get you going with second level models are provided below::
General design matrix setup: Example of second level design matrix
One-sample testing, with non-parametric multiple comparisons correction: Second-level fMRI model: one sample test
Two-sample testing, unpaired and paired: Second-level fMRI model: two-sample test, unpaired and paired
Complex contrast: Example of generic design in second-level models
5.3.2. Thresholding statistical maps#
Nilearn’s statistical plotting functions provide simple thresholding functionality. For instance, functions
nilearn.plotting.plot_glass_brain have an argument
called threshold that, when set, will only show voxels with a value that is over the threshold provided.
Thresholding examples are available here: Second-level fMRI model: one sample test and Statistical testing of a second-level analysis.
5.3.3. Multiple comparisons correction#
As discussed in the Multiple Comparisons section of the introduction, the issue of multiple comparisons is important to address with statistical analysis of fMRI data. Nilearn provides parametric and non-parametric tools to address this issue.
Refer to the example Statistical testing of a second-level analysis for a guide
to applying FPR, FDR, and FWER corrections.
These corrections are applied using the
You can additionally employ a non-parametric correction procedure using either
Refer to the example Second-level fMRI model: one sample test
for a practical use of this function.
Within an activated cluster, not all voxels represent true activation. To estimate true positives within a cluster,
Nilearn provides the
nilearn.glm.cluster_level_inference function. An example with usage information is available
here: Second-level fMRI model: true positive proportion in clusters.
5.3.4. Voxel based morphometry#
nilearn.glm.second_level.SecondLevelModel and its associated functions can also be used
to perform voxel based morphometry. An example using the OASIS dataset to
identify the relationship between aging, sex and gray matter density is available here
Voxel-Based Morphometry on OASIS dataset.