Error running dwibiascorrect command

Hello everyone,

I’m encountering an issue while running the dwibiascorrect command in MRtrix3. I’ve got this error:

 user@DESKTOP: my/working/directory$ dwibiascorrect ants dwi.mif dwi_bc.mif
dwibiascorrect:
dwibiascorrect: Note that this script makes use of commands / algorithms that have relevant articles for citation; INCLUDING FROM EXTERNAL SOFTWARE PACKAGES. Please consult the help page (-help option) for more information.
dwibiascorrect:
dwibiascorrect: Generated scratch directory: /my/working/directory/dwibiascorrect-tmp-UDAIJL/
Command:  mrconvert /my/working/directory/dwi.mif /my/working/directory/dwibiascorrect-tmp-UDAIJL/in.mif
dwibiascorrect: Changing to scratch directory (/my/working/directory/dwibiascorrect-tmp-UDAIJL/)
Command:  dwi2mask in.mif mask.mif
Command:  dwiextract in.mif - -bzero | mrmath - mean mean_bzero.mif -axis 3
Command:  mrconvert mean_bzero.mif mean_bzero.nii -strides +1,+2,+3
Command:  mrconvert mask.mif mask.nii -strides +1,+2,+3
Command:  N4BiasFieldCorrection -d 3 -i mean_bzero.nii -w mask.nii -o [corrected.nii,init_bias.nii] -s 4 -b [100,3] -c [1000,0.0]
Command:  mrcalc mean_bzero.mif mask.mif -mult - | mrmath - sum - -axis 0 | mrmath - sum - -axis 1 | mrmath - sum - -axis 2 | mrdump -
Command:  mrcalc corrected.nii mask.mif -mult - | mrmath - sum - -axis 0 | mrmath - sum - -axis 1 | mrmath - sum - -axis 2 | mrdump -
dwibiascorrect: [ERROR] mrcalc corrected.nii mask.mif -mult - | mrmath - sum - -axis 0 | mrmath - sum - -axis 1 | mrmath - sum - -axis 2 | mrdump - (ants.py:80)
dwibiascorrect: [ERROR] Information from failed command:
dwibiascorrect:
                mrcalc: computing: (corrected.nii * mask.mif)... [==================================================]
                mrmath: computing sum along axis 0...... []
                mrmath: [ERROR] error creating temporary file in directory "/my/working/directory/dwibiascorrect-tmp-UDAIJL/": No such file or directory
                mrmath: [ERROR] error creating image "-"
                mrmath: [ERROR] no filename supplied to standard input (broken pipe?)
                mrmath: [ERROR] error opening image "-"
                mrdump: [ERROR] no filename supplied to standard input (broken pipe?)
                mrdump: [ERROR] error opening image "-"
dwibiascorrect:
dwibiascorrect: [ERROR] For debugging, inspect contents of scratch directory: /my/working/directory/dwibiascorrect-tmp-UDAIJL/
dwibiascorrect: Scratch directory retained; location: /my/working/directory/dwibiascorrect-tmp-UDAIJL/

I tried this command on WSL2(Ubuntu 20.04.5 LTS).
MRtrix3 version is 3.0.4. (installed from Anaconda.)
ANTs Version is 2.4.4.post34-g7627c44.
Other commands (nii2mif, degibbs, etc.) have worked well so far.

Could you please provide some insights into what might be causing this error and any potential solutions to resolve it? Any help would be greatly appreciated.

Thank you in advance!

Hi @kenbridge6,

OK, this is unexpected… Can you confirm that the folder that the script claims does not exist, does in fact exist? For your run, that was the /my/working/directory/dwibiascorrect-tmp-UDAIJL/ folder.

Assuming it does exist, the issue may relate to something other than a ‘file not found’ error. The error message originates from core/file/utils.h, lines 224-232 in the code, which tries to create a new file with a random filename, ensuring it doesn’t overwrite an existing file. I’m not sure what error message the open() call might produce when trying to create a file using the O_CREAT | O_EXCL flags (which ensure it’s not opening an existing file, but creating a new one), but the call fails for reasons other than the file already exists. If for example there is no space left on the device, the call could fail and set the error code to ‘file not found’ – which I suppose is technically correct, but doesn’t really tell you why it doesn’t exist given that you’ve just asked for it to be created afresh…

All this to say, there’s a good chance the issue might relate to running out of space on that folder, or some similar problem. But I’ll freely admit this isn’t much more than an educated guess…

All the best,
Donald.

Hi Donald,

Thank you for your comment!

Actually, the error I was facing was solved by changing the working directory from external SSD to internal HDD.
(And I didn’t change anything other than that.)

I still do not know what caused the error, but I’d like to share this.

Wishing you a wonderful day!

Best regards,
kenbridge6

1 Like