Dwipreproc error [Linux]

Hi, I am trying to run dwipreproc command

dwipreproc "$SUBJECT"_dwi_denoised.mif "$SUBJECT"_dwi_preproc.mif -json "$SUBJECT"_dwi.json -rpe_header -nocleanup -force -info

on linux workstation and I get this error:

Command:  mrconvert dwi.mif - | dwiextract - bzeros.mif -bzero
mrconvert: [100%] copying from "dwi.mif" to "/tmp/mrtrix-tmp-kFlxH2.mif"
dwiextract: [100%] extracting volumes
Traceback (most recent call last):
  File "/usr/pubsw/packages/mrtrix/current/bin/dwipreproc", line 372, in <module>
    if not image.headerKeyValue('bzeros.mif', 'pe_scheme'):
  File "/autofs/cluster/pubsw/2/pubsw/Linux2-2.3-x86_64/packages/mrtrix/3.0/lib/mrtrix3/image.py", line 29, in headerKeyValue
    if app.verbosity > 1:
AttributeError: module 'mrtrix3.app' has no attribute 'verbosity'

I ran the exact same command (using the same data) on a mac and it works well!

Thank you so much!

I am following up on this error. Any help would be appreciated! Thank you.

It looks to me like you have conflicting versions of MRtrix3, one installed in /usr/pubsw/packages/mrtrix/current/, the other in /autofs/cluster/pubsw/2/pubsw/Linux2-2.3-x86_64/packages/mrtrix/3.0/. For some reason, it looks like the command in the first location might be importing modules from the second location, which is presumably a different and incompatible version.

As to why that might be happening, my guess is you might have your PYTHONPATH environment variable pointing at the second location? Try unsetting that variable if it’s set:


If that’s not the issue, then I’m a bit stumped…

Thank you so much for your reply!
I tried to unset PYTHONPATH and got the same error. However, I changed my mrtrix path, I get this error now:

Command:  mrconvert dwi.mif - | dwiextract - bzeros.mif -bzero
Traceback (most recent call last):
  File "/autofs/cluster/pubsw/2/pubsw/Linux2-2.3-x86_64/packages/mrtrix/3.0/bin/dwipreproc", line 372, in <module>
    if not image.headerKeyValue('bzeros.mif', 'pe_scheme'):
  File "/autofs/cluster/pubsw/2/pubsw/Linux2-2.3-x86_64/packages/mrtrix/3.0/lib/mrtrix3/image.py", line 29, in headerKeyValue
    if app.verbosity > 1:
AttributeError: module 'mrtrix3.app' has no attribute 'verbosity'

I really appreciate your help!

OK, that’s unexpected, but it might be that /usr/pubsw/packages/mrtrix/current/ is a symbolic link to /autofs/cluster/pubsw/2/pubsw/Linux2-2.3-x86_64/packages/mrtrix/3.0/ – in which case that was a red herring…

So it looks like there might be a problem in the code. Can you report the version you’re using (dwipreproc -help, look for the version string in the top left of the screen)?

MRtrix 3.0_RC1-6-ge7f6714a

OK, that’s a pretty old version – dates back to May 2017. But it does show that there was indeed a bug in that version – that should be app._verbosity…

To fix this, I think all you need to do is edit the problematic line in lib/mrtrix3/image.py, so it would read:

  if app._verbosity > 1:

Or can I simply change the version? If so what version would be stable to use? I am just starting to use MRtrix. Thank you!

Indeed, that would be the simpler option – I’d assumed since it looks like you were running on a cluster, you might not have control over that…

Best thing to do is just to checkout the master branch – that’s what we consider stable and most bug-free. A simple git pull && ./configure && ./build should get you right up to date.

Thank you so much. We upgraded to 3.16 version

MRtrix 3.0_RC3_latest-71-gdba7ba1e-dirty        dwipreproc       bin version: 3.0_RC3_latest-71-gdba7ba1e-dirty

But I get this error though when I tried to run this command:

dwipreproc "$SUBJECT"_dwi_denoised.mif "$SUBJECT"_dwi_preproc.mif -json "$SUBJECT"_dwi.json -rpe_header -eddy_options "--niter=8 --fwhm=10,6,4,2,0,0,0,0 --repol " -nocleanup -force -info

dwipreproc: [ERROR] Command failed: eddy --imain=eddy_in.nii --mask=eddy_mask.nii --acqp=eddy_config.txt --index=eddy_indices.txt --bvecs=bvecs --bvals=bvals --out=dwi_post_eddy --niter=8 --fwhm=10,6,4,2,0,0,0,0 --repol (dwipreproc:891)
dwipreproc: Output of failed command:
            Part of FSL (build 507)
            Copyright(c) 2011, University of Oxford (Jesper Andersson)
            eddy --monsoon
            Compulsory arguments (You MUST set one or more of):
            	--imain	File containing all the images to estimate distortions for
            	--mask	Mask to indicate brain
            	--index	File containing indices for all volumes in --imain into --acqp and --topup
            	--acqp	File containing acquisition parameters
            	--bvecs	File containing the b-vectors for all volumes in --imain
            	--bvals	File containing the b-values for all volumes in --imain
            	--out	Basename for output
            Optional arguments (You may optionally specify one or more of):
            	--session	File containing session indices for all volumes in --imain
            	--topup	Base name for output files from topup
            	--flm	First level EC model (linear/quadratic/cubic)
            	--fwhm	FWHM for conditioning filter when estimating the parameters
            	--niter	Number of iterations (default 5)
            	--resamp	Final resampling method (jac/lsr)
            	--repol	Detect and replace outlier slices
            	-v,--verbose	switch on diagnostic messages
            	-h,--help	display this message
            --fwhm: Couldn't set_value! valstr="10,6,4,2,0,0,0,0"!
dwipreproc: Changing back to original directory (/autofs/cluster/atassigp/MMMB/MotorNeuronDisease/Data/BIOMARKER/BIO-ALS-701-020-BL/dwi)
dwipreproc: Script failed while executing the command: eddy --imain=eddy_in.nii --mask=eddy_mask.nii --acqp=eddy_config.txt --index=eddy_indices.txt --bvecs=bvecs --bvals=bvals --out=dwi_post_eddy --niter=8 --fwhm=10,6,4,2,0,0,0,0 --repol

is this a version problem? because the same command work on my mac version:
“MRtrix d411e6c5 bin version: d411e6c5”

Sounds like it’s the version of FSL that’s the problem. I don’t think version 5.0.7 supports the --repol option…

You are absolutely right! All works now. Thank you for your great knowledge, great support and for MRtrix!

1 Like

By the way, I note your version string ends with -dirty – this means there are local modifications in your installation compared to that specific commit. Type git diff in your MRtrix3 folder to see what these changes are. If these were unintentional, I recommend you revert those changes like this:

git reset --hard HEAD
1 Like