Dwibiascorrect after dwipreproc


Dear MrTrixers,

I am experiencing a problem running dwibiascorrect on the output of dwipreproc. I get the following message: “dwibiascorrect: [ERROR] Command failed: N4BiasFieldCorrection -d 3 -i mean_bzero.nii -w mask.nii -o [corrected.nii,bias.nii] -s 2 -b [150] -c [200x200,0.0]”. I ve checked the output of dwipreproc and they looked correct.
However if I run eddy_openmp in FSL and then run dwibiascorrect on the nifty output it works just fine.
Any idea?




Hi Chiara,
When the dwibiascorrect script exits, it won’t delete the working temporary folder (at least with later versions of MRtrix). You can then change directory into this temporary folder, and re-run the command that failed. This should then give you some idea of why it failed (hopefully an error message).


I am having a problem too with dwibiascorrect after calling dwipreproc, it doesn’t show any errors when running, but the output image is all black (there’s nothing). What can I do?


Hi @carolinajimenez26,

For any one of us to be able to help you, you’ll have to provide at least a bit more information; for instance the output of dwibiascorrect at the command line, maybe a screenshot of your input, the exact dwibiascorrect command line you ran (i.e. typed), and your MRtrix3 version.



This is the image input (preprocessed with dwidenoise and dwipreproc in thtat order):

This is the command I used:

dwibiascorrect dwi_distCorr.mif biasCorrect.mif -fsl

And this is the output I get:


I’m not sure what’s going on here, but a few thoughts:

  • the intensity value displayed in the output is shown as ‘?’, which means it’s not a finite number, most likely NaN (not-a-number) resulting from a divide-by-zero. This would indicate that FSL’s fast has produced a zero bias field, but that’s just a hunch. And this admittedly doesn’t help you much – but it’s a suggestion as to where to start digging…

  • if you try running the script with the -nocleanup option, you’ll be able to inspect intermediate files produced by the script (look at the output of the script to see where that folder is located, and all the commands invoked). It will definitely be instructive to check the direct inputs and outputs to & from the fast command. You could also run with the -debug option, which will produce potentially informative diagnostic information. Do post the full output of the command as well, by the way, not just the command itself: that’s often how we can stop what’s going on.

  • Is there any particular reason why you need to use the -fsl option? I get the feeling that the -ants approach is generally more robust (others will no doubt confirm).


Yeah, an added “problem” with the -fsl option is that it only ends up correcting inside the brain mask, and leaves the intensities untouched outside of it, creating a quite artificial image… we’re now warning stronger against using this option in the upcoming RC3 for these reasons.


It is because I already have installed fsl, but I am going to try with ANTs to see if the result is positive… Thank you for the advices, I am going to check that and will answer again this issue :slight_smile: