The command dwifslpreproc error in MRtrix3 version 3.0.3 while correctly run in the version 3.0.2

Hi, Recently I update the MRtrix3 (from version 3.0.2 to 3.0.3). However, the dwi tractography pipeline met errors during the dwifslpreproc procedure. Below is my error info:

dwifslpreproc: [ERROR] dwi2mask dwi_pad2_pe_0_applytopup.mif - | maskfilter - dilate - | mrconvert - eddy_mask.nii -datatype float32 -strides -1,+2,+3

dwi2mask : preloading data for dwi_pad2_pe_0_applytopup.mif
dwi2mask : [Error] no valid diffusion gradient table found
dwi2mask: [Error] error importing diffusion gradient table for image dwi_pad2_pe_0_applytopup.mif
maskfilter: [Error] no filename supplied to standard input (broken pipe?)
maskfilter: [Error] error open image -

… and so on

Here is my shell command:

paste -d " " ${Output_Folder}/AP/AP.bvec ${Output_Folder}/PA/PA.bvec >> ${Output_Folder}/Tracking/AP_PA.bvec

paste -d " " ${Output_Folder}/AP/AP.bval ${Output_Folder}/PA/PA.bval >> ${Output_Folder}/Tracking/AP_PA.bval

dwifslpreproc ${Output_Folder}/Tracking/degibbs.mif ${Output_Folder}/Tracking/DWI_preproc.mif -pe_dir AP -rpe_pair -se_epi ${Output_Folder}/Tracking/b0_pair.mif -nthreads 4 -fslgrad ${Output_Folder}/Tracking/AP_PA.bvec ${Output_Folder}/Tracking/AP_PA.bval -eddy_options " --data_is_shelled --slm=linear --niter=5 " -force

When I run the command in the MRtrix3 version 3.0.2 everything is okay, however, when I update the MRtrix3 into version 3.0.3, the dwifslpreproc met errors.

I just want to use the option -tratography.colourmap in the mrview, while it only provides in the version 3.0.3 rather than 3.0.2. Thus I update my MRtrix3.

Then check the file dwi_pad2_pe_0_applytopup.mif when I use the mrinfo -dwgrad it met errors:

mrinfo [ERROR] no valid diffusion gradient table found.
mrinfo [ERROR] error importing diffusion gradient table for image dwi_pad2_pe_0_applytopup.mif

Then I check the file dimension for my degibbs.mif (256 × 256 × 65 × 73), it has odd number in the third dims. And the dimension of dwi_pad2_pe_0_applytopup.mif is 256 × 256 × 66 × 73.

I guess the odd dims will meet error, however, I have no idea to deal with it. Hope you can give me some technique help, many thanks. The dwi scannner is GE Discovery 750.

Thank you very much!

I seem to find the solutions

I used the shell command “locate dwifslpreproc” to find the location of the dwifslpreproc file in my computer, and added the ’ -grad grad.b ’ in the corresponding lines. Below is my solution.

add the ’ -grad grad.b ’ into the command “run.command('mrconvert ’ + temp_path + ’ ’ + output_path + ’ -json_import ’ + json_path)”

add the ’ -grad grad.b ’ into the command “run.command(‘mrconvert ’ + dwi_path + import_dwi_pe_table_option + dwi_permvols_preeddy_option + ’ eddy_in.nii -strides -1,+2,+3,+4 -export_grad_fsl bvecs bvals -export_pe_eddy eddy_config.txt eddy_indices.txt’)”

Then save the file ‘dwifslpreproc’ and run the command sucessfully.

Hi @GaoxingZheng,

Sorry this isn’t working for you. I’ve been looking into this, and I can reproduce the error using 3.0.3. This doesn’t happen on our current master branch though (soon to be released as 3.0.4), and I’ll freely admit I’m not sure why that is.

The main reason is that the DW scheme information is supposed to be stored in the JSON sidecar file (dwi_pad2_pe_0.json) at this point:

Command:  mrconvert dwi_pad2.mif dwi_pad2_pe_0.nii -coord 3 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32 -strides -1,+2,+3,+4 -json_export dwi_pad2_pe_0.json

and this is then fed back in during the subsequent conversion back to mif:

Command:  mrconvert dwi_pad2_pe_0_applytopup.nii dwi_pad2_pe_0_applytopup.mif -json_import dwi_pad2_pe_0.json

But on 3.0.3, the JSON file doesn’t contain the DW scheme information. Works fine on the master, though I can’t identify a single change in the code that would explain this… :man_shrugging:

In the meantime, the simplest thing is just to make sure your input mif file already contains the correct DW information:

mrconvert ${Output_Folder}/Tracking/degibbs.mif ${Output_Folder}/Tracking/DWI_preproc_in.mif -fslgrad ${Output_Folder}/Tracking/AP_PA.bvec ${Output_Folder}/Tracking/AP_PA.bval

and use the resulting ${Output_Folder}/Tracking/DWI_preproc_in.mif as your input to dwifslpreproc without the -fslgrad option. That should work – though you may encounter a different bug in the process (also fixed on master, but not yet released… :grimacing:).