Errors with dwidenoise and dwipreproc

Dear MRtrix3 experts,

I’m running the dwidenoise and dwipreproc commands on a data set and appear to be running into problems.

The first is with dwipreproc:

$ dwipreproc -nthreads 20 dwi_denoised.mif dwi_preprocessed.mif -pe_dir AP -rpe_pair -se_epi b0s.mif
dwipreproc:
dwipreproc: 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.
dwipreproc:
dwipreproc: Generated temporary directory: /ibscratch/users/uqisaham/CAI_imaging/files_relevant_to_analysis/mrtrix3_Preprocessed_Data/S06_KC-3T/HARDI/dwipreproc-tmp-TNDEA2/
Command: mrconvert /ibscratch/users/uqisaham/CAI_imaging/files_relevant_to_analysis/mrtrix3_Preprocessed_Data/S06_KC-3T/HARDI/dwi_denoised.mif /ibscratch/users/uqisaham/CAI_imaging/files_relevant_to_analysis/mrtrix3_Preprocessed_Data/S06_KC-3T/HARDI/dwipreproc-tmp-TNDEA2/dwi.mif
Command: mrconvert /ibscratch/users/uqisaham/CAI_imaging/files_relevant_to_analysis/mrtrix3_Preprocessed_Data/S06_KC-3T/HARDI/b0s.mif /ibscratch/users/uqisaham/CAI_imaging/files_relevant_to_analysis/mrtrix3_Preprocessed_Data/S06_KC-3T/HARDI/dwipreproc-tmp-TNDEA2/topup_in.mif
dwipreproc: Changing to temporary directory (/ibscratch/users/uqisaham/CAI_imaging/files_relevant_to_analysis/mrtrix3_Preprocessed_Data/S06_KC-3T/HARDI/dwipreproc-tmp-TNDEA2/)
Command: mrinfo dwi.mif -export_grad_mrtrix grad.b
dwipreproc: [WARNING] Topup images contain at least one non-even dimension; cropping images for topup compatibility
Command: mrcrop topup_in.mif topup_in_crop.mif -axis 2 1 54
Command: mrconvert topup_in_crop.mif topup_in.nii -import_pe_table topup_manual_pe_scheme.txt -stride -1,+2,+3,+4 -export_pe_table topup_datain.txt
Command: topup --imain=topup_in.nii --datain=topup_datain.txt --out=field --fout=field_map.nii.gz --config=/clusterdata/apps/fsl/etc/flirtsch/b02b0.cnf
Command: mrinfo dwi.mif -export_pe_eddy applytopup_config.txt applytopup_indices.txt
Command: dwiextract dwi.mif -pe 0,-1,0,0.0464 dwi_pe_1.nii
Command: applytopup --imain=dwi_pe_1.nii --datain=applytopup_config.txt --inindex=1 --topup=field --out=dwi_post_topup.nii.gz --method=jac
Command: mrconvert dwi_post_topup.nii.gz -grad grad.b - | dwi2mask - - | maskfilter - dilate - | mrconvert - mask.nii -datatype float32 -stride -1,+2,+3
Command: mrconvert dwi.mif dwi.nii -stride -1,+2,+3,+4 -export_grad_fsl bvecs bvals -export_pe_eddy eddy_config.txt eddy_indices.txt
Command: eddy_openmp --imain=dwi.nii --mask=mask.nii --acqp=eddy_config.txt --index=eddy_indices.txt --bvecs=bvecs --bvals=bvals --topup=field --out=dwi_post_eddy
dwipreproc:
> dwipreproc: [ERROR] Command failed: eddy_openmp --imain=dwi.nii --mask=mask.nii --acqp=eddy_config.txt --index=eddy_indices.txt --bvecs=bvecs --bvals=bvals --topup=field --out=dwi_post_eddy (dwipreproc:470)
> dwipreproc: Output of failed command:
> Image Exception : #3 :: Attempted to add images/ROIs of different sizes
> terminate called after throwing an instance of 'RBD_COMMON::BaseException’
dwipreproc: Changing back to original directory (/ibscratch/users/uqisaham/CAI_imaging/files_relevant_to_analysis/mrtrix3_Preprocessed_Data/S06_KC-3T/HARDI)
dwipreproc: Script failed while executing the command: eddy_openmp --imain=dwi.nii --mask=mask.nii --acqp=eddy_config.txt --index=eddy_indices.txt --bvecs=bvecs --bvals=bvals --topup=field --out=dwi_post_eddy
dwipreproc: For debugging, inspect contents of temporary directory: /ibscratch/users/uqisaham/CAI_imaging/files_relevant_to_analysis/mrtrix3_Preprocessed_Data/S06_KC-3T/HARDI/dwipreproc-tmp-TNDEA2/

The second is with dwidenoise:

$ dwidenoise …/rawdata/DTI_66/ dwi_denoised.mif
dwidenoise: [done] scanning DICOM folder "…/rawdata/DTI_66/"
dwidenoise: [100%] reading DICOM series "NODDI_OUTER_SHELL_66"
dwidenoise: [100%] preloading data for "C_S01_PZ_3T (C_S01_PZ_3T) [MR] NODDI_OUTER_SHELL_66"
dwidenoise: [100%] running MP-PCA denoising
[uqisaham@inode HARDI]$ ls
dwi_denoised.mif
[uqisaham@inode HARDI]$ mrview dwi_denoised.mif
mrview: WARNING: invalid key "EchoTime in generic image header “./dwi_denoised.mif” - ignored
mrview: WARNING: invalid key "PhaseEncodingDirection in generic image header “./dwi_denoised.mif” - ignored
mrview: WARNING: invalid key "TotalReadoutTime in generic image header “./dwi_denoised.mif” - ignored
mrview: WARNING: invalid key "command_history in generic image header “./dwi_denoised.mif” - ignored
mrview: WARNING: invalid key "mrtrix_version in generic image header “./dwi_denoised.mif” - ignored

I understand that this issue is currently being resolved and I’m not sure if it relates to the error I receive via dwipreproc.

I’m also aware of this issue with mrview however I’ve been using the same version of MRtrix3 throughout and NIfTI files open without such errors, so not sure how this file corruption was introduced.

To my knowledge, our computers have had a system update recently, however this was a few weeks ago where our IT team confirmed that MRtrix3 was up to date. I will check this with them again tomorrow.

For reference, please find the content check of the mif image:

$ head dwi_denoised.mif
mrtrix image
dim: 100,100,55,67
vox: 2.3,2.3,2.3,nan
layout: -1,-2,+3,+0
datatype: Float32LE
transform: 0.9997041757060217, -0.01797351600319981, -0.01638639064671639, -107.1678526805917
transform: 0.01282302615547002, 0.9619745064493196, -0.272838081912706, -88.60715532724285
transform: 0.02066714968640003, 0.2725472466638971, 0.9619204058859386, -80.40929179312866
EchoTime: 0.078
PhaseEncodingDirection: j-

Your advice on these matters is appreciated!
Ishani

Image Exception : #3 :: Attempted to add images/ROIs of different sizes

I’ve already had this issue reported to me, but have not yet fixed it as I was putting my efforts into a more general solution for dwipreproc issues that would have usurped this error. The issue relates to the warning message reported earlier in the output:

dwipreproc: [WARNING] Topup images contain at least one non-even dimension; cropping images for topup compatibility

If the input image to topup contains a spatial axis where the size of the image is an odd number, topup will crash. dwipreproc averts this by automatically cropping the image provided via the -se_epi option if necessary. In the past when I first implemented this solution, this was adequate; however it appears that in newer versions of eddy, the result from topup is somehow concatenated with the DWIs input to eddy, and this therefore causes eddy to crash if these images do not have the same size.

While I’m still working on a better dwipreproc solution for topup - eddy alignment / compatibility, the quick fix for this specific error is to crop / pad both your DWIs and your SE-EPI images so that the three spatial axes have sizes that are even numbers.

mrview: WARNING: invalid key "EchoTime" in generic image header “./dwi_denoised.mif” - ignored

I can’t even find where in the code this could be being generated from… Can you make sure that you’re running the version of mrview that you think you are?

I would expect that this has nothing to do with dwidenoise specifically. Do the warnings only appear when running mrview? They certainly look like well-formed key-value pairs in what you’ve pasted, but maybe there’s a hidden erroneous character…?

It’s also just telling you that mrview is ignoring those fields; that’s not really going to stop you from visualising your images, or from doing any other kind of processing on that image (unless you try to run something that relies on being able to read those fields, and that command is also unable to read these items properly).

Thanks very much for taking the time to answer my queries!

While I’m still working on a better dwipreproc solution for topup - eddy alignment / compatibility, the quick fix for this specific error is to crop / pad both your DWIs and your SE-EPI images so that the three spatial axes have sizes that are even numbers.

I used mrcrop to do this and I can confirm dwipreproc runs without error. I also cropped my dwi_denoised.mif file in this way.

I can’t even find where in the code this could be being generated from… Can you make sure that you’re running the version of mrview that you think you are?

I would expect that this has nothing to do with dwidenoise specifically. Do the warnings only appear when running mrview? They certainly look like well-formed key-value pairs in what you’ve pasted, but maybe there’s a hidden erroneous character…?

It’s also just telling you that mrview is ignoring those fields; that’s not really going to stop you from visualising your images, or from doing any other kind of processing on that image (unless you try to run something that relies on being able to read those fields, and that command is also unable to read these items properly).

I’ve since heard back from our IT team and they’ve confirmed that mrview is not compatible on our cluster (even though mrview opens, it gives the aforementioned warnings). I’ve installed MRtrix3 for windows and can open mrview and all mif/nii files without error.

Thanks again!

I was wondering if more recent versions of mrtrix solved this issue? Our group was running into some similar errors on our university’s cluster. Now trying to troubleshoot it, I was unsure whether to get our IT group to install more recent mrtrix versions (I believe we have 3.0_rc2 installed), or to try and pad the image to get around things, etc.? Any thoughts or updated are deeply appreciated!

Welcome Jamie!

There’s a relevant line in the 3.0_RC3 changelog:

Odd axis sizes : When input images have an odd size along a spatial axis, pad rather than truncating images (to achieve topup compatibility), and remove the padding afterwards. This gives the output image series the same dimensions as the input.

Cheers
Rob