# DWIToDTIEstimation: Error reading Mask file, wrong coordinate space

**URL:** <https://discourse.slicer.org/t/dwitodtiestimation-error-reading-mask-file-wrong-coordinate-space/3847>\
**Category:** Support\
**Tags:** diffusion\
**Created:** [August 20, 2018, 1:23pm UTC](https://discourse.slicer.org/t/dwitodtiestimation-error-reading-mask-file-wrong-coordinate-space/3847 "2018-08-20T13:23:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Saba\_Shahab](https://avatars.discourse-cdn.com/v4/letter/s/df705f/32.png) [@Saba\_Shahab](https://discourse.slicer.org/u/Saba_Shahab)\
**Post date:** [August 20, 2018, 1:23pm UTC](https://discourse.slicer.org/t/dwitodtiestimation-error-reading-mask-file-wrong-coordinate-space/3847/1 "2018-08-20T13:23:56Z")

</div>

Operating system:  
NAME=“Ubuntu”  
VERSION=“16.04.3 LTS (Xenial Xerus)”  
ID=ubuntu  
ID\_LIKE=debian  
PRETTY\_NAME=“Ubuntu 16.04.3 LTS”  
VERSION\_ID=“16.04”

Slicer version:  
slicer/4.4.0 and slicer/4.8.1 (I got an error using both versions)

Generally, when running the WMA pipeline, I run DTIPrep \> DWIToDTIEstimation \> DiffusionWeightedVolumeMasking \> TractographyLabelMapSeeding. I wanted to create the mask before the tensor estimation step and use the mask to limit the area where the tensor is being calculated. I switched the two steps around and added the mask as an argument in the DWIToDTIEstimation code and got the following error: DWIToDTIEstimation: Error reading Mask file, wrong coordinate space

I looked for a solution online and found this: [http://massmail.spl.harvard.edu/public-archives/slicer-users/2013/006314.html](http://massmail.spl.harvard.edu/public-archives/slicer-users/2013/006314.html)

As suggested in this link, I ran the estimation once without a mask and then used the baseline volume to regenerate the mask and tried re-running DWIToDTIEstimation with this mask but got the same error.

Please let me know if you need any more information to debug this issue.

Best,  
Saba Shahab

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [August 20, 2018, 2:08pm UTC](https://discourse.slicer.org/t/dwitodtiestimation-error-reading-mask-file-wrong-coordinate-space/3847/2 "2018-08-20T14:08:50Z")

</div>

Could you please try if latest Slicer nightly version works well?

---

<div class="post-metadata">

**Author:** ![Saba\_Shahab](https://avatars.discourse-cdn.com/v4/letter/s/df705f/32.png) [@Saba\_Shahab](https://discourse.slicer.org/u/Saba_Shahab)\
**Post date:** [August 20, 2018, 8:01pm UTC](https://discourse.slicer.org/t/dwitodtiestimation-error-reading-mask-file-wrong-coordinate-space/3847/3 "2018-08-20T20:01:49Z")

</div>

I used the latest Slicer nightly version (updated as of 2018-08-20) and got this error message:

DWIToDTIEstimation: Error reading Mask file, wrong coordinate space  
vtkDebugLeaks has found no leaks.

Here is the code I am running: [https://github.com/sabashahab/STOPPD\_DTI/blob/master/SlicerTractography\_edit.sh](https://github.com/sabashahab/STOPPD_DTI/blob/master/SlicerTractography_edit.sh)

---

<div class="post-metadata">

**Author:** ![ihnorton](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ihnorton/32/9_2.png) [@ihnorton](https://discourse.slicer.org/u/ihnorton)\
**Post date:** [August 20, 2018, 9:18pm UTC](https://discourse.slicer.org/t/dwitodtiestimation-error-reading-mask-file-wrong-coordinate-space/3847/4 "2018-08-20T21:18:36Z")

</div>

I believe the following is happening:

- The output DWI from DTIPrep is probably in ITK’s native LPS.

- Slicer’s NRRD reader (used by DWVolumeMasking) “reorients” the volume while loading, such that the transformation matrix is relative to Slicer’s native RAS. This is technically an identity operation, but when the mask volume is saved, the resulting transform is different than the input DWI.

- Then DWToDTIEstimation checks that the mask and DWI transforms are equal, but only looks at the transformation matrices, and does not account for the fact that the image is (technically) the same (relative to the embedding NRRD space-directions).

So, in light of that, in the short term I think the quickest solution is to use the [OrientScalarVolume](https://www.slicer.org/wiki/Documentation/4.0/Modules/OrientScalarVolume) module to change the mask image back to the same “space directions” as found in the DTIPrep output.

Assuming the DTIPrep output is indeed LPS (check the NRRD header “space directions” field), then you could try adding a step to your script – something like this:

```auto
OrientImage -o LPS ${outputfolder}/${stem}_MASK.nrrd ${outputfolder}/${stem}_MASK_lps.nrrd

```

(and the input mask file for DWIToDTIEstim step would correspondingly change to  
`$outputfolder/${stem}_MASK_lps.nrrd`)

---

<div class="post-metadata">

**Author:** ![Saba\_Shahab](https://avatars.discourse-cdn.com/v4/letter/s/df705f/32.png) [@Saba\_Shahab](https://discourse.slicer.org/u/Saba_Shahab)\
**Post date:** [August 24, 2018, 1:51pm UTC](https://discourse.slicer.org/t/dwitodtiestimation-error-reading-mask-file-wrong-coordinate-space/3847/5 "2018-08-24T13:51:49Z")

</div>

Hi Isaiah,

Thanks for your response. I tried OrientScalarVolume (OrientImage didn’t show up as a module) and it didn’t fix the problem.

But the following worked:

`ResampleScalarVectorDWIVolume -R ${outputfolder}/${stem}_QCed.nrrd ${outputfolder}/${stem}_MASK.nrrd ${outputfolder}/${stem}_MASK_oriented.nrrd`
