[SOLVED] Dwiintensitynorm: [ERROR] error opening image "-"

Hi everyone,

I’m working with some HCP data and am trying to use the global intensity normalisation function on 20 participants.
I’m using a high performance cluster at my university where hard disk space is allocated, so I’ve set a temporary folder in my partition (where there is several hundred GB available).

This is the command/error output:

[myuser@cluster Scripts]$ dwiintensitynorm /scratch/users/myuser/Workflow/GlobalIntensity/DWI /scratch/users/myuser/Workflow/GlobalIntensity/BrainMasks /scratch/users/myuser/Workflow/Normalised_DWI /scratch/users/myuser/Workflow/Noramlised_DWI/FA_template.mif /scratch/users/myuser/Workflow/Normalised_DWI/WM_mask.mif -force -tempdir /scratch/users/myuser/Workflow/tmp
dwiintensitynorm: performing global intensity normalisation on 20 input images
dwiintensitynorm: [WARNING] Output directory Normalised_DWI already exists; will be overwritten at script completion
dwiintensitynorm: Generated temporary directory: /scratch/users/myuser/Workflow/tmp/dwiintensitynorm-tmp-FVL1U0/
Command: cp -r -L ../Workflow/GlobalIntensity/BrainMasks /scratch/users/myuser/Workflow/tmp/dwiintensitynorm-tmp-FVL1U0/BrainMasks
dwiintensitynorm: Changing to temporary directory (/scratch/users/myuser/Workflow/tmp/dwiintensitynorm-tmp-FVL1U0/)
dwiintensitynorm: Computing FA images
Command: dwi2tensor /scratch/users/myuser/Workflow/GlobalIntensity/DWI/103111_DWI.mif -mask /scratch/users/myuser/Workflow/GlobalIntensity/BrainMasks/103111_nodif_brain_mask.mif - | tensor2metric - -fa fa/103111.mif
dwiintensitynorm:
dwiintensitynorm: [ERROR] Command failed: dwi2tensor /scratch/users/myuser/Workflow/GlobalIntensity/DWI/103111_DWI.mif -mask /scratch/users/myuser/Workflow/GlobalIntensity/BrainMasks/103111_nodif_brain_mask.mif - | tensor2metric - -fa fa/103111.mif
dwiintensitynorm: Output of failed command:
tensor2metric: [ERROR] no filename supplied to standard input (broken pipe?)
tensor2metric: [ERROR] error opening image "-"
dwiintensitynorm: Changing back to original directory (/scratch/users/myuser/Scripts)
dwiintensitynorm: Script failed while executing the command: dwi2tensor /scratch/users/myuser/Workflow/GlobalIntensity/DWI/103111_DWI.mif -mask /scratch/users/myuser/Workflow/GlobalIntensity/BrainMasks/103111_nodif_brain_mask.mif - | tensor2metric - -fa fa/103111.mif
dwiintensitynorm: For debugging, inspect contents of temporary directory: /scratch/users/myuser/Workflow/tmp/dwiintensitynorm-tmp-FVL1U0/

Have I just put the variables in the function the wrong way around? I’m not sure why I’m getting the [ERROR] error opening image "-" message.

I tried running this command to see if it was a problem with the DWI or the brain mask image for that subject and I’m pretty sure it worked:
dwi2tensor 103111_DWI.mif -mask /ibscratch/users/uqjmcfad/Workflow/GlobalIntensity/BrainMasks/103111_nodif_brain_mask.mif testDT.mif
mrinfo testDT.mif
************************************************
Image: “testDT.mif”
************************************************
Dimensions: 145 x 174 x 145 x 6
Voxel size: 1.25 x 1.25 x 1.25 x 1
Data strides: [ -1 2 3 4 ]
Format: MRtrix
Data type: 32 bit float (little endian)
Intensity scaling: offset = 0, multiplier = 1
Transform: 1 0 0 -90
-0 1 0 -126
-0 0 1 -72
comments: FSL5.0
dw_scheme: [ 288 entries ]
mrtrix_version: 0.3.15-294-ge8a525c6-dirty

Any help much appreciated!

Cheers,

Jess

Any help much appreciated!

Cheers,

Jess

Try to update your mrtrix install, they normally fixed this kind of issue with arguments processing. At least thes is how i fixed my issue which was similar.

Hi Jess,
The error you are getting is because tensor2metric is used in a pipe. The ‘-’ character is telling tensor2metric to expect a file name of a temporary file (supplied via stdin), however it does not get one.

This is because something has gone wrong with the dwi2tensor command that feeds the tensor image to tensor2metric. If you change directory in your tempdir (/scratch/users/myuser/Workflow/tmp/dwiintensitynorm-tmp-FVL1U0/), then run the entire command it may give you an idea what is going wrong (dwi2tensor /scratch/users/myuser/Workflow/GlobalIntensity/DWI/103111_DWI.mif -mask /scratch/users/myuser/Workflow/GlobalIntensity/BrainMasks/103111_nodif_brain_mask.mif - | tensor2metric - -fa fa/103111.mif)

My guess is that it’s to do with the piping storing the temporary image. By default MRtrix stores this in /tmp. However maybe this directory is full on your machine, and so dwi2tensor fails since it can’t write the temporary file to pass into tensor2metric. Unfortunately due to the way the commands are run in a python script, you only see the error message from the last command run in the pipe.

You can change where MRtrix stores the temporary files during piping by defining this in the MRtrix configuration file (either in ~/.mrtrix.conf or /etc/mrtrix.conf). Add this line: TmpFileDir: /path/to/temp/location
Cheers,
Dave

Hi Dave,

Thanks for the feedback. I’ve contacted the IT department for a hand but have also tried locally installing MRtrix on the scratch server. It worked but unfortunately I can’t seem to find the mrtrix.conf file in either my home directory or the /etc/ directory. I also couldn’t find it in the folder where MRtrix was set up for the whole cluster.

Is there a way I can find where this file is located?

Cheers,

Jess

Hi Jess,
It’s not created during the install. You have to create the file yourself. You could use something like:
echo "TmpFileDir: /path/to/temp/location" > ~/.mrtrix.conf

And replace the path with a local folder you have access to, and has plenty of space.
Cheers,
Dave

1 Like

Hi Dave,

Oh right! I hadn’t realised. Perfect, it’s all working now. Thank you so much!

Cheers,

Jess