# Dwiintensitynorm error!

**URL:** <https://community.mrtrix.org/t/dwiintensitynorm-error/681>\
**Category:** Uncategorized\
**Created:** [January 29, 2017, 9:27pm UTC](https://community.mrtrix.org/t/dwiintensitynorm-error/681 "2017-01-29T21:27:16Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![rehappydoc](https://community.mrtrix.org/user_avatar/community.mrtrix.org/rehappydoc/32/426_2.png) [@rehappydoc](https://community.mrtrix.org/u/rehappydoc)\
**Post date:** [January 29, 2017, 9:27pm UTC](https://community.mrtrix.org/t/dwiintensitynorm-error/681/1 "2017-01-29T21:27:17Z")

</div>

Dear MRtrix3 master.

Due to many experts’ help, now I can make my own script although it is incomplete. however, now I can not help asking you one help again.

I have been trying group intensity normalization with “dwiintesitynorm command”.  
there are six files in both dwi\_folder and mask\_folder. You can see them in the attached files.

 ![](https://community.mrtrix.org/uploads/default/original/1X/d267a52f16c9f71d97c5fa6df007e1b2892a279b.png) ![](https://community.mrtrix.org/uploads/default/original/1X/82e1ebe8ca2fe07b0980a59431f425d1a937307b.png)

I type the command " $ dwiintensitynorm -nthreads 4 dwi\_dir mask\_dir output\_dir fa\_templete wm\_mask"

But until now, I can see the Error message.  
dwiintensitynorm: performing global intensity normalisation on 7 input images  
dwiintensitynorm: [ERROR] the number of images in the mask directory does not equal the number of images in the input directory  
my computer insists that there are 7 files in the “dwi\_dir folder”

 ![](https://community.mrtrix.org/uploads/default/original/1X/2abcedecdbefe566fbeb4daada18858c5b16f855.png)

so I had removed one dwi\_file to match the number of files between both folders as the computer’s insist. but the error message changed to this

 ![](https://community.mrtrix.org/uploads/default/original/1X/956f4faa5d4580bf7f01591318cc09b9caf33507.png)

What did make this problem? What do I have to do in this situation? Why my computer recognize 7 files in dwi\_dir folder?

Best,

Rehappydoc

---

<div class="post-metadata">

**Author:** ![Dave](https://community.mrtrix.org/user_avatar/community.mrtrix.org/dave/32/7_2.png) [@Dave](https://community.mrtrix.org/u/Dave)\
**Post date:** [January 30, 2017, 1:36am UTC](https://community.mrtrix.org/t/dwiintensitynorm-error/681/2 "2017-01-30T01:36:35Z")

</div>

Hi,  
That’s a weird one. The only thing I can think of is maybe you have a hidden file inside the dwi folder? It’s also odd that the file browser is reporting ‘zero bytes’.

You could try to put a print statement in the script [immediately after it lists the files in the dwi directory](https://github.com/MRtrix3/mrtrix3/blob/master/scripts/dwiintensitynorm#L42) and work out why it thinks you have 7 files when there is 6.

Hope that helps,  
Dave

---

<div class="post-metadata">

**Author:** ![jdtournier](https://community.mrtrix.org/user_avatar/community.mrtrix.org/jdtournier/32/2594_2.png) [@jdtournier](https://community.mrtrix.org/u/jdtournier)\
**Post date:** [January 30, 2017, 9:24am UTC](https://community.mrtrix.org/t/dwiintensitynorm-error/681/3 "2017-01-30T09:24:12Z")

</div>

I notice this is on a backup drive? Presumably an external NTFS formatted drive? It might have something to do with this, MacOSX (which I presume is what you’re running this on) has a habit of adding hidden `__MACOSX` folders when manipulating ZIP archives (see e.g. [this article on the topic](http://gotoes.org/sales/Zip_Mac_Files_For_PC/What_Is__MACOSX.php)). It could be that this is what happened?

---

<div class="post-metadata">

**Author:** ![rehappydoc](https://community.mrtrix.org/user_avatar/community.mrtrix.org/rehappydoc/32/426_2.png) [@rehappydoc](https://community.mrtrix.org/u/rehappydoc)\
**Post date:** [February 1, 2017, 5:15pm UTC](https://community.mrtrix.org/t/dwiintensitynorm-error/681/4 "2017-02-01T17:15:22Z")

</div>

Dear Master!

Your comments were right! There was a hidden file in the dwi\_folder.  
so in a terminal window, I typed ls -all. After removing a hidden file, I can run group normalization. However, it takes a lot of time.

Thank you so much!

Best,

Rehappydoc

---

<div class="post-metadata">

**Author:** ![anege](https://community.mrtrix.org/letter_avatar_proxy/v4/letter/a/bbe5ce/32.png) [@anege](https://community.mrtrix.org/u/anege)\
**Post date:** [April 4, 2019, 10:18am UTC](https://community.mrtrix.org/t/dwiintensitynorm-error/681/5 "2019-04-04T10:18:19Z")

</div>

Dear Mrtrix experts,  
I get [ERROR] ‘no matching mask image was found for input image cDWI\_461743.mif’ when running `dwiintensitynorm`.

Ls in the **brainmask** folder looks as follows (includes nodif\_brain\_mask\_fillh\_461743.nii)

```auto
$ ls
nodif_brain_mask_fillh_102109.nii nodif_brain_mask_fillh_125222.nii nodif_brain_mask_fillh_146836.nii nodif_brain_mask_fillh_200513.nii nodif_brain_mask_fillh_299760.nii nodif_brain_mask_fillh_561949.nii
nodif_brain_mask_fillh_102614.nii nodif_brain_mask_fillh_127832.nii nodif_brain_mask_fillh_152225.nii nodif_brain_mask_fillh_206323.nii nodif_brain_mask_fillh_314225.nii nodif_brain_mask_fillh_567759.nii
nodif_brain_mask_fillh_102715.nii nodif_brain_mask_fillh_130114.nii nodif_brain_mask_fillh_152427.nii nodif_brain_mask_fillh_206727.nii nodif_brain_mask_fillh_342129.nii nodif_brain_mask_fillh_635245.nii
nodif_brain_mask_fillh_111211.nii nodif_brain_mask_fillh_134627.nii nodif_brain_mask_fillh_153126.nii nodif_brain_mask_fillh_206828.nii nodif_brain_mask_fillh_392447.nii nodif_brain_mask_fillh_675661.nii
nodif_brain_mask_fillh_115724.nii nodif_brain_mask_fillh_135124.nii nodif_brain_mask_fillh_165941.nii nodif_brain_mask_fillh_213017.nii nodif_brain_mask_fillh_401422.nii nodif_brain_mask_fillh_680452.nii
nodif_brain_mask_fillh_117021.nii nodif_brain_mask_fillh_136631.nii nodif_brain_mask_fillh_167440.nii nodif_brain_mask_fillh_213522.nii nodif_brain_mask_fillh_461743.nii nodif_brain_mask_fillh_694362.nii
nodif_brain_mask_fillh_118831.nii nodif_brain_mask_fillh_138332.nii nodif_brain_mask_fillh_169545.nii nodif_brain_mask_fillh_248238.nii nodif_brain_mask_fillh_468050.nii nodif_brain_mask_fillh_757764.nii
nodif_brain_mask_fillh_119025.nii nodif_brain_mask_fillh_143830.nii nodif_brain_mask_fillh_180230.nii nodif_brain_mask_fillh_257946.nii nodif_brain_mask_fillh_510225.nii nodif_brain_mask_fillh_814548.nii
nodif_brain_mask_fillh_120010.nii nodif_brain_mask_fillh_144933.nii nodif_brain_mask_fillh_191235.nii nodif_brain_mask_fillh_274542.nii nodif_brain_mask_fillh_518746.nii nodif_brain_mask_fillh_818455.nii
nodif_brain_mask_fillh_122418.nii nodif_brain_mask_fillh_145632.nii nodif_brain_mask_fillh_192237.nii nodif_brain_mask_fillh_281135.nii nodif_brain_mask_fillh_531940.nii nodif_brain_mask_fillh_908860.nii

```

Ls in the **input dwi** folder looks as follows

```auto
$ ls
cDWI_102109.mif cDWI_115724.mif cDWI_120010.mif cDWI_130114.mif cDWI_138332.mif cDWI_146836.mif cDWI_165941.mif cDWI_191235.mif cDWI_206727.mif cDWI_248238.mif cDWI_299760.mif cDWI_401422.mif cDWI_518746.mif cDWI_635245.mif cDWI_757764.mif
cDWI_102614.mif cDWI_117021.mif cDWI_122418.mif cDWI_134627.mif cDWI_143830.mif cDWI_152225.mif cDWI_167440.mif cDWI_192237.mif cDWI_206828.mif cDWI_257946.mif cDWI_314225.mif cDWI_461743.mif cDWI_531940.mif cDWI_675661.mif cDWI_814548.mif
cDWI_102715.mif cDWI_118831.mif cDWI_125222.mif cDWI_135124.mif cDWI_144933.mif cDWI_152427.mif cDWI_169545.mif cDWI_200513.mif cDWI_213017.mif cDWI_274542.mif cDWI_342129.mif cDWI_468050.mif cDWI_561949.mif cDWI_680452.mif cDWI_818455.mif
cDWI_111211.mif cDWI_119025.mif cDWI_127832.mif cDWI_136631.mif cDWI_145632.mif cDWI_153126.mif cDWI_180230.mif cDWI_206323.mif cDWI_213522.mif cDWI_281135.mif cDWI_392447.mif cDWI_510225.mif cDWI_567759.mif cDWI_694362.mif cDWI_908860.mif

```

Could this also be due to hidden files?  
Ls -all in the **brainmask** folder looks as follows

```auto
$ ls -all
total 3769
drwxrwxr-x 2 fdez fdez 60 Apr 4 11:38 .
drwxrwxr-x 119 fdez fdez 117 Apr 3 22:37 ..
-rw-r--r-- 1 fdez fdez 68211 Apr 4 11:17 nodif_brain_mask_fillh_102109.nii
etc

```

Am I missing something?

Thank you!

---

<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:** [April 6, 2019, 4:53pm UTC](https://community.mrtrix.org/t/dwiintensitynorm-error/681/6 "2019-04-06T16:53:09Z")

</div>

Hi @anege,

I believe the error message is slightly misleading, and the script is in fact unable to find the corresponding mask file for _any_ of the input files; it’s just printing the error for the file that it happens to look for first.

The `dwiintensitynorm` help page states (emphasis mine):  
`Input directory containing brain masks, corresponding to one per input image (` **`with the same file name prefix`** `)`

I would suggest that the current code within `dwiintensitynorm` is able to determine the correspondence between input and mask images _only_ when the unique identifier for each subject appears at the _start_ of the filename. Obviously this could be improved by implementing improved logic within the source code for determining that correspondence, but this script has generally fallen out of use in favour of `mtnormalise`.

Rob

---

<div class="post-metadata">

**Author:** ![anege](https://community.mrtrix.org/letter_avatar_proxy/v4/letter/a/bbe5ce/32.png) [@anege](https://community.mrtrix.org/u/anege)\
**Post date:** [April 8, 2019, 7:45am UTC](https://community.mrtrix.org/t/dwiintensitynorm-error/681/7 "2019-04-08T07:45:47Z")

</div>

Got it! Thank you!
