MRtrix3 / mrtrix3

MRtrix3 provides a set of tools to perform various advanced diffusion MRI analyses, including constrained spherical deconvolution (CSD), probabilistic tractography, track-density imaging, and apparent fibre density
http://www.mrtrix.org
Mozilla Public License 2.0
292 stars 179 forks source link

dwi2response: [ERROR] Error trying to calculate statistics from image 'mask.mif' #2738

Open jaja123j opened 11 months ago

jaja123j commented 11 months ago

I install a mrtrix3 and its version is 3.0.4,but the error comes when I run the following line dwi2response msmt_5tt align.mif 5ttseg.mif ms_5tt_wm.txt ms_5tt_gm.txt ms_5tt_csf.txt \ -voxels ms_5tt_voxels.mif -force

Here is the content of the error.txt:

dwi2response tournier dwi.mif wm_ss_response.txt -mask wm_mask.mif -voxels wm_sf_mask.mif -scratch /media/monica/data_prefreesurfer/3113/unprocessed/3T/Diffusion/dwi2response-tmp-6U3ZXK/

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: /media/monica/data_prefreesurfer/3113/unprocessed/3T/Diffusion/dwi2response-tmp-6U3ZXK/dwi2response-tmp-QJ75F4/
dwi2response: Importing DWI data (/media/monica/data_prefreesurfer/3113/unprocessed/3T/Diffusion/dwi2response-tmp-6U3ZXK/dwi.mif) and selecting b-values...
dwi2response: Importing mask (/media/monica/data_prefreesurfer/3113/unprocessed/3T/Diffusion/dwi2response-tmp-6U3ZXK/wm_mask.mif)...
dwi2response: Changing to scratch directory (/media/monica/data_prefreesurfer/3113/unprocessed/3T/Diffusion/dwi2response-tmp-6U3ZXK/dwi2response-tmp-QJ75F4/)

dwi2response: [ERROR] Error trying to calculate statistics from image 'mask.mif'
Lestropie commented 11 months ago

Hi,

The usage that you initially quote is quite different to what was executed that generated the error.txt that you then quote. The former invokes the msmt_5tt algorithm and does not provide a mask; the latter invokes the tournier algorithm and does provide a mask. So you may have mixed up contents from different scratch directories.

The error message is not as informative as it could be; but it's actually the very code that's trying to produce a more informative error message for you that's producing the uninformative message! :-/ Almost certainly what has happened in the second case is that the mask you have provided, "wm_mask.mif", is completely empty. If you run mrstats wm_mask.mif, you should get both a minimum and maximum of zero.

From a development perspective, we need to either:

  1. Change image.statistics() to yield a valid result, but filled with NaN for statistics and 0 for count, if mrinfo yields a non-zero return code (and ideally also the cause of that non-zero return code is an empty image)
  2. Change mrinfo to write NaN for explicitly requested fields rather than throwing an exception if no values are read
  3. Change any Python code that runs image.statistics to catch a specific exception class, rather than checking for count being equal to zero.

1 makes sense to me I think; it's less intrusive, is consistent with the pretty-print usage of mrstats, and code to check the result is still short.

jaja123j commented 11 months ago

Thanks for replying!I've used another subjects diffusion MRI data for preprocessing,and a part of them won't have error,which is a large part.I think maybe the problem comes from data.I will try to use data without problems.