use Schaefer atlas in subject space

Hi,
How can I align this parcellation (Schaefer-Yeo, from this thread) to errts file in original space?

Thanks,
Maya

Hi, Maya-

I'll assume this refers to volumetric alignment (the S-Y atlas is defined on surface meshes as well, which transfer to subject space meshes directly if using SUMA-standardized ones).

This process will likely involve running nonlinear alignment between each subject's anatomical volume and the template on which the Schaefer-Yeo atlas is defined.

  • If the errts itself is living in the anatomical volume space, then that would be all that is necessary (that is, if the "align" block were used in afni_proc.py processing to get the errts).
  • If the subject space is only defined by the subject's EPI volume (that is, the "volreg" block was the only alignment-related block in the AP command), then additionally EPI-anatomical alignment would need to be calculated with align_epi_anat.py, and the nonlinear warp concatenated with that, and the resulting transform applied to the S-Y atlas.

I will assume here that the first is the case (going to subject anatomical space). Let me know if that is not the case. The steps then are:

  1. for each subject, estimate anatomical-template alignment nonlinearly.
    • If you have used sswarper2 (or the older @SSwarper) already to skullstrip the anatomical, then you have this warp already in hand.
    • If you haven't got the nonlinear anatomical-to-template warp already, then I would use sswarper2 to estimate the warp. You can use the skullstripping that you already have directly within the program now, if you have it.
  2. then, create the inverse warp from template space to subject anatomical space
  3. then apply the warp from template-to-anatomical space, using the errts file to define the grid and "NN" (nearest neighbor) interpolation to apply to the parcellation map, to preserve region definitions.

NB: I'll assume you are using the S-Y atlas that we have refined (downloadable from here, and described here), which sit on MNI-2009c space, and so MNI152_2009_template_SSW.nii.gz is an appropriate template space dataset.

1. The sswarper2 command

Cases:

  • if you have both a with-skull anatomical and a masked version or a mask that you trust deeply, so that you don't want it refined, then in AFNI version=25.0.12 and higher, you can run this:

    sswarper2                                     \
     -input   DSET_ANAT_W_SKULL                  \
     -mask_apply DSET_MASK       \
     -base    MNI152_2009_template_SSW.nii.gz  \
     -subid   ${subj}                       \
     -odir    o.ssw2_${subj}
    

    ... where DSET_MASK is either literally a binary mask dset or just the well-skullstripped dset (which will be binarized early on in the processing).

  • if you have both a with-skull anatomical and a masked version or a mask that you only sorta trust but would like refined further, you can run this (note the use of "-mask_ss" instead of "-mask_apply, which was used above):

    sswarper2                                     \
     -input   DSET_ANAT_W_SKULL                  \
     -mask_ss DSET_MASK       \
     -base    MNI152_2009_template_SSW.nii.gz  \
     -subid   ${subj}                       \
     -odir    o.ssw2_${subj}
    

    ... where DSET_MASK is either literally a binary mask dset or just the well-skullstripped dset (which will be binarized early on in the processing).

  • if you have onlywith-skull anatomical, run this:

    sswarper2                                     \
     -input   DSET_ANAT_W_SKULL                  \
     -base    MNI152_2009_template_SSW.nii.gz  \
     -subid   ${subj}                       \
     -odir    o.ssw2_${subj}
    

Check your sswarper2 results for happiness with the alignment. If happy, proceed and if not happy... let's troubleshoot that.

2. and 3.: Invert warps and apply

We can do these steps in one fell swoop. Here, I'll call the output sswarper2 directory ${odir}, assuming it contains the affine part of the transform (anatQQ.*.aff12.1D) and the nonlinear part (anatQQ.*_WARP.nii*).

# create the inverse transform from sswarper2 and apply it to atlas in template space
3dNwarpApply                                                        \
      -nwarp  "INV($odir/anatQQ.${subj}.aff12.1D)                   \
               INV(${odir}/anatQQ.${subj}_WARP.nii)"                \
      -ainterp NN                                                   \
      -master "${errts_dset}"                                       \
      -source "${dset_schaefer_yeo_refined}"                        \
      -prefix DSET_OUT

Check that things look good visually, and that the DSET_OUT is on the errts grid with:

3dinfo -same_all_grid "${errts_dset}" DSET_OUT 

... which should show five 1s, verifying the five properties being checked to determine "same-grid-ness".

And a bonus step: reattach labels and colormap-choice from the original atlas dset to the new one:

3drefit -copytables "${dset_schaefer_yeo_refined}" DSET_OUT
3drefit -cmap INT_CMAP  DSET_OUT

Then you could use 3dNetCorr, etc.

--pt