Dwinormalise: empty mask in wm_mask_warped folder

Hi everyone,
I’m using dwinormalise for global intensity normalisation across subjects. I got this error:

          dwinormalise: [ERROR] dwiextract /Users/s5110052/Desktop/_analysisDTI/dwinormalise/dwi_input/007_healthy.mif -bzero - | mrmath - mean - -axis 3 | mrstats - -mask /Users/s5110052/Desktop/_analysisDTI/wrist/dwinormalise-tmp-BD1090/wm_mask_warped/007_healthy.mif -output median (individual.py:68)
          dwinormalise: [ERROR] Information from failed command:
                        dwiextract: extracting volumes... [==================================================]
                        mrmath: computing mean along axis 3...... [==================================================]
                        mrstats: [ERROR] Cannot output statistic of interest; no values read (empty mask?)

I went to check the mask for this participant in the dwinormalise/wm_mask_warped folder and it is indeed empty. The original mask provided in dwinormalise/mask_input is fine. Any ideas where it went wrong and how to fix it?
I’m working with single-shell data and using the tutorial for single-tissue (step 5)
Thanks in advance!

Hi Eva,

The mask that is involved in the erroneous command is actually basically unrelated to the input mask for that particular subject:

  • The subject’s input mask is only used to constrain generation of the population template FA image, and is ignored subsequent to that point;

  • There has been a “WM” mask derived in template space based on the template FA image, and that mask has then been warped from the template back to the space of that individual’s input DWI. It is the warped version of this mask that is being reported as empty.

So the first thing to check would be whether or not the template FA image looks reasonable, and the template “WM” mask looks reasonable. If these look wrong, then the actual problem is likely upstream of the error you’re receiving, and you probably need to look closely at your input data to try to figure out why the population_template step that is part of the dwinormalise group script is going awry. Conversely, if these template images look OK, then the problem must be in the warping of that mask back to the space of that individual subject. It would be useful to know whether this appears to be a problem only for one specific subject or whether if performing the steps within the script manually that mask gets warped successfully for all other subjects.

Some of this involves understanding the relevant code and analysing the underlying steps to figure out where the problem first arises. If you’ve navigated around the data within the script scratch directory that was preserved and are still feeling lost, you’ll need to give us access to your data so that we can have a poke and prod around.


1 Like

Hi Rob,
Thanks for getting back to me. The FA template looks reasonable. I would say “less defined” compared to what a single FA would be for one participant but I think this is something to be expected? I think the warping may be the issue. I tried manually to continue with the pipeline. I could but at some point, I got an error:

dwinormalise: [ERROR] Output file ‘temp.mif’ already exists (use -force to override)

In the original script, I don’t see this temp.mif being -force to change so there must be something that I’m doing wrong… Any ideas? Happy to try one more thing before I give up!

Hi Eva,

When the script is proceeding without issue, the sequence is:

  1. dwinormalise generates temp.mif;
  2. mrconvert utilises temp.mif;
  3. temp.mif is deleted.

So under normal circumstances, there’s no need for the use of -force. But if the script has failed during step 1, there’s going to be an empty temp.mif sitting there in the scratch directory. If you then go into the scratch directory and start playing around, any guarantees that were predicated on the script operating normally are off the table. So you may indeed need to manually delete files, or use -force, it’s entirely up to your judgement as you investigate what’s going on.

Given the warping of the template WM mask to subject space is clearly awry, personally what I would be trying is warping the subject FA image to template space, and warping the template FA image to subject space. If something has truly gone wrong with the registration, the outputs produced by those two transformations may provide some insight.