Dwiintensitynorm: ERROR: Generating FA population template

Hello,

I’m trying to run a FBA on 20 Subjects using MRTRIX3. All steps including ‘dwibiascorrect’ worked just fine.

Unfortunately I have problems running the next step ‘dwiintensitynorm’.
I created the necessary folders (dwi_input, dwi-mask) as described in the documentation and this is my script I want to run:

"${mrtrix_bin}/foreach * : ln -sr IN/dwi_ec_denoised_bias.mif ${out_dir}/dwiintensitynorm/dwi_input/IN.mif
${mrtrix_bin}/foreach * : ln -sr IN/dwi_mask.mif ${out_dir}/dwiintensitynorm/mask_input/IN.mif

${mrtrix_bin}/dwiintensitynorm ${out_dir}/dwiintensitynorm/dwi_input/ ${out_dir}/dwiintensitynorm/mask_input/ ${out_dir}/dwiintensitynorm/dwi_output/ ${out_dir}/dwiintensitynorm/fa_template.mif ${out_dir}/dwiintensitynorm/fa_template_wm_mask.mif

${mrtrix_bin}/foreach ${out_dir}/dwiintensitynorm/dwi_output/* : ln -sr IN PRE/dwi_ec_denoised_bias_norm.mif "

The symbolic linking works just fine as well as ‘dwi2tensor’ for each subject.
Subsequently the script crashes and the FA-template and wm_mask is not created.

This is the command line/error output:

dwiintensitynorm: Generating FA population template
Command: population_template fa -mask_dir /tmp/dwiintensitynorm-tmp-0G0P83/mask_input fa_template.mif -linear_scale 0.25,0.5,1.0,1.0 -nl_scale 0.5,0.75,1.0,1.0,1.0 -nl_niter 5,5,5,5,5 -warp_dir warps -nocleanup -tempdir population_template
Traceback (most recent call last):
File “/data/p_nro152/mrtrix3/scripts/dwiintensitynorm”, line 88, in
runCommand(‘population_template fa -mask_dir ’ + maskTempDir + ’ fa_template.mif -linear_scale 0.25,0.5,1.0,1.0 -nl_scale 0.5,0.75,1.0,1.0,1.0 -nl_niter 5,5,5,5,5 -warp_dir warps -nocleanup -tempdir population_template’)
File “/data/p_nro152/mrtrix3/scripts/lib/runCommand.py”, line 103, in runCommand
process = subprocess.Popen(cmdstack[0], stdin=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
File “/usr/lib/python2.7/subprocess.py”, line 711, in init
errread, errwrite)
File “/usr/lib/python2.7/subprocess.py”, line 1343, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
ln: failed to create symbolic link ‘*/dwi_ec_denoised_bias_norm.mif’: No such file or directory

Any help/advice is much appreciated!
Thanks in advance!
Tom

I can’t reproduce that problem but I suspect that dwiintensitynorm fails to create correct symlinks for the masks. Are you using the latest version of MRtrix?

Line 77 in dwiintensitynorm should read
runCommand ('cp -R -L ' + maskDir + ' ' + maskTempDir)

If it does, could you please check whether the folder mask_input in the temporary directory contains mask images, not (broken) symlinks?

I’m using MRtrix version 0.3.15.

Line 77 reads exactly as you stated:
runCommand ('cp -R -L ' + maskDir + ' ' + maskTempDir)

The folder mask_input in tmp contains the real mask images.

is population_template in your path? (you might want to run set_path to make sure it is).

Your code works fine for me. My test:

~/test_dwibiascorrect $ tree
.
|-- data
|   |-- sub1
|   |   |-- dwi_ec_denoised_bias.mif
|   |   `-- dwi_mask.mif
|   `-- sub2
|       |-- dwi_ec_denoised_bias.mif
|       `-- dwi_mask.mif
|-- out
|   `-- dwiintensitynorm
|       |-- dwi_input
|       |   |-- sub1.mif -> ../../../data/sub1/dwi_ec_denoised_bias.mif
|       |   `-- sub2.mif -> ../../../data/sub2/dwi_ec_denoised_bias.mif
|       |-- dwi_output
|       `-- mask_input
|           |-- sub1.mif -> ../../../data/sub1/dwi_mask.mif
|           `-- sub2.mif -> ../../../data/sub2/dwi_mask.mif
`-- test.sh


mrtrix_bin=~/mrtrix3/scripts
out_dir=~/test_dwibiascorrect/out

${mrtrix_bin}/dwiintensitynorm ${out_dir}/dwiintensitynorm/dwi_input/ ${out_dir}/dwiintensitynorm/mask_input/ ${out_dir}/dwiintensitynorm/dwi_output/ ${out_dir}/dwiintensitynorm/fa_template.mif ${out_dir}/dwiintensitynorm/fa_template_wm_mask.mif


dwiintensitynorm: performing global intensity normalisation on 2 input images
dwiintensitynorm: Generated temporary directory: /home/mp14/tmp13/dwiintensitynorm-tmp-FN1HR1/
Command: cp -R -L out/dwiintensitynorm/mask_input /home/mp14/tmp13/dwiintensitynorm-tmp-FN1HR1/mask_input
dwiintensitynorm: Changing to temporary directory (/home/mp14/tmp13/dwiintensitynorm-tmp-FN1HR1/)
dwiintensitynorm: Computing FA images
Command: dwi2tensor /home/mp14/test_dwibiascorrect/out/dwiintensitynorm/dwi_input/sub2.mif -mask /home/mp14/test_dwibiascorrect/out/dwiintensitynorm/mask_input/sub2.mif - | tensor2metric - -fa fa/sub2.mif
Command: dwi2tensor /home/mp14/test_dwibiascorrect/out/dwiintensitynorm/dwi_input/sub1.mif -mask /home/mp14/test_dwibiascorrect/out/dwiintensitynorm/mask_input/sub1.mif - | tensor2metric - -fa fa/sub1.mif
dwiintensitynorm: Generating FA population template
Command: population_template fa -mask_dir /home/mp14/tmp13/dwiintensitynorm-tmp-FN1HR1/mask_input fa_template.mif -linear_scale 0.25,0.5,1.0,1.0 -nl_scale 0.5,0.75,1.0,1.0,1.0 -nl_niter 5,5,5,5,5 -warp_dir warps -nocleanup -tempdir population_template
Command: mrthreshold fa_template.mif -abs 0.4 template_wm_mask.mif
Command: mrtransform template_wm_mask.mif -interp nearest -warp_full warps/sub2.mif wm_mask_warped/sub2.mif -from 2 -template fa/sub2.mif
Command: dwinormalise /home/mp14/test_dwibiascorrect/out/dwiintensitynorm/dwi_input/sub2.mif wm_mask_warped/sub2.mif /home/mp14/test_dwibiascorrect/out/dwiintensitynorm/dwi_output/sub2.mif
Command: mrtransform template_wm_mask.mif -interp nearest -warp_full warps/sub1.mif wm_mask_warped/sub1.mif -from 2 -template fa/sub1.mif
Command: dwinormalise /home/mp14/test_dwibiascorrect/out/dwiintensitynorm/dwi_input/sub1.mif wm_mask_warped/sub1.mif /home/mp14/test_dwibiascorrect/out/dwiintensitynorm/dwi_output/sub1.mif
Command: mrconvert template_wm_mask.mif /home/mp14/test_dwibiascorrect/out/dwiintensitynorm/fa_template_wm_mask.mif
Command: mrconvert fa_template.mif /home/mp14/test_dwibiascorrect/out/dwiintensitynorm/fa_template.mif
dwiintensitynorm: Changing back to original directory (/home/mp14/test_dwibiascorrect)
dwiintensitynorm: Deleting temporary directory /home/mp14/tmp13/dwiintensitynorm-tmp-FN1HR1/

Thanks for the hint!

I checked my path and set everything up right (seems like I had a problem during installation…). Now the script is running properly.

Your help is much appreciated!

Glad it worked :slight_smile: