Hi DIPY Experts,
I am interested in saving the diffusion tensor as a NIFTI file created as part of the free water implementation. I ran the following commands:
import sys
import os
import bz2file
import numpy as np
import nibabel as nib
import dipy.reconst.fwdti as fwdti
import dipy.reconst.dti as dti
import matplotlib.pyplot as plt
fdwi="dwi_tpl_max2000.nii.gz"
fbval="dwi_tpl_max2000.bvals"
fbvec="dwi_tpl_max2000.bvecs"
mask_wb="mask.tpl.final.nii.gz"
img = nib.load(fdwi)
data = img.get_data()
affine = img.affine
mask = nib.load(mask_wb)
maskdata = mask.get_data()
fwdtimodel = fwdti.FreeWaterTensorModel(gtab,fit_method='NLS')
fwdtifit = fwdtimodel.fit(data, mask=maskdata)
1) The following errors were displayed even though the code ran after running the fwidtifit command above:
.../python_local/scipy/optimize/minpack.py:447: RuntimeWarning: Number of calls to function has reached maxfev = 1800.
warnings.warn(errors[info][0], RuntimeWarning)
...python_local/dipy/reconst/fwdti.py:454: RuntimeWarning: overflow encountered in exp
y = (1-f) * np.exp(np.dot(design_matrix, tensor[:7])) + \
I wanted to verify if this is just due to imperfect masking near the edge or if this means the code did not fully run and that there are errors to fix.
2) I ran the following code to save the tensor, as from my understanding fwdtifit uses the DTI tensorfit module:
img = nib.Nifti1Image(fwdtifit.quadratic_form, affine)
nib.save(img, 'FWms_quadratic_form.nii.gz')
Is this the upper or lower triangle? The NIFTI standard is lower triangle, but given that in the DTI module has a lower_triangular function I am guessing DIPY default is the upper triangle.
I am having trouble using the lower_triangular function so if you can send me the correct way to interface with this command that would be much appreciated.
Thanks,
Ajay