# Errors with dwidenoise and dwipreproc

**URL:** <https://community.mrtrix.org/t/errors-with-dwidenoise-and-dwipreproc/1174>\
**Category:** Uncategorized\
**Created:** [September 16, 2017, 10:09pm UTC](https://community.mrtrix.org/t/errors-with-dwidenoise-and-dwipreproc/1174 "2017-09-16T22:09:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![isahama](https://community.mrtrix.org/letter_avatar_proxy/v4/letter/i/a587f6/32.png) [@isahama](https://community.mrtrix.org/u/isahama)\
**Post date:** [September 16, 2017, 10:09pm UTC](https://community.mrtrix.org/t/errors-with-dwidenoise-and-dwipreproc/1174/1 "2017-09-16T22:09:04Z")

</div>

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](https://github.com/MRtrix3/mrtrix3/issues/1084) 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](http://community.mrtrix.org/t/error-message/175/7) 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

---

<div class="post-metadata">

**Author:** ![rsmith](https://community.mrtrix.org/user_avatar/community.mrtrix.org/rsmith/32/2672_2.png) [@rsmith](https://community.mrtrix.org/u/rsmith)\
**Post date:** [September 18, 2017, 1:24am UTC](https://community.mrtrix.org/t/errors-with-dwidenoise-and-dwipreproc/1174/2 "2017-09-18T01:24:44Z")

</div>

> `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](https://github.com/MRtrix3/mrtrix3/issues/874) working [on](https://github.com/MRtrix3/mrtrix3/pull/1051) a [better](https://github.com/MRtrix3/mrtrix3/issues/1084) `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).

---

<div class="post-metadata">

**Author:** ![isahama](https://community.mrtrix.org/letter_avatar_proxy/v4/letter/i/a587f6/32.png) [@isahama](https://community.mrtrix.org/u/isahama)\
**Post date:** [September 22, 2017, 3:51am UTC](https://community.mrtrix.org/t/errors-with-dwidenoise-and-dwipreproc/1174/3 "2017-09-22T03:51:25Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![jlhanson5](https://community.mrtrix.org/letter_avatar_proxy/v4/letter/j/ac8455/32.png) [@jlhanson5](https://community.mrtrix.org/u/jlhanson5)\
**Post date:** [March 29, 2020, 8:31am UTC](https://community.mrtrix.org/t/errors-with-dwidenoise-and-dwipreproc/1174/4 "2020-03-29T08:31:27Z")

</div>

> [@rsmith](#):
>
> 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:

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!

 ![Untitled](https://community.mrtrix.org/uploads/default/original/2X/2/27342cde00ffb3c1f7738735844086c4b413525f.png)

---

<div class="post-metadata">

**Author:** ![rsmith](https://community.mrtrix.org/user_avatar/community.mrtrix.org/rsmith/32/2672_2.png) [@rsmith](https://community.mrtrix.org/u/rsmith)\
**Post date:** [March 29, 2020, 9:43am UTC](https://community.mrtrix.org/t/errors-with-dwidenoise-and-dwipreproc/1174/5 "2020-03-29T09:43:07Z")

</div>

Welcome Jamie!

There’s a relevant line in the [`3.0_RC3` changelog](https://community.mrtrix.org/t/mrtrix-3-0-release-candidate-3/1624/2):

> [_Odd axis sizes_](https://github.com/MRtrix3/mrtrix3/pull/1159): 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
