Open matthew-brett opened 9 years ago
Checking with dipy suggested that the directions are correct - so it looks as though FSL does not tolerate A-P flipped images. We could either ship as is, or reorient the images / bvecs to be compatible with FSL.
+1 for outputting data that is properly interpreted by FSL, even though it's annoying :(
Script to view tensors. Run on fixed_dti.nii
, a version of DTI_15DIR_SENSE_4_1.PAR
from nitest-parrec
with the last spurious volume removed:
import numpy as np
import nibabel as nib
from dipy.core.gradients import gradient_table
from dipy.segment.mask import median_otsu
import dipy.reconst.dti as dti
from dipy.reconst.dti import fractional_anisotropy, color_fa
from dipy.data import get_sphere
from dipy.viz import fvtk
gtab = gradient_table('fixed_dti.bvals', 'fixed_dti.bvecs')
img = nib.load('fixed_dti.nii')
data = img.get_data()
maskdata, mask = median_otsu(data)
tenmodel = dti.TensorModel(gtab)
tenfit = tenmodel.fit(maskdata)
FA = fractional_anisotropy(tenfit.evals)
FA[np.isnan(FA)] = 0
FA = np.clip(FA, 0, 1)
RGB = color_fa(FA, tenfit.evecs)
sphere = get_sphere('symmetric724')
ren = fvtk.ren()
evals = tenfit.evals[42:86, 61:88, 26:27]
evecs = tenfit.evecs[42:86, 61:88, 26:27]
cfa = RGB[42:86, 61:88, 26:27]
cfa /= cfa.max()
fvtk.add(ren, fvtk.tensor(evals, evecs, cfa, sphere))
fvtk.show(ren)
More info - when using the current master branch parrec2nii
conversion, and running dtifit
followed by fslview
, the tensors look flipped in Y - the original observation. Reading the V1 tensor orientation for a voxel in the corpus callosum that should be pointing from right lower to left upper on the slice gives:
In [5]: v1 = nib.load('fsl_base_V1.nii.gz')
In [6]: v1.get_data()[71, 79, 30]
Out[6]: array([-0.65730137, -0.569175 , -0.49395818], dtype=float32)
I don't know what axes these refer to, but if these are using same axes as the bvecs, that is, the voxel directions of the image, then I think this is incorrect, because it points to the left (minus X) lower (minus Y) direction on the image.
See discussion at the end of #275.
We are looking at the DTI data in https://bitbucket.org/nipy/nitest-parrec and in particular at the PAR / REC converted bvectors for the file
DTI_15DIR_SENSE_4_1.PAR
in that repo.With the code at the current time of writing,
parrec2nii --bvs DTI_15DIR_SENSE_4_1.PAR
gives bvectors of:Running
dcm2nii
on theDICOM
folder of this repository gives a converted filex20141118_192645WIPDTI15DIRSENSEs401a1004.nii.gz
which appears to be equivalent. This file is flipped in the second (Y) direction compared toDTI_15DIR_SENSE_4_1.PAR
. The converted bvectors are:These are the same as the PAR / REC bvecs multiplied by -1, but with the Y sign inverted, as you'd expect from the different voxel orientations of the two images.
When I run FSLs
dtifit
on thedcm2nii
data, and view the first eigenvector lines, these look correct, and aligned with the corpus callosum.If I do the same on the converted PAR / REC files, the Y direction of the tensor looks flipped.
If I flip the Y axis of the PAR / REC converted image, and flip the sign of the Y bvec value, save this out and then run
dtifit
, runfslview
the Y direction of the tensor looks correct.Is it possible that FSL insists on canonical P-A image voxel orientation?
@mrjeffs - how did you check the tensor orientation?