In AFNI, we have a couple ways to do this.
- With the standard whereami (afni_whereami) command, one can use a command like
whereami -lpi -calc_chain TT_N27 MNI_2009c_asym \
-xform_xyz_quiet 10 4 1
That computes transformations among known spaces using precomputed “standard” transformations that can include affine, 12-piece, 2-piece and identity transformations. Importantly, it does not include nonlinear transformations, so it’s of more limited use for your application because the differences between the N27 and the MNI 2009c brains are similar with effectively only a nonlinear transformation between the two spaces.
- For nonlinear transformations, given an alignment between two spaces like MNI_N27 and MNI_2009c_asym, then there will be a pair of datasets - the affine transformation (…aff12.1D) and a nonlinear warp dataset (…WARP.nii). To transform coordinates, one can use a command like this
3dNwarpXYZ -nwarp 'anatQQ.WARP.nii anatQQ.aff12.1D' [-iwarp] testxyz.1D
where the nonlinear warp, an affine transformation and a list of coordinates are provided in DICOM (RAI) order. The transformations can come from the result of aligning one template to another - maybe with sswarper2, auto_warp.py or 3dQwarp. Transformations can be concatenated (chained together) to go back and forth among multiple spaces, but direct transformations are better. The transformation and WARP directions are important, and you may need to invert and reverse the warp components with ‘INV(…WARP.nii.gz)’ or just use -iwarp.
For this case, I ran a simple 3dQwarp to create the WARP file here.
3dQwarp -prefix N27_to_MNI2009c.nii.gz \
-base ~/abin/MNI152_2009_template.nii.gz \
-source ~/abin/MNI_caez_N27+tlrc. -resample
https://osf.io/sjqhm/files/osfstorage
For the case of transforming the coordinates from N27 to the MNI 2009c asymmetric space, you should be able to do this:
3dNwarpXYZ -nwarp 'N27_to_MNI2009c_WARP.nii.gz' -iwarp testxyz.1D
For more info, see these links:
https://afni.nimh.nih.gov/pub/dist/doc/program_help/3dNwarpXYZ.html
https://discuss.afni.nimh.nih.gov/t/maintain-crosshair-in-gui-when-switching-between-views-tlrc-to-orig/6969/4
https://github.com/afids/afids-macaca/blob/master/registration/nl_coords_transform.py
Other related projects use underlying ANTs transformations. These can be applied similarly with ANTS commands.
https://www.templateflow.org/
https://prime-re.github.io/templates_and_atlases/rhemap.html