Working with Subcortical ROIs (Freesurfer)
In addition to surface-space ROIs, group-level analyses done in 2mm mni305 space can be used to produce ROIs for subcortical regions. We might use the GLM volumes as-is, as a binary mask, or we might wish to use significant clusters to isolate voxels from specific anatomical regions. This second case is what I will focus on for the time being.
Prerequisites
In addition to FreeSurfer, the steps described below make use of some of AFNI's command-line utilities. AFNI should be installed on all our lab workstations, but if you are working elsewhere, go ahead and find and install AFNI from here.
In particular, we will be making use of a utility called 3dcalc. FSL may have some similar utilities, but I've not learned about them if they exist, and I know that the method described below works.
Besides having AFNI installed, you will also need to have some number of MRI volumes that you will want to manipulate to produce your ROIs. These volumes may include one or more GLM contrasts and/or a labeled anatomical volume, such as the aseg.mgz volume found in $FREESURFER_HOME/subjects/fsaverage/mri.2mm. Note that all your volumes will need to be in the same space. For example, you can't be mixing volumes with 1mm voxels and volumes with 2mm voxels. The group-level analyses detailed elsewhere on this wiki are in mni305 space sampled at 2mm. I'm afraid you're on your own if you took a different path.
Collect Your VOIS
Here I will document a scenario in which significant subcortical clusters have been identified using a group-level GLM in mni305 space. The goal will be to use those significant clusters to filter out subcortical regions.
The significant clusters will be found in your group-level glm directory. If you've generally followed directions elsewhere on this wiki, these files will probably be in a directory called $SUBJECTS_DIR/RFX/parfile.sm4.mni/contrast/glm.wls/osgm (the text in red is likely to differ from project to project). In this directory you will find a pile of files, but the one you care about will probably be named something like perm.abs.01.sig.cluster.nii.gz. Again, the part of the file name in red may differ. The key thing to look for is the sig.cluster.nii.gz file. This is the file that has assigned all the significant voxels in each cluster the same value (e.g., 1, 2, ..., etc.), according to the cluster to which it belongs (voxels in the largest cluster are assigned a '1', those in the second-largest are assigned a '2', etc.).
So there's half of the files you need. The other file you will need is the segmentation file for the mni305 template. You will find that in fsaverage/mri.2mm/aseg.mgz. Copy it to the current directory for convenience:
cp $SUBJECTS_DIR/mri.2mm/aseg.mgz ./
Convert to AFNI-Compatible Files
One minor obstacle is that the AFNI utility we plan to use has no idea what to do with FreeSurfer .mgz files. We'll have to convert our aseg.mgz file to the more flexible .nii format using mri_convert:
mri_convert aseg.mgz aseg.nii.gz
Calculate the Overlap with 3dcalc
For reference, the usage for 3dcalc:
3dcalc -a dsetA [-b dsetB...] \ -expr EXPRESSION \ [options]
So you will be passing this program a series of volumes, which you will label as a, b, ... etc. and you will use these labels to build an expression, which you will indicate after the -expr
flag. Let's think about what we want to create:
We would like to retain the original numerical segmentation assignments in the aseg.mgz file, but drop all the voxels in that file that aren't included in the sig.cluster.nii.gz file. We can take advantage of a familiar and basic mathematical fact:
1 × x = x 0 × x = 0
So if we binarize our GLM data (i.e., turn it into 0s and 1s) and multiply it by the aseg.mgz file, then the resulting volume will have the original segmentation value wherever there was a significant voxel in our GLM analysis, and a 0 otherwise. If you explore the documentation for 3dcalc, you will find a list of functions that can be included in your expressions. The most useful one here is the ispositive(x)
function, which returns a 1 for all voxels where the value is greater than zero, and a 0 otherwise. This is exactly what we want!
3dcalc -a aseg.nii.gz -b perm.abs.01.sig.cluster.nii.gz \ -expr 'ispositive(b) * a' -prefix mask.nii.gz
You should see the following output, which lets you know it worked:
++ 3dcalc: AFNI version=AFNI_19.2.01 (Jul 3 2019) [64-bit] ++ Authored by: A cast of thousands ** AFNI converts NIFTI_datatype=8 (INT32) in file aseg.nii.gz to FLOAT32 Warnings of this type will be muted for this session. Set AFNI_NIFTI_TYPE_WARN to YES to see them all, NO to see none. ++ Output dataset ./mask.nii.gz