‘dwi2response dhollander’ script meet error

Dear developers,
when I’m using this command

dwi2response dhollander ants_up.mif wm.txt gm.txt csf.txt -mask mask_up.mif

and then I met this error:

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 temporary directory: /Users/ziqianwanglive.cn/Documents/S5/2_nifti/dwi2response-tmp-TWS5M7/

Command: mrconvert /Users/ziqianwanglive.cn/Documents/S5/2_nifti/ants_up.mif /Users/ziqianwanglive.cn/Documents/S5/2_nifti/dwi2response-tmp-TWS5M7/dwi.mif -strides 0,0,0,1

dwi2response: Changing to temporary directory (/Users/ziqianwanglive.cn/Documents/S5/2_nifti/dwi2response-tmp-TWS5M7/)

Command: dwi2mask dwi.mif mask.mif

dwi2response: 2 unique b-value(s) detected: 0,1000 with 1,40 volumes.

Command: maskfilter mask.mif erode eroded_mask.mif -npass 3

Command: dwiextract dwi.mif -shells 0 - | mrmath - mean mean_b0.mif -axis 3

Command: mrcalc mean_b0.mif -finite mean_b0.mif 0 -if 0 -le err_b0.mif -datatype bit

Command: dwiextract dwi.mif -shells 1000 - | mrmath - mean mean_b1000.mif -axis 3

Command: mrcalc mean_b1000.mif -finite mean_b1000.mif 0 -if 0 -le err_b1000.mif -datatype bit

Command: mrcalc mean_b0.mif mean_b1000.mif -divide -log sdm_b1000.mif

Command: mrcalc sdm_b1000.mif 40 -mult 40 -divide full_sdm.mif

Command: mrcalc full_sdm.mif -finite full_sdm.mif 0 -if 0 -le err_sdm.mif -datatype bit

Command: mrcalc err_b0.mif err_b1000.mif -add err_sdm.mif -add 0 eroded_mask.mif -if safe_mask.mif -datatype bit

Command: mrcalc safe_mask.mif full_sdm.mif 0 -if 10 -min safe_sdm.mif

Command: dwi2tensor dwi.mif - -mask safe_mask.mif | tensor2metric - -fa safe_fa.mif -vector safe_vecs.mif -modulate none -mask safe_mask.mif

Command: mrcalc safe_mask.mif safe_fa.mif 0 -if 0.2 -gt crude_wm.mif -datatype bit

Command: mrcalc crude_wm.mif 0 safe_mask.mif -if _crudenonwm.mif -datatype bit

Command: mrcalc _crudenonwm.mif safe_sdm.mif 2.66076 -subtract 0 -if - | mrthreshold - - -mask _crudenonwm.mif | mrcalc _crudenonwm.mif - 0 -if crude_csf.mif -datatype bit

Command: mrcalc crude_csf.mif 0 _crudenonwm.mif -if crude_gm.mif -datatype bit

Command: mrcalc crude_wm.mif safe_sdm.mif 0 -if 3.33132 -gt _crudewmhigh.mif -datatype bit

Command: mrcalc _crudewmhigh.mif 0 crude_wm.mif -if _crudewmlow.mif -datatype bit

Command: mrcalc crude_wm.mif safe_sdm.mif 0 -if 4.75134 -gt _crudewmoutliers.mif -datatype bit

Command: mrcalc _crudewmoutliers.mif 0 crude_wm.mif -if refined_wm.mif -datatype bit

Command: mrcalc crude_gm.mif safe_sdm.mif 0 -if 2.35888 -gt _crudegmhigh.mif -datatype bit

Command: mrcalc _crudegmhigh.mif 0 crude_gm.mif -if _crudegmlow.mif -datatype bit

Command: mrcalc _crudegmhigh.mif safe_sdm.mif 2.35888 -subtract 0 -if - | mrthreshold - - -mask _crudegmhigh.mif -invert | mrcalc _crudegmhigh.mif - 0 -if _crudegmhighselect.mif -datatype bit

Command: mrcalc _crudegmlow.mif safe_sdm.mif 2.35888 -subtract -neg 0 -if - | mrthreshold - - -mask _crudegmlow.mif -invert | mrcalc _crudegmlow.mif - 0 -if _crudegmlowselect.mif -datatype bit

Command: mrcalc _crudegmhighselect.mif 1 _crudegmlowselect.mif -if refined_gm.mif -datatype bit

Command: mrcalc _crudewmoutliers.mif safe_sdm.mif 0 -if 2.58357 -gt 1 crude_csf.mif -if _crudecsfextra.mif -datatype bit

Command: mrcalc _crudecsfextra.mif safe_sdm.mif 2.58357 -subtract 0 -if - | mrthreshold - - -mask _crudecsfextra.mif | mrcalc _crudecsfextra.mif - 0 -if refined_csf.mif -datatype bit

dwi2response: Running ‘tournier’ algorithm to select 2848 single-fibre WM voxels.

Command: dwi2response tournier dwi.mif _respsfwmss.txt -sf_voxels 2848 -iter_voxels 28480 -mask refined_wm.mif -voxels voxels_sfwm.mif -tempdir /Users/ziqianwanglive.cn/Documents/S5/2_nifti/dwi2response-tmp-TWS5M7/

**stats: [ERROR] Cannot output statistic of interest; no values read (empty mask?)

Traceback (most recent call last):

File “/Users/ziqianwanglive.cn/mrtrix3/bin/dwi2response”, line 107, in <module>

alg.execute()

File “/mrtrix3/lib/mrtrix3/dwi2response/dhollander.py”, line 141, in execute

refgmmedian = image.statistic(‘safe_sdm.mif’, ‘median’, ‘-mask refined_gm.mif’)

File “/mrtrix3/lib/mrtrix3/image.py”, line 200, in statistic

app.error(‘Error trying to calculate statistic '’ + statistic + ‘' from image '’ + image_path + ‘'’)

TypeError: must be str, not function

the information of the DWI is :slightly_smiling_face:

Dimensions: 200 x 200 x 96 x 41
Voxel size: 1.25 x 1.25 x 1.25 x 1
Data strides: [ -2 -3 4 1 ]
Format: MRtrix
Data type: 32 bit float (little endian)
Intensity scaling: offset = 0, multiplier = 1
Transform: 0.9948 -0.09246 0.04277 -118.1
0.09921 0.9747 -0.2005 -133.7
-0.02315 0.2037 0.9788 -116.9
command_history: /home/bwgig/mrtrix3/bin/mrconvert “dwi_post_eddy.nii.gz” “result.mif” “-strides” “-2,-3,4,1” “-fslgrad” “dwi_post_eddy.eddy_rotated_bvecs” “bvals” (version=3.0_RC3-96-g2c350fa9)
[6 entries] /home/bwgig/mrtrix3/bin/mrconvert “result.mif” “/media/bwgig/S5/2_nifti/prep.mif” (version=3.0_RC3-96-g2c350fa9)

/home/bwgig/mrtrix3/bin/mrconvert “result.mif” “/media/bwgig/S5/2_nifti/ants.mif” (version=3.0_RC3-96-g2c350fa9)
mrresize “S5/2_nifti/ants.mif” “-vox” “1.25” “S5/2_nifti/ants_up.mif” (version=3.0_RC3-96-g2c350fa9)
comments:
dw_scheme: 0,0,0,0
[41 entries] -0.9998051238,0.009154279131,0.01749038477,1000

-0.1016412304,0.2822529404,0.9539404268,1000
-0.02276882304,0.811373184,0.5840848714,1000
mrtrix_version: 3.0_RC3-96-g2c350fa9

And I also check the refined_wm.mif is not empty.
I hope I posted enough information. Please feel free to touch me if you need to know more.
Any thoughts would be helpful.

Best regards,
Ziqian Wang

Here is the image for refined_wm.mif…

Hi Ziqian,

Note that the problem is probably an empty refined_gm.mif (i.e. not WM). Can you check whether that one is empty? It almost certainly will be, and I can actually tell via the refined_wm image you posted: that clearly captures too much. I can see 2 explanations, a simpler one and a more complicated one. Let’s check the simple one: this would probably mean that the right FA threshold wasn’t applied at the very start of the algorithm. By default the threshold to roughly separate WM and GM+CSF initially is set at 0.2. It appears the FA in a lot of the GM might be above that (that is, if my simple explanation will be the right one…). Can you post an image of safe_fa.mif in the temporary folder? Make sure you clearly show the colour scale bar in the screenshot, so we can see whether my simple theory holds here…

Is there anything else strange about your data? I note a not-so-high b-value (no problem though), yet quite a (very) high spatial resolution. Is this acquisition special / unique in any particular way?

Cheers,
Thijs

Hi Thijs,
appreciate your help. We found the problem comes from the very beginning by converting the raw DICOM to mif data. so I didn’t do it by myself, I can’t tell you the specific reason of this problem.
We now converted again and it works fine.
Thank you again for your help.

Best regards,
Ziqian Wang

1 Like

Good to hear! Just for future reference: this probably makes good sense, as anything that imports your data wrongly (e.g. the gradient table, or ordering of volumes, etc…) is almost certainly going to make the data so “randomly” behaved, that the FA is going to take on very large, and even non-physical values. So in line with my explanation above, I reckon the FA map would’ve shown unusually high values all over the place, naturally resulting in that error at that particular stage. In the future, I may build in a few extra warnings or errors at some of these stages where masks can end up being empty; so users have a better idea as to what might be going wrong. But in any normal case, they shouldn’t go wrong to begin with. :slight_smile:

Thank you for mention this FA value checking method. It would be very helpful for me to know if the problem comes from the very beginning.

1 Like