GM mask through SSwarper

Hello,
I am looking to get a bit of guidance on how to generate a grey matter mask using SSwarper. I have never used this program before but one of my lab mates has used it for some issues she was having with her data. I am attaching the script used below for reference.
I have been reading as much documentation that I can find but as a novice am confused about a few things. First, when you run SSwarper on a subject do I need to input any specific command for it to produce a GM mask in the output? I have looked in my labmates outputs and cant seem to find any file that would correspond to such a thing.
Second, can this mask be used during for a single participants processing to restrict analysis to the GM only? Or is that only done during group analysis?
Finally, can a single mask generated from SSwarper be used for group analysis considering its warped to a specific template or would I still want to average each subjects together to try and create a better fit?
I know these are likely pretty basic questions but I would love to hear what someone has to say and it would help me greatly. Thanks very much.
Austin

#tcsh syntax


setenv OMP_NUM_THREADS 8


echo parameter 1 is $1
set subj = $1 

set indir     = /space/kmsyn03/projects/MGH_alc/Stroop/individual/$subj/Afni
set template  = /space/kmsyn03/projects/MGH_alc/Stroop/individual/$subj/Afni/MNI152_2009_template_SSW.nii.gz
set anat = /space/kmsyn03/projects/MGH_alc/Stroop/individual/$subj/Afni/{$subj}_anat2.nii
set odir = /space/kmsyn03/projects/MGH_alc/Stroop/individual/$subj/Afni/SSwarperTEST
 
    @SSwarper                     \
        -input  ${anat}           \
        -base   ${template}       \
        -subid  ${subj}           \
        -odir   ${odir}		  \

Hi, Austin-

The SSW reference templates are special, multivolume datasets. The [0]th volume is a skull-less anatomical dset, and the other 4 volumes have more information used in various parts of the @SSwarper program. You can see these a bit more here:
https://afni.nimh.nih.gov/pub/dist/doc/htmldoc/template_atlas/sswarper_base.html#reference-templates-for-sswarper

The [4]th volume is (from the help):


[4] = binary mask for gray matter plus some CSF (slightly dilated)
          ++ this volume is not used in this script
          ++ it is intended for use in restricting FMRI analyses
             to the 'interesting' parts of the brain
          ++ this mask should be resampled to your EPI spatial
             resolution (see program 3dfractionize), and then
             combined with a mask from your experiment reflecting
             your EPI brain coverage (see program 3dmask_tool).

So, this is the closest to being a GM mask, but it isn’t pure GM.

To your specific questions:

  1. “when you run SSwarper on a subject do I need to input any specific command for it to produce a GM mask in the output?”
    —> there isn’t such. In the animal-MRI processing world, the @animal_warper program (similar-ish to @SSwarper, but different, too) does allow one to put in other standard space maps and have those sent along the estimated transforms to subject space, or vice versa. But @SSwarper at present doesn’t.

  2. “can this mask be used during for a single participants processing to restrict analysis to the GM only? Or is that only done during group analysis?”
    —> This program is not the way to generate a GM mask (but see below for a pretty good way to generate such a beast).

  3. “can a single mask generated from SSwarper be used for group analysis considering its warped to a specific template or would I still want to average each subjects together to try and create a better fit?”
    —> SSwarper works to mask your input anatomical, but that is a whole brain (WB) mask, not a GM/tissue mask.


In order to generate a group level whole brain mask, what we might recommend if you are using afni_proc.py to process your subjects:

  • take the individual masks from single subject processing, and make a new mask based on where 70% or more of them overlap
  • the “70%” is just an empirically kinda useful value—a lot of overlap, but some flexibility
  • for the single subject masks to use, with afni_proc.py outputs, these would likely be the mask_epi_anat*.HEAD dsets (the combination of EPI and anatomical coverage per subj)
  • The explicit AFNI command to do this could look like the following, globbing over each mask in each “results” directory output by afni_proc.py:

3dmask_tool -input GROUP/*.results/mask_epi_anat*.HEAD \
            -prefix group_mask.7 -frac 0.7

This step, and a a lot of these processing choices and rationales we recommend for processing (with specific details on afni_proc.py) are described here:
https://www.biorxiv.org/content/10.1101/308643v1.abstract

In terms of getting a GM-specific group mask: if you have all your data in standard space, there might be a GM tissue mask associated with that template; perhaps you could just take that and intersect it with you new WB mask. Though, in practice, and depending on your specific purpose, you might want to inflate that slightly, because while nonlinear alignment can be quite good, it is not perfect. Or, if you ran FreeSurfer’s recon-all on all of your subjects, you could pass the individually-estimated GM masks from that into afni_proc.py as well, having those sent along to your final EPI space, and then you could merge them in some fashion across your entire group. Again, what to do about a GM mask in standard space depends on your specific goal.

Hope there are some useful tidbits in this long and windy reply.

–pt

Hello,
Thank you for your quick response to my questions. Your answers make sense. I just have one follow up question for right now. I had read through help section regarding the SSW templates and saw that the 4th volume is a dilated GM mask. Is it possible/what is the easiest way to use only the 4th volume of the MNI template as a mask for volume wise analysis? Or am I again misinterpreting what the template/program is capable of?

Best,
Austin

Hi, Austin-

Please note the full description of the [4]th volume:


[4] = binary mask for gray matter plus some CSF (slightly dilated)
          ++ this volume is not used in this script
          ++ it is intended for use in restricting FMRI analyses
             to the 'interesting' parts of the brain
          ++ this mask should be resampled to your EPI spatial
             resolution (see program 3dfractionize), and then
             combined with a mask from your experiment reflecting
             your EPI brain coverage (see program 3dmask_tool).

… namely that it is an inflated GM map, that includes more than just the GM of the template itself (many templates come with tissue maps, too).

The idea of inflating it is to provide a mask that cover GM of perfectly aligned data and GM of non-perfectly aligned data. While SSwarper and the 3dQwarp alignment tools underneath are quite good, they are not perfect; and there is a lot of variability across human brains to try to overcome, like different numbers of sulci/gyri in a given part of the brain across a group.

So, how much this expanded GM is useful for your analysis depends on what specifically you want to do. What do you want to do with this GM mask?


On separate AFNI notes of selecting/resampling volumes like this:

If you wanted to make a separate volume of just that [4]th volume of the MNI-SSwarper reference dset, you could do something like:


3dcalc -a MNI152_2009_template_SSW.nii.gz"[4]" -expr "a" -prefix MNI152_2009_template_SSW_vol4_only.nii.gz

If you had some output EPI data in the MNI space at a particular resolution, you could both grab the [4]th volume and resample it to that grid with:


3dresample    \
      -input MNI152_2009_template_SSW.nii.gz"[4]"    \
     -master DSET_EPI_IN_MNI     \
     -rmode NN     \
     -prefix  MNI152_2009_template_SSW_vol4_only_res2epi.nii.gz

–pt

Well with the data we have collected we are primarily interested in group differences in grey matter based activations. So ultimately we are trying to eliminate unnecessary voxels, such as those from white matter, from our analyses to reduce the number of statistical tests (we have nearly 290,000 total voxels) AFNI performs during group analysis. Some preliminary group analyses that have been ran have shown nice results with respect to the p-value but maintains a high q-value. I know there are a number of ways to go about alleviating this issue but this seemed like a reasonable avenue for beginning to solve this problem. Perhaps you have some advice for alternative or more proper methods to help with this issue.
Thanks very much,
Austin