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

**URL:** https://community.mrtrix.org/t/the-command-dwifslpreproc-error-in-mrtrix3-version-3-0-3-while-correctly-run-in-the-version-3-0-2/5841
**Category:** Uncategorized
**Tags:** error, preprocessing, tractography
**Created:** [June 16, 2022, 1:57pm UTC](https://community.mrtrix.org/t/the-command-dwifslpreproc-error-in-mrtrix3-version-3-0-3-while-correctly-run-in-the-version-3-0-2/5841 "2022-06-16T13:57:59Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![GaoxingZheng](https://community.mrtrix.org/user_avatar/community.mrtrix.org/gaoxingzheng/32/3888_2.png) [@GaoxingZheng](https://community.mrtrix.org/u/GaoxingZheng)
#### Post date: [June 16, 2022, 1:57pm UTC](https://community.mrtrix.org/t/the-command-dwifslpreproc-error-in-mrtrix3-version-3-0-3-while-correctly-run-in-the-version-3-0-2/5841/1 "2022-06-16T13:57:59Z")

</div>

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:

```auto
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:

```auto
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:

```auto
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!

---

<div class="post-metadata">

### Author: ![GaoxingZheng](https://community.mrtrix.org/user_avatar/community.mrtrix.org/gaoxingzheng/32/3888_2.png) [@GaoxingZheng](https://community.mrtrix.org/u/GaoxingZheng)
#### Post date: [June 17, 2022, 3:00am UTC](https://community.mrtrix.org/t/the-command-dwifslpreproc-error-in-mrtrix3-version-3-0-3-while-correctly-run-in-the-version-3-0-2/5841/2 "2022-06-17T03:00:57Z")

</div>

I seem to find the solutions

> <https://github.com/MRtrix3/mrtrix3/blob/master/bin/dwifslpreproc>

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.

---

<div class="post-metadata">

### Author: ![jdtournier](https://community.mrtrix.org/user_avatar/community.mrtrix.org/jdtournier/32/2594_2.png) [@jdtournier](https://community.mrtrix.org/u/jdtournier)
#### Post date: [June 22, 2022, 3:05pm UTC](https://community.mrtrix.org/t/the-command-dwifslpreproc-error-in-mrtrix3-version-3-0-3-while-correctly-run-in-the-version-3-0-2/5841/3 "2022-06-22T15:05:52Z")

</div>

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:

```auto
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`:

```auto
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… 🤷‍♂️

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

```auto
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](https://community.mrtrix.org/t/dwifslpreproc-error-somewhere-after-the-topup-process/5248/4) in the process (also fixed on `master`, but not yet released… 😬).
