Dwi2response error - mrconvert: -coord option is out of range of input image

I got an error during dwi2response.
My command was:
dwi2response tournier -mask mr_eroded_mask_upsample.mif -voxels mr_voxels_reduced_eroded.mif mr_dwi_denoised_preproc_biasCorr_reduced_upsample.mif mr_dwi_response_tournier_reduced_eroded_upsample.txt -force -nthreads 12

The error I got was:

Command: mrconvert iter2_amps.mif iter2_second_peaks.mif -coord 3 1 -axes 0,1,2
dwi2response: 
dwi2response: [ERROR] Command failed: mrconvert iter2_amps.mif iter2_second_peaks.mif -coord 3 1 -axes 0,1,2
dwi2response: Output of failed command:
mrconvert: [ERROR] coordinate position 1 for axis 3 provided with -coord option is out of range of input image
dwi2response: Changing back to original directory (/ifs/scratch/pimri/posnerlab/1anal/Monk/data/5537/DTI)
Traceback (most recent call last):
  File "/ifs/scratch/pimri/posnerlab/app/mrtrix3/scripts/dwi2response", line 120, in <module>
    algorithm.execute()
  File "/ifs/scratch/pimri/posnerlab/app/mrtrix3/scripts/src/dwi2response/tournier.py", line 73, in execute
    runCommand('mrconvert ' + prefix + 'amps.mif ' + prefix + 'second_peaks.mif -coord 3 1 -axes 0,1,2')
  File "/ifs/scratch/pimri/posnerlab/app/mrtrix3/scripts/lib/runCommand.py", line 144, in runCommand
    lib.app.complete()
  File "/ifs/scratch/pimri/posnerlab/app/mrtrix3/scripts/lib/app.py", line 192, in complete
    sys.stdout.write(os.path.basename(sys.argv[0]) + ': ' + colourWarn + 'Script failed while executing the command: ' + errortext.readline().rstrip() + colourClear + '\n')
TypeError: Can't convert 'bytes' object to str implicitly

In the following command:

mrconvert iter2_amps.mif iter2_second_peaks.mif -coord 3 1 -axes 0,1,2

iter2_amps.mif only has one volume and the command expects a second volume. Could you please let me know what is going on here?

for your reference, iter2_amps.mif looks like this:

Hi,

I just found out that with files with the original resolution—not upsampled—dwi2response worked without any issues.

Best,

Jiook

Hi Jiook,

Even though you found that the script works as expected with different data, this is still a useful report for us to look into.

The first error:

mrconvert: [ERROR] coordinate position 1 for axis 3 provided with -coord option is out of range of input image

is, as you say, failing because image iter2_amps.mif only contains one volume. What this implies is that in that iteration of the algorithm, no crossing-fibre populations are detected in any of the single-fibre voxels selected in the previous iteration (or their immediate voxel neighbours, for that matter). I’ve never seen this happen; but will make the necessary modifications to the algorithm so that it correctly identifies when this has happened, informs the user of such, and returns the resulting response function appropriately.

Given it’s an unexpected result, is there any chance of you sharing the two input images? I’d like to see if I can reproduce it, even if only to make sure that the changes I need to make to the script work as required.

The second error:

TypeError: Can't convert 'bytes' object to str implicitly

is a small error occurring when the script library is trying to inform you of the fact that it’s kept the temporary working directory for you (in case you want to debug the issue and/or resume the script later). We might not have picked it up previously due to different versions of Python automagically hiding the mistake. But the script has actually more-or-less completed (given the first error); it’s just crashing when trying to print a message to you. I’ll make sure that one’s fixed as well.

Thanks for the report
Rob