Working with Subcortical ROIs (Freesurfer): Difference between revisions
No edit summary |
|||
Line 23: | Line 23: | ||
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 <code>-expr</code> flag. Let's think about what we want to create: | 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 <code>-expr</code> 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 basic mathematical fact that we have known for many years: | 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 basic mathematical fact that we have known for many years: | ||
1 & | 1 × x = x | ||
0 & | 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 <code>ispositive(x)</code> 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! | 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 <code>ispositive(x)</code> 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.mgz -b perm.abs.01.sig.cluster.nii.gz \ | 3dcalc -a aseg.mgz -b perm.abs.01.sig.cluster.nii.gz \ | ||
-expr 'ispositive(b) * a' -prefix mask.nii | -expr 'ispositive(b) * a' -prefix mask.nii |
Revision as of 15:07, 8 July 2019
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.
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 ./
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 basic mathematical fact that we have known for many years:
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.mgz -b perm.abs.01.sig.cluster.nii.gz \ -expr 'ispositive(b) * a' -prefix mask.nii