The segmentation/spatial normalisation in SPM12 uses a different format for writing out deformation fields. They are now saved as vector fields, represented by a 5D image (where the 4th dimension has 1 element - as this dimension is really supposed to encode time - and the 5 th dimension has 3 elements).
If you have the deformation field as a y_*.nii, you can read the vector of 3 values at the spatial coordinate of interest. This gives coordinates in mm, which can then be converted to voxel indices by multiplying with the inverse of the voxel to world mapping from the image header.
Hi,
I have played around with this function a bit and have a more directed question that hopefully someone can answer.
spm_get_orig_coord.m seems to use the following variables from subject_seg_sn.mat: VG, Affine, Tr, and VF. For the new "Segment" implemented in SPM12, subject_seg8.mat has the following roughly analogous looking variables: tpm, Affine, Twarp, image.
However, when I rewrite spm_get_orig_coord.m to take the subject_seg8.mat, substituting the variables, it produces an output that's definitely incorrect. Does anyone know of the relevant variables in subject_seg8.mat that would allow me to make the correct substitutions?
Alternatively, I could do the following to get the voxel coords from an MNI-normed VOI: make the inverse transformation matrix in Segment, apply the inverse transform to the VOI.nii, find the center of mass of the transformed wVOI.nii, preferably in voxel coords (not sure how to do this last step in SPM).
Thanks in advance. Apologies for the multiple emails about this but I'm a bit stuck.