Recently I have updated mrtrix and now dwi2response is not working properly. With the same data, it was working in the previous version. I found similar threads on the forum. But I could not understand how to fix the issue. I appreciate if someone can explain a solution simply.
Thank you.
This is the error I get.
dwi2response tournier dwi.mif response.txt
dwi2response:
dwi2response: Note that this script makes use of commands / algorithms that have relevant articles for citation. Please consult the help page (-help option) for more information.
dwi2response:
dwi2response: Generated scratch directory: /home/connectome/TBI/connectomes/FBA/study/subjects/001_control/dwi2response-tmp-U0GB42/
dwi2response: Importing DWI data (/home/connectome/TBI/connectomes/FBA/study/subjects/001_control/dwi.mif) and selecting b-values...
dwi2response: Changing to scratch directory (/home/connectome/TBI/connectomes/FBA/study/subjects/001_control/dwi2response-tmp-U0GB42/)
dwi2response: Computing brain mask (dwi2mask)...
dwi2response: [. ] Optimising...
dwi2response: [ERROR] fixel2voxel iter0_fixel/peaks.mif none iter0_amps.mif -number 2 (tournier.py:91)
dwi2response: [ERROR] Information from failed command:
dwi2response:
fixel2voxel: [ERROR] failed to open key/value file "iter0_fixel/peaks.mif": No such file or directory
fixel2voxel: [ERROR] error opening image "iter0_fixel/peaks.mif"
dwi2response:
Do you happen to be running on a Windows machine? The first thing that jumps out at me looking at the relevant code is that it’s slightly clumsy with respect to filesystem directory navigation, which can sometimes lead to code that works on Unix but not Windows. Having said that I did just run tests where this command worked for version 3.0.1 on all three OS’s…
The only other thing would be that if you are installing from source, make sure that you have not only downloaded updates to the code, but also re-compiled the MRtrix3 binaries. dwi2response may be a Python script, but it invokes many MRtrix3 binary commands, and there was a specific change involving the fod2fixel command interface (which is invoked by dwi2response tournier just prior to fixel2voxel) that could potentially lead to unexpected behaviour if there’s a mismatch between the Python code and the compiled binaries.
Otherwise, I would need you to re-run the command with the -info flag, and also show the contents of the script’s scratch directory.
I am running Mrtrix on Linux (virtual toolbox). I have checked the dwi2response with different data set which have been acquired on a Hitachi scanner. It is working properly. This problem happens only with Philips data. I am wondering whether it is related to image header. Because I am sure It was working properly with the same data too in the previous version. I just had to update suddenly because fixelcfestats had higher memory consumption in the early version. Anyway now I have reinstalled Mrtrix3 again… considering that update went wrong.
This is what I got with -info flag;
senobold@senobold-VirtualBox:~/connectome/TBI/connectomes/FBA/study/subjects/001_control$ dwi2response tournier dwi.mif response.txt -info
dwi2response:
dwi2response: Note that this script makes use of commands / algorithms that have relevant articles for citation. Please consult the help page (-help option) for more information.
dwi2response:
dwi2response: Loading header for image file '/home/senobold/connectome/TBI/connectomes/FBA/study/subjects/001_control/dwi.mif'
dwi2response: Generated scratch directory: /home/senobold/connectome/TBI/connectomes/FBA/study/subjects/001_control/dwi2response-tmp-7C4TK5/
dwi2response: Importing DWI data (/home/senobold/connectome/TBI/connectomes/FBA/study/subjects/001_control/dwi.mif) and selecting b-values...
Command: mrconvert /home/senobold/connectome/TBI/connectomes/FBA/study/subjects/001_control/dwi.mif - -strides 0,0,0,1 | dwiextract - /home/senobold/connectome/TBI/connectomes/FBA/study/subjects/001_control/dwi2response-tmp-7C4TK5/dwi.mif -singleshell -no_bzero
mrconvert: [ 0%] copying from "/home/seno...ubjects/001_control/dwi.m mrconvert: [100%] copying from "/home/seno...ubjects/001_control/dwi.mif" to "/home/seno...C4TK5/mrtrix-tmp-z7NUQc.mif"
dwiextract: [100%] extracting volumes
dwi2response: Changing to scratch directory (/home/senobold/connectome/TBI/connectomes/FBA/study/subjects/001_control/dwi2response-tmp-7C4TK5/)
dwi2response: Computing brain mask (dwi2mask)...
Command: dwi2mask dwi.mif mask.mif
dwi2mask: [done] computing dwi brain mask
dwi2mask: [done] applying mask cleaning filter
dwi2response: Command: '/home/senobold/git/mrtrix3/bin/mrstats mask.mif -output mean -output median -output std -output std_rv -output min -output max -output count -mask mask.mif' (piping data to local storage)
dwi2response: Result: ImageStatistics(mean=1.0, median=1.0, std=0.0, std_rv=0.0, min=1.0, max=1.0, count=159691)
dwi2response: [. ] Optimising...
Command: dwi2fod csd dwi.mif init_RF.txt iter0_FOD.mif -mask mask.mif
Command: fod2fixel iter0_FOD.mif iter0_fixel -peak peaks.mif -mask mask.mif -fmls_no_thresholds
Command: fixel2voxel iter0_fixel/peaks.mif none iter0_amps.mif -number 2
dwi2response: [ERROR] fixel2voxel iter0_fixel/peaks.mif none iter0_amps.mif -number 2 (tournier.py:91)
dwi2response: [ERROR] Information from failed command:
dwi2response:
fixel2voxel: [ERROR] failed to open key/value file "iter0_fixel/peaks.mif": No such file or directory
fixel2voxel: [ERROR] error opening image "iter0_fixel/peaks.mif"
dwi2response:
dwi2response: [ERROR] For debugging, inspect contents of scratch directory: /home/senobold/connectome/TBI/connectomes/FBA/study/subjects/001_control/dwi2response-tmp-7C4TK5/
senobold@senobold-VirtualBox:~/connectome/TBI/connectomes/FBA/study/subjects/001_control$ mes/FBA/study/subjects/001_control/dwi2response-tmp-7C4TK5/
Thank you for checking this out.
Hope you can suggest things to fix the issue.
I’m not sure what’s going on here, but it seems clear there’s something unusual about the data you’re providing. One possibility might be that your input DWI data includes one of those synthetic isotropic-weighted images that Philips tend to include as the last image in the series (not sure what it’s for). One way to check is to run:
mrinfo -dwgrad dwi.mif
and post the output here. If that’s the issue, I’m expecting to see an entry of the form “0 0 0 1000” (where that last b-value is the actual b-value you used) somewhere in the gradient table (i.e. non-zero b-value with a zero direction vector). In which case you could try removing that volume from your DWI image, using a command like e.g.:
mrconvert dwi.mif -coord 3 0:58 dwi_clean.mif`
where that last number 59 is the index of the last volume you want included (indexed from zero). In the example above, that would remove the last volume assuming you have 60 volumes in the original dwi.mif.
I don’t see evidence there that support’s @jdtournier’s hypothesis of what may have been causing the problem.; so a closer inspection is likely required. Would you be able to provide us with access to an example dataset?
Thanks for sending me some data. It seems that in your copy & pasting of the output of mrinfo -dwgrad, you accidentally left out the most important part. The last five lines of the output actually read:
That final line, with a null vector direction and non-zero b-value, is precisely the trace-weighted image that @jdtournier was referring to. By scraping that final volume from the data using mrconvert -coord 3 0:32 prior to running dwi2response, the script completes without issue.
I have added an issue to GitHub to modify the software, as ideally such data would not lead to such an obscure error but would do something a bit more sensible.
I’m pretty sure the issue is now dealt with at DICOM import. I’m assuming these data were converted using a previous version of MRtrix, or a different package altogether? If not, then we definitely need to find a clean solution for this…
dwi2response dhollander sub_unbiased.mif wm.txt gm.txt csf.txt -mask mask_on_b0.nii.gz -voxels voxels.mif -force
dwi2response:
dwi2response: Note that this script makes use of commands / algorithms that have relevant articles for citation. Please consult the help page (-help option) for more information.
dwi2response:
dwi2response: [ERROR] Script requires diffusion gradient table: either in image header, or using -grad / -fslgrad option
pc@pc-1-0:~test_subject$ mrinfo -dwgrad dwi.nii
mrinfo: [ERROR] no valid diffusion gradient table found
mrinfo: [ERROR] error importing diffusion gradient table for image “dwi.nii”
But I ran the same code earlier, and it worked. Now it’s showing 'NO gradient table.