Dwiintensitynorm error!

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.

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”

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

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



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 and work out why it thinks you have 7 files when there is 6.

Hope that helps,

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). It could be that this is what happened?

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!



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)

$ 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

$ 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

$ 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

Am I missing something?

Thank you!

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.


Got it! Thank you!