How to convert from voxel index to MNI coordinates and vice versa.

Please see the figure below (aal.nii opened by MRIcroN).
The MNI coordinates of the current position is -66 -92 -40, and its value is 0. (-66x-92x-40= 0 on the titile).
The voxel index is 25 34 32. (X 25 Y 34 Z 32).

1. Read the file header:

[Data Header]=y_Read('aal.nii');

2. Convert from voxel index to MNI coordinates:
MNI_Coordinates = Header.mat*[25;34;32;1]
MNI_Coordinates =
-66
-92
-40
1

3. Convert from MNI coordinates to voxel index:
Voxel_Index = inv(Header.mat)*[-66;-92;-40;1]
Voxel_Index =
25
34
32
1

 老师,想请问问在 Nifti header 中, qform 和 sform 的 q 与 s 分别是什么意思? 两种存储方向信息的 forms 是说什么样的 forms? 这么分开理解合适吗? 很谢谢!

qform是与扫描仪相关,sform是与变换相关。SPM中常用的是sform。
http://nifti.nimh.nih.gov/nifti-1/documentation/nifti1fields/nifti1fields_pages/qsform_brief_usage