dwi2response: mrthreshhold error "bottom" is out of bounds

Hi there,
I’m totally new to diffusion imaging and using MRtrix3.0.3 for the first time to preprocess some multi-shell dwi data.

Broadly, the dwi acquisition was done on a 7T Siemens Magnetom: b=2500 x 60dir, b=1000 x 30dir, b=0 x 6 dir all acquired in AP, and one b=0 acquired in PA direction.

The raw (bidsified) data I input look like this:

sub-081_ses-02_acq-b0orig_dir-PA_dwi.bval
sub-081_ses-02_acq-b0orig_dir-PA_dwi.bvec
sub-081_ses-02_acq-b0orig_dir-PA_dwi.json
sub-081_ses-02_acq-b0orig_dir-PA_dwi.nii.gz
sub-081_ses-02_acq-b25001000d060306orig_dir-AP_dwi.bval
sub-081_ses-02_acq-b25001000d060306orig_dir-AP_dwi.bvec
sub-081_ses-02_acq-b25001000d060306orig_dir-AP_dwi.json
sub-081_ses-02_acq-b25001000d060306orig_dir-AP_dwi.nii.gz

Plus a T1w image.

While running this command:

dwi2response dhollander dwi_den_preproc_unbiased.mif wm.txt gm.txt csf.txt -voxels voxels.mif

I’m running into this error:

dwi2response: [ERROR] mrcalc refined_gm.mif safe_sdm.mif 1.38035095 -subtract -abs 1 -add 0 -if - | mrthreshold - - -bottom 0 -ignorezero | mrcalc refined_gm.mif - 0 -if - -datatype bit | mrconvert - voxels_gm.mif -axes 0,1,2 (dhollander.py:220)
dwi2response: [ERROR] Information from failed command:
dwi2response:
              ]
              mrthreshold: [ERROR] value supplied for option "bottom" is out of bounds (valid range: 1 to 9223372036854775807, value supplied: 0)
              mrcalc: [ERROR] Could not interpret string "-" as either an image path or a numerical value

This is all the output from dwi2response immediately before the error:

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: /scratch/cvl/uqywards/data/bidsdwi/sub-081/ses-02/dwi2response-tmp-ZJQS82/
dwi2response: Importing DWI data (/scratch/cvl/uqywards/data/bidsdwi/sub-081/ses-02/dwi_den_preproc_unbiased.mif)...
dwi2response: Changing to scratch directory (/scratch/cvl/uqywards/data/bidsdwi/sub-081/ses-02/dwi2response-tmp-ZJQS82/)
dwi2response: Computing brain mask (dwi2mask)...
dwi2response: -------
dwi2response: 3 unique b-value(s) detected: 0,1001,2500 with 6,30,60 volumes
dwi2response: -------
dwi2response: Preparation:
dwi2response: * Eroding brain mask by 3 pass(es)...
dwi2response:   [ mask: 191895 -> 145250 ]
dwi2response: * Computing signal decay metric (SDM):
dwi2response:  * b=0...
dwi2response:  * b=1001...
dwi2response:  * b=2500...
dwi2response: * Removing erroneous voxels from mask and correcting SDM...
dwi2response:   [ mask: 145250 -> 145221 ]
dwi2response: -------
dwi2response: Crude segmentation:
dwi2response: * Crude WM versus GM-CSF separation (at FA=0.2)...
dwi2response:   [ 145221 -> 145204 (WM) & 17 (GM-CSF) ]
dwi2response: * Crude GM versus CSF separation...
dwi2response:   [ 17 -> 14 (GM) & 3 (CSF) ]
dwi2response: -------
dwi2response: Refined segmentation:
dwi2response: * Refining WM...
dwi2response:   [ WM: 145204 -> 119426 ]
dwi2response: * Refining GM...
dwi2response:   [ GM: 14 -> 11 ]
dwi2response: * Refining CSF...
dwi2response:   [ CSF: 3 -> 6949 ]
dwi2response: -------
dwi2response: Final voxel selection and response function estimation:
dwi2response: * CSF:
dwi2response:  * Selecting final voxels (10.0% of refined CSF)...
dwi2response:    [ CSF: 6949 -> 695 ]
dwi2response:  * Estimating response function...
dwi2response: * GM:
dwi2response:  * Selecting final voxels (2.0% of refined GM)...

The strange thing is that I’m only getting this error on roughly 1/6 datasets, all the other subjects’ data runs perfectly fine. All subjects’ data was acquired and handled in exactly the same way up until this point.

I’ve checked that the following mrstats output looks sensible (as per Dwi2response dhollander with single-shell data - #4 by ThijsDhollander) , and looks the more or less the same between the subjects that ran successfully vs the unsuccessful. I couldn’t see any obvious inconsistencies between those two groups. This is the output for an unsuccessful subject:

mrstats dwi_den_preproc_unbiased.mif 
      volume       mean     median        std        min        max      count
       [ 0 ]    225.604    26.0696    428.513   -77.8928    4359.29     792000
       [ 1 ]    33.5253    10.8098    46.7958   -9.72118     699.59     792000
       [ 2 ]    68.5331    13.1319    98.4974   -18.7232    1447.52     792000
       [ 3 ]    32.9465    10.9196    43.9799    -10.509    541.876     792000
       [ 4 ]    33.6652    10.9169    46.0688   -18.6469    812.889     792000
       [ 5 ]    68.0234    12.9603    98.8386   -41.9257    1429.11     792000
       [ 6 ]    33.3437    11.0449    45.5428   -29.2986    586.589     792000
       [ 7 ]    33.1947    11.0987     44.512   -17.8611    711.573     792000
       [ 8 ]    68.8179    12.9325    99.3377   -46.1274    1206.68     792000
       [ 9 ]    32.5754    10.7389    44.0108   -25.5638    608.957     792000
      [ 10 ]    32.8976    10.8686    44.5712   -25.2744    660.122     792000
      [ 11 ]    68.1469    12.4588     99.882    -68.533     1534.8     792000
      [ 12 ]    33.3571      10.98    45.5524   -24.6983    672.529     792000
      [ 13 ]    33.8293    10.9306    45.7618   -40.3466    500.997     792000
      [ 14 ]    68.3923    12.7722    98.8272   -77.6986    1368.13     792000
      [ 15 ]    33.1235    11.0074    44.7503   -34.2009    731.715     792000
      [ 16 ]    225.372    26.0705     427.22   -161.473    4335.47     792000
      [ 17 ]    32.5487    10.8458    43.7321   -36.7623    600.417     792000
      [ 18 ]    68.4628    12.8421    98.8906   -93.4583    1139.42     792000
      [ 19 ]    33.2623    10.9362    45.4955   -43.3604    569.888     792000
      [ 20 ]    32.9939    10.9871    43.9228   -34.3732    501.919     792000
      [ 21 ]    68.5864     12.557      100.2   -89.4346    1585.51     792000
      [ 22 ]    33.6954    11.1862    45.2316   -40.8593    812.241     792000
      [ 23 ]    33.1582     10.979    45.1631    -29.897    584.966     792000
      [ 24 ]     67.462    12.4383     99.268   -94.2682    1453.97     792000
      [ 25 ]    33.4161     10.817    46.3118   -30.7029    740.809     792000
      [ 26 ]    33.4556    11.0815    45.1121    -26.036    688.536     792000
      [ 27 ]    68.2906     12.823    98.5451    -68.325    1575.81     792000
      [ 28 ]    33.4337    10.9955     44.932   -31.4385    768.656     792000
      [ 29 ]    33.4882    10.9316    46.0712   -33.2577    478.714     792000
      [ 30 ]    67.8546    12.6469    98.6953   -67.8498    1212.05     792000
      [ 31 ]    33.2393    10.6802    46.2148   -34.8093    755.174     792000
      [ 32 ]    224.674    25.8476    425.058   -123.557    4389.78     792000
      [ 33 ]    33.8282    10.9166    45.9179   -38.0568    486.606     792000
      [ 34 ]      68.59    12.8053    99.4243   -61.7393    1151.61     792000
      [ 35 ]    33.1781     10.994    44.5938    -12.927     572.43     792000
      [ 36 ]    33.8559     11.021    45.9852   -27.8023    501.257     792000
      [ 37 ]    68.9705    12.9136    99.6649   -48.9331    1397.56     792000
      [ 38 ]    33.2831    10.9104    45.4402   -13.1544    505.805     792000
      [ 39 ]    33.3575    11.0789    44.5915   -24.3367    790.146     792000
      [ 40 ]    67.2569    12.6381    97.3887   -55.1866     1172.4     792000
      [ 41 ]    33.5339    11.0714    45.7987   -18.8319     507.55     792000
      [ 42 ]    32.8478    11.0191    44.0817   -14.9116    649.516     792000
      [ 43 ]    67.2741    12.5505    98.0491   -63.9307    1177.29     792000
      [ 44 ]    33.8165    10.8566    46.9971    -21.057    804.612     792000
      [ 45 ]    32.8388    10.8857    44.5418   -9.06007    688.542     792000
      [ 46 ]    68.4657    12.9688     99.269   -41.7669    1608.21     792000
      [ 47 ]      33.62    10.9822    45.5036   -24.8433    771.574     792000
      [ 48 ]    225.496    26.2786    427.051   -155.858    4355.98     792000
      [ 49 ]      33.77    10.9479    46.2539   -25.9326     507.89     792000
      [ 50 ]    67.3933    12.6131    97.9132   -38.0978    1215.99     792000
      [ 51 ]    33.0295    10.9499    43.9517   -11.3667    515.787     792000
      [ 52 ]    33.5896    11.0367    45.2422   -14.3615    588.068     792000
      [ 53 ]    67.2486    12.4537    98.5836    -38.036    1397.26     792000
      [ 54 ]    32.6396    10.8519    44.3738   -11.3554    714.447     792000
      [ 55 ]    33.1745    10.9821    44.8263   -23.6144    489.026     792000
      [ 56 ]    67.8408    12.8236    97.9866   -46.3754    1155.67     792000
      [ 57 ]    32.9807    11.0555    44.5212   -11.5739     540.78     792000
      [ 58 ]    33.7414    10.9972    45.3545   -17.3297    506.522     792000
      [ 59 ]    68.4033    12.8414    98.9654   -27.7487    1174.67     792000
      [ 60 ]    32.9253    10.9542    44.1526   -7.96499    594.321     792000
      [ 61 ]    33.4991    11.0728    45.3298   -9.00119    660.986     792000
      [ 62 ]    68.6834    12.6427    100.182   -19.8394     1090.9     792000
      [ 63 ]     33.516    10.9901    45.3049    -8.4031    756.794     792000
      [ 64 ]    224.653    26.1813    425.723   -128.348    4373.91     792000
      [ 65 ]    33.3461    10.9638    45.6967   -30.6652    497.677     792000
      [ 66 ]    68.4454    12.6604    99.5934   -13.3198    1118.48     792000
      [ 67 ]    33.3317    11.1403    44.5546   -11.6457    602.121     792000
      [ 68 ]    33.5981    11.0683    45.3974   -8.46102    566.477     792000
      [ 69 ]    68.5784    13.0115    98.7589   -15.3578    1567.76     792000
      [ 70 ]    33.5136    11.0097    45.1391   -10.5454    667.103     792000
      [ 71 ]    33.5131    10.9283    45.3518   -11.0038    757.323     792000
      [ 72 ]    67.9993    12.8271    98.0638   -14.6371    1170.59     792000
      [ 73 ]    33.1867    11.2213    43.9231   -8.08128    641.989     792000
      [ 74 ]    33.1309     11.066    44.3074   -12.8869    683.116     792000
      [ 75 ]     68.563    12.9466    98.6603    -21.376    1320.43     792000
      [ 76 ]      33.04     10.861    45.4148   -12.9685    768.963     792000
      [ 77 ]    32.6577    10.8141    44.3012   -11.8498    684.515     792000
      [ 78 ]    68.1491    13.0069     98.698   -20.8514    1613.46     792000
      [ 79 ]    33.4766    10.9863    45.2155    -8.6721    641.386     792000
      [ 80 ]    225.241    26.3994    425.874   -148.569    4332.54     792000
      [ 81 ]    33.8255    11.0089    45.6156   -15.2462    518.511     792000
      [ 82 ]    68.0764    12.7456    98.7705   -20.5782    1131.55     792000
      [ 83 ]    33.0691    11.0475    43.9437    -11.979    587.742     792000
      [ 84 ]    33.7105     10.748    47.2111   -6.91505    789.475     792000
      [ 85 ]    68.0934    13.0205    98.5841   -19.6995    1439.53     792000
      [ 86 ]    33.2425    10.8682     45.653   -11.8344    704.633     792000
      [ 87 ]     33.118    11.0392     44.426   -19.6083    787.107     792000
      [ 88 ]    67.2247    12.4361    98.8212   -15.7834    1440.03     792000
      [ 89 ]    32.9667    11.1284    44.1834   -12.3513    698.324     792000
      [ 90 ]    33.1401    11.0704    44.9349   -36.0062    663.574     792000
      [ 91 ]     68.042    12.7301     98.519   -32.6245     1182.3     792000
      [ 92 ]    33.6192    10.8127    47.0035   -7.50583    741.346     792000
      [ 93 ]    33.9159    10.9589    46.2415   -17.1549    542.396     792000
      [ 94 ]    68.7463    12.7124    100.225   -20.9229    1667.04     792000
      [ 95 ]    33.5328    10.8954    46.2297   -14.5156     759.26     792000

I’m not sure if this is relevant for my exact error, but this is a small snippet of the output from the “mrinfo dwi_den_preproc_unbiased.mif -dwgrad” command. I believe it also looks sensible, and again looks roughly the same for subjects that ran successfully vs unsuccessfully.

mrinfo dwi_den_preproc_unbiased.mif -dwgrad
-0.5855320966696912  0.5340646921723553  0.6098582362684321                   0
-0.5766456784261192 -0.5762032649260992 -0.5791973403262348                2500
 0.5784417000926612 -0.5756298712926968 -0.5779753029926671                 995
-0.5782468337016529 -0.5788247019016545  0.5749717939016434                2510
-0.5765702972849575 -0.5757757828849782  -0.579697283184876                2490
 0.5774875239074091  0.5803309004074456 -0.5742161664073671                 995
 0.5759777777091984  0.5750914549091842   0.580964214109278                2500
 0.5775957047130471  0.5813047464131309 -0.5731212731129461                2495
-0.5763089908933897  0.5802078192933451 -0.5755230954933989                1000
 0.5761960273095779 -0.5808815071096557  0.5749563573095573                2510
  -0.57841485232055 -0.5808520206206366  0.5727540386203488                2505
-0.5779813888127195 -0.5815784520127987  0.5724543810125979                1000
 0.5791337037825004 -0.5731292949826819 -0.5797645766824815                2495
 0.5751383955640389  0.5735043105641411  0.5833597789635249                2510
 0.5790893279149646  -0.572801649314802 -0.5801325890149915                1000
-0.5782977910987848 -0.5821028155987767  0.5716012393987988                2500

The issue happens regardless of whether I attempt to run several participants at the same time, or if I run them one by one. I don’t have any problems with storage space.

Do you have any idea why some datasets are running into this error and what I can do to further debug/fix the issue? I’d really appreciate any help.

Kind regards

Yohan

1 Like