Print

Print


Hi,

I'm afraid that applying matrices can get slightly tricky.

I am not sure what the "normalized image header"
means.

If it means either the qform or sform matrix
from the nifti header, then the correct thing to do
is to apply it to the nifti voxel coordinates.  This is
described quite well in the $FSLDIR/src/niftiio/nifti1.h
file.  Note that the voxel coordinates start at 0, as
FSLView displays them.  For instance, in the
MNI152_T1_2mm template image you'll find (with fslhd):
sto_xyz:1      -2.000000  0.000000  0.000000  90.000000
sto_xyz:2      0.000000  2.000000  0.000000  -126.000000
sto_xyz:3      0.000000  0.000000  2.000000  -72.000000
sto_xyz:4      0.000000  0.000000  0.000000  1.000000
which if multiplied by a voxel coordinate like
(26,47,45) gives (38,-32,18) - exactly what FSLView reports.

Alternatively, if you are dealing with mappings created
by flirt matrices then we provide the utilities img2imgcoord,
img2stdcoord and std2imgcoord so that coordinate
mappings can be done easily.

Hope this answers your question.
All the best,
	Mark



On 24 Mar 2009, at 07:06, Michael T Rubens wrote:

> Bonjour,
>
> When I convert my voxel coordinates into MNI coords, the resulting  
> coordinates do not exactly match the corresponding display in  
> FSLview. I convert the voxels like so:
>
> V = normalized image header
> xyz = n*3 matrix of voxel coords
>
> mni_coords = (V.mat * [xyz ones(size(xyz,1),1)]')';
> mni_coords = mni_coords(:,1:3);
>
> %% But, if I add the voxel dims from V.mat, then it matches.
>
> m = diag(V.mat);
> mni_coords = mni_coords + repmat(m(1:3)',size(xyz,1),1);
>
> Which is the correct conversion?
>
> Thanks,
> Michael
>
>
> -- 
> Research Associate
> Gazzaley Lab
> Department of Neurology
> University of California, San Francisco