Dwifslpreproc causes "studies in base image (199) does not match number of rows in diffusion gradient table (398)"


I am trying to process some data from the aging human connectome project.

Before processing, I concatenate the 4 diffusion images they collected

mrcat dwi_98_AP.mif dwi_99_AP.mif dwi_98_PA.mif dwi_99_PA.mif dwi.mif

Then I run it through
dwidenoise & mrdegibbs

I then use eddy current correction using the -rpe_header verison

dwifslpreproc -force -eddyqc_text QC -rpe_header dwi_denoised_unringed.mif dwi_prep.mif

This seems to work, however, when trying to run dwimask or dwibiascorrect afterwards I get the following errors.

dwi2mask: [100%] preloading data for “dwi_prep.mif”

dwi2mask: [ERROR] number of studies in base image (199) does not match number of rows in diffusion gradient table (398)

dwi2mask: [ERROR] unable to get valid diffusion gradient table for image "dwi_prep.mif"
dwibiascorrect: [ERROR] Unhandled Python exception:

dwibiascorrect: [ERROR] TypeError: can only concatenate str (not “int”) to str

dwibiascorrect: [ERROR] Traceback:

dwibiascorrect: [ERROR] /Applications/MRtrix3Tissue/bin/dwibiascorrect:49 (in execute())

dwibiascorrect: [ERROR] raise MRtrixError(‘DW gradient scheme contains different number of entries (’ + str(len(dwi_header.keyval()[‘dw_scheme’])) + ’ to number of volumes in DWIs (’ + dwi_header.size()[3] + ‘)’)

I am not sure what is causing this issue? Does it have something to do with the header information? This would be weird as eddy correction seemed to work and I imported all the information from the .json for all of the dwi_98_AP.mif files.

Let me know if you have any ideas on how to twouble shoot this issue.


Hi Daniel,

The issue is the use of software not supported by the MRtrix3 team, which does not contain the latest bug fixes. This particular issue was first reported on the forum here, with the relevant fix to the code on GitHub here, and it was mentioned in the changelog here.


Thank you!