I have a very simple question about SPM12.
I obtained the anatomical T1 image of a participant,
and normalized the brain to MNI brain with SPM12 using spatial.normalise.estwrite.
I now have wOOO and y_OOO nifti files.
I now want to obtain a coordinate that corresponds to certain MNI coordinate (e.g. -8,-11,6)
within the original image.
How can I do this? Any help would be greatly appreciated.
Command used (and if a helper script was used, a link to the helper script or the command generated):
function [MNICoord]=GetMNICoord(InverseDeformationField,NativeCoord)
%Get voxel to mm transformation matrix:
M = spm_get_space(InverseDeformationField);
% Make Native coordinate a 4D collumn vector:
NativeCoordmm = NativeCoord(:);
NativeCoordmm = [NativeCoordmm(1:3) ; 1];
% Get Native coordinate in voxelspace
NativeCoordvox = M\NativeCoordmm;
% Round to nearest integer voxel:
NativeCoordvox = round(NativeCoordvox);
% % Load all of the deformation field into memory (SLOW)
% for dim=1:3
% [Y(:,:,:,dim),XYZ]=spm_read_vols(spm_vol([InverseDeformationField ',1,' num2str(dim)]));
% end
%
% % Get value at Native coordinate
% MNICoord = Y(NativeCoordvox(1),NativeCoordvox(2),NativeCoordvox(3),1:3);
% Alternative faster version using spm_sample_vol:
for dim=1:3
MNICoord(dim) = spm_sample_vol(spm_vol([InverseDeformationField ',1,' num2str(dim)]),NativeCoordvox(1),NativeCoordvox(2),NativeCoordvox(3),0);
end
MNICoord = MNICoord(:);