Transforming ROIs from MNI space to Native EPI space

Hello AFNI Gurus!
I have some ROIs in MNI space that I would like to transform back to native space so that I can extract time-series from EPIs in native (i.e. non-normalised) space using these ROIs as masks. The participants’ anatomies are normalised using SSwarper, and EPIs are aligned to the participants’ native space anatomies using through
I used the following 3dNwarpApply command

3dNwarpApply -source ${ROIDir}/MNI/${mask}+tlrc     \
            -ainterp NN                                                   \
            -master ${APDir}/pb04.sub-0${sub}.r01.scale+orig. \
            -nwarp ${APDir}/anatSS.${sid}_al_junk_mat.aff12.1D           \
            ${APDir}/anatQQ.${sid}.aff12.1D                              \
            ${APDir}/anatQQ.${sid}_WARP.nii                              \
            -iwarp                                                        \
            -prefix ${subjROIDir}/${sid}_MNI_${mask}.nii.gz

Is this the correct way to do this? I’m a little confused about whether to use the -iwarp flag, or whether to specify the transforms in the opposite order and not use the -iwarp flag. Finally, the anatSS.${sid}_al_junk_mat.aff12.1D is got from, but this command had the -anat2epi option. So should I be using the -I flag to invert this transform to undo the inversion from the -iwarp flag?
Thank you,

Hi, Mrinmayi-

Before getting to the technicalities of warp dsets, I have a conceptual question: which native EPI space do you want to map the MNI ROIs to? The succession of stages the EPI could theoretically be in is:

  • raw EPI (subject space, no motion correction/reduction)
  • motion corrected EPI (subject space, but volumes are rigid-bodily aligned to one reference volume)
  • EPI in anatomical space (subject space defined by the anatomical dset, probably an affine transform)
  • warped to standard space (concatenated a nonlinear transform to get to MNI).

Note that there are 3 “native space” options here. In practice, many pieces of this alignment are calculated individually, either “forwards” or “backwards and then inverted” (for the latter, the EPI-anatomical alignment). Then they get concatenated together and applied.

Another practical consideration here is how you have set up your single subject processing (I will humbly guess it was with…). In such a case, the ordering of blocks we typically recommend is something like (here, from s05* in the AFNI Bootcamp example):

-blocks tshift align tlrc volreg blur mask scale regress \

(And in the large variety of possible processing, I’m just focusing on the alignment-related blocks here: align, tlrc, and volreg). The important thing to note here is that the volreg block comes after the tlrc block, so in this case the “pbvolreg” dsets in the results directory (that is, the EPI dsets there that have motion correction applied) include the other warps to anatomical and then to template (MNI, here) space—that is, pbvolreg will be in MNI space already.

So, the questions are:

  • which EPI dset do you want use with the MNI ROIs?
  • how did you do your processing (namely, with AP, what is the order of blocks)?
  • what is your goal for getting stats of the EPI at the earlier stage using the MNI ROIs (sometimes knowing the specific scientific point of interest affects the recommendations)?
  • if you want stats on the motion-reduced EPI time series, AND your processing block order for warps (align, tlrc and volreg) looks like the example here, then how about if you used the MNI ROIs on the pbvolreg dset just as it is at present?


Hi Paul,
Thanks a lot for your response!

Yes, I did use to preprocess these people with the following blocks:

-blocks tshift align volreg mask blur scale regress

So the EPIs are never warped to standard space. The reason for this is because we’re looking to do multivariate analyses in small regions that are hand-segmented in individual T1s, and we don’t want to warp these to standard space because the non-linear warp applied to the EPIs might introduce distortion in these small regions (which is already probably happening with all the volreg and alignment transforms).

A small correction from my original post: I will be extracting parameter estimates from these ROIs rather than timeseries. So after alignment to native space anatomy (and blurring and scaling) I run 3dDeconvolve on each participant, and use the ROIs as masks to extract from Coeff sub-brick of the Deconvolve output. In order to replicate some past work, I want to run this analysis within ROIs centered around MNI co-ordinates reported in some papers. I need to transform these ROIs from MNI space to the individual’s native space EPIs aligned to the native space anatomies (or at least get equivalent co-ordinates in native space so I can make spherical ROIs around them).

Hope this answers your question!

Hi, Mrinmayi-

Thanks, that all does make sense.

I don’t think that “junk” or intermediate alignment should be necessary: you have aligned+warped your EPI to your subj anat, and you have the SSW transform from that same anat to MNI space, so you should just need to invert the SSW warp, and have the output dset be on the EPI grid (which overlays the anat, just more coarsely, I assume).

I think this is what I would try, where “${APDir}” looks like your variable for the AP results, and I am calling the directory with the SSW warps “${dir_ssw}”; if you have those anatQQ* dsets copied into the AP results dir, then you can use that variable again:

3dNwarpApply \
    -source     SOME_ROIS_IN_MNI    \
    -ainterp NN                                                   \
    -master ${APDir}/stats.${subj}+orig.HEAD                 \
    -nwarp  "${dir_ssw}/anatQQ.${subj}_WARP.nii ${dir_ssw}/anatQQ.${subj}.aff12.1D" \
    -iwarp  \
    -prefix  ${APDir}/OUTPUT_IN_SUBJ

NB: as a test, I would try warping the [0]th volume of the MNI SSW template to your subj space like this, to make sure that it looks like it overlaps the anatomical well:

3dNwarpApply \
    -source     MNI_TEMPLATE_SSW"[0]"    \
    -master ${APDir}/stats.${subj}+orig.HEAD                 \
    -nwarp  "${dir_ssw}/anatQQ.${subj}_WARP.nii ${dir_ssw}/anatQQ.${subj}.aff12.1D" \
    -iwarp  \
    -prefix  ${APDir}/MNI_IN_SUBJ

You can use 3dcalc to make spheres (from the program’s help):

7. Create a region-of-interest mask comprised of a 3-dimensional sphere.
   Values within the ROI sphere will be labeled as '1' while values     
   outside the mask will be labeled as '0'. Statistical analyses can    
   then be done on the voxels within the ROI sphere.                    

   The example below puts a solid ball (sphere) of radius 3=sqrt(9)     
   about the point with coordinates (x,y,z)=(20,30,70):                 

     3dcalc -a anat+tlrc                                              \
            -expr 'step(9-(x-20)*(x-20)-(y-30)*(y-30)-(z-70)*(z-70))' \
            -prefix ball