vistalab / vistasoft

VISTASOFT is the main software repository of the VISTA lab at Stanford University.
http://vistalab.stanford.edu
148 stars 142 forks source link

Problem with resolution of nifti after applied niftiApplyXform #298

Open soanduong opened 6 years ago

soanduong commented 6 years ago

I used the function niftiApplyXformto change the orientation of a nifti file (e.g. from 'LAS' to 'ILP'). However, the resolution of the new nifti computed by the transformation matrix is changed. Below is MATLAB script that I used

ni = readFileNifti('epi1.nii');
T = ni.sto_xyz;

xform = [0     0    -1     0;
         1     0     0     0;
         0    -1     0     0;
         0     0     0     1]
ni_new = niftiApplyXform(ni, xform);
T_new = ni_new.sto_xyz;

% Show the resolution from the transformation matrix
r1 = sqrt(sum(T(1:3,1:3).^2))
r2 = sqrt(sum(T_new(1:3,1:3).^2))

r1 and r2 are the resolutions of nifties. I think that the isotropic resolution should be kept with the given xform. However, they are not the same (e.g. r1 = [0.5 0.5 0.5] and r2 = [2 2 2]).

Do you have any idea about where I am wrong? Any offer is highly appreciated.