Hi Alle,

I think you're right, the matrix seems not correct, currently I'm using
http://www.mathworks.com/matlabcentral/fileexchange/29344-read-medical-data-3d
[info] = nii_read_header('XXX.nii')

And I also tried another software:
http://www.restfmri.net/forum/node/1300
[Data Header]=rest_ReadNiftiImage('XXX.nii');

They got similar rotation matrix, however both are not correct, at least for my data. What is the correct way to get the sform matrix?

Thanks for your reply,
Hong





At 2015-10-07 03:42:38, "Alle Meije Wink" <[log in to unmask]> wrote:

Dear Than,

The way you compute voxel_index looks spot on to me. But the Sform does not look like a standard MNI Sform (at least not the 2x2x2 mm one in which most atlases are defined). Could this have caused your problem?

With best wishes
Alle Meije Wink




Date: Wed, 7 Oct 2015 02:48:50 +0800
From: Sisy <[log in to unmask]>
Subject: How to map the MNI coordinate back to NIFTI voxel index?

Hi All,

I have a general question to ask. How to map the MNI coordinate back to NIFTI voxel index, that we could access data from nii_object.img?
For example, I'd like to get the voxel data locates in the calcarine area, where the MNI coordinate shows [-7 -72 16 1], so I use Sform matrix where I got from the header

Sform =

-3 0 0 78 -> SrowX
0 3 0 -112 -> SrowY
0 0 3 -50 -> SrowZ
0 0 0 1 -> appended

and I got voxel_index = inv(Sform)*[-7 -72 16 1]';
voxel_index =

28.3333
13.3333
22.0000
1.0000

But if I use nii_object.img(28,13, 22) I couldn't get the same value as it shows. Consider Matlab is 1 based, I also tried (29,14,23) but it doesn't work either.

Than

gmail sent from phone