Error in DTI metrics estimation

While trying to compute DTI maps on a subject I jumped into the following error:

sct_dmri_compute_dti -i kurtosis_crop_moco.nii.gz -bval bvals -bvec bvecs -method restore -m kurtosis_crop_moco_dwi_mean_seg_dil.nii.gz

Spinal Cord Toolbox (4.1.0)

data.shape (42, 42, 16, 32)
Open mask file...
Computing tensor using "restore" method...
Traceback (most recent call last):
  File "/home/rosella/sct_4.1.0/scripts/", line 208, in <module>
  File "/home/rosella/sct_4.1.0/scripts/", line 120, in main
    if not compute_dti(fname_in, fname_bvals, fname_bvecs, prefix, method, evecs, file_mask):
  File "/home/rosella/sct_4.1.0/scripts/", line 172, in compute_dti
    tenfit =, mask)
  File "/home/rosella/sct_4.1.0/python/envs/venv_sct/lib/python3.6/site-packages/dipy/reconst/", line 793, in fit
  File "/home/rosella/sct_4.1.0/python/envs/venv_sct/lib/python3.6/site-packages/dipy/reconst/", line 1862, in restore_fit_tensor
  File "/home/rosella/sct_4.1.0/python/envs/venv_sct/lib/python3.6/site-packages/scipy/optimize/", line 392, in leastsq
    raise TypeError('Improper input: N=%s must not exceed M=%s' % (n, m))
TypeError: Improper input: N=7 must not exceed M=5

thanks for reporting this bug.
could you upload the files so we can try to reproduce it?

1 Like

here are the required data:
Rosellabvals (219 Bytes) bvecs (1.7 KB) kurtosis_crop_moco.nii.gz (1.5 MB)

kurtosis_crop_moco_dwi_mean_seg_dil.nii.gz (1.0 KB)

As noted here, the problem is likely related to your data, having too many outliers.

I recommend you switch to -method standard

1 Like