If you know the voxel indices (going from 1..N, rather than 0..N-1),
then you can get the mm coordinate by multiplying by one of the
matrices in the header.
Nii=nifti(filename); % Get header info
M = Nii.mat; % The matrix in the header
vox = [20 30 4] % an example voxel coordinate.
mm = M(1:3,:)*[vox 1]' % mm coordinate
Best regards,
-John
On 2 August 2013 11:36, Iwo Bohr <[log in to unmask]> wrote:
> Dear SPMers,
>
>
> Is there any routine automatically doing the above conversion?
> I know it should be possible to work it given the origin of the coordinate system (45 63 36 in voxels?) and voxel size (isotropic 2mm), but I'm afraid I can go astray something in the process.
>
> More precisely: I'm doing some processing on NIfTI images converted to Matlab matrices (using load_nii), so I assume that first I should rotate the matrices by 90 degrees to align them to the template orientation?
>
> In general am not sure how to align these matrices...
>
>
> Many thanks in advance,
>
>
>
> Iwo
>
> ---
> Iwo Bohr, PhD
> Research Associate,
> Newcastle Magnetic Resonance Centre
> Campus for Ageing and Vitality,
> Newcastle University,
> Newcastle upon Tyne, NE4 5PL, UK
> Tel. +44 191 248 1160
> Webpage: http://www.ncl.ac.uk/magres/staff/profile/iwo.bohr
|