Dwi2response tournier error invalid literal for int base 10


#1

Hi Everyone,

I have just started to use MRtrix3.

I have been following basic tutorials given in http://mrtrix.readthedocs.io/en/latest/tutorials/basic_dwi_processing.html.

I tried to implement

dwi2response tournier mydata.mif respFunction.txt

But it gives me the following error

File/usr/local/mrtrix3/scripts/src/dwi2response/tournier.py line 96, in execute
if int(max-diff)==0
ValueError: invalid literal for int base 10: ' '

I am not sure, why is it giving me this error.
Seems like python error to me.

I am working with MRtrix3, python 3.5.2 and ubuntu 14

Any suggestions.

Cheers


#2

I’m also stumped with this one… The only thing I can think of is to run the command with the -verbose option, and post the full command output. This will hopefully give us some hint as to what might be going on…


#3

A vaguely similar issue was posted earlier here.

What you can try is re-running the script with the -nocleanup option, and after the error occurs have a look at the image iter#_SF_diff.mif, where ‘#’ is the largest number that appears in the directory. For some reason, when mrstats is run on this file, no maximum value is being reported; hence Python is trying to convert ‘nothing’ (i.e. empty space) into an integer.

You can also look at the images iter#_SF.mif and iter(#-1)_SF.mif, since these are what is used to generate image iter#_SF_diff.mif.

If this doesn’t get you anywhere, you can send us a copy of the offending input file, and we’ll see if we can re-produce the fault.

Cheers
Rob


#4

@rsmith,

As per your suggestion; I have looked into iter#_SF_diff.mif and also at iter#_SF.mif and iter(#-1)_SF.mif.

I get , for iter1_SF_diff.mif a grayscale image. It is not empty.

I also checked the link suggested by you.

My brain mask is not empty.

test-TDI-1/workflow_tdi_DTI_P2_1/BrainMask$ mrstats brainmask.mif channel mean std. dev. min max count [ ] 0.148983 0.356072 0 1 600000

This is my file info

Any suggestions ?


#5

Hi,

I have solved this issue.

Apparently there was some internal version clash.

I ran ./set_path.

This updated my .bashrc file.

And on re-executing this command it seemd to be running fine.

This mismatch was also causing some of the commands in mrview to not work.

Cause, although I had include mrtrix3 bin release and scripts into my basrc script. It was still running mrview from the previous version. Once this was fixed; dwi2reponse with tournier also worked fine.

Cheers


#6

Good to know, thanks for reporting back. Just for completeness: I’ve just pushed changes to both the previous version of master and our brand-new version that will delete old bin/ or release/bin/ folders, which should help minimise these types of conflicts.


#7

Unfortunately we encountered a similar error. When we execute TractSeg with raw diffusion input the command fails trying to invoke dwi2response.

Command:
dwi2response tournier tractseg_output/Diffusion_MNI.nii.gz tractseg_output/response.txt -mask tractseg_output/nodif_brain_mask.nii.gz -fslgrad tractseg_output/Diffusion_MNI.bvecs tractseg_output/Diffusion_MNI.bvals -debug

Error:
if int(image.statistic(‘mask.mif’, ‘count’, ‘-mask mask.mif’)) == 0:
ValueError: invalid literal for int() with base 10: ‘1305180 1305180 1305180 1305180 1305180 1305180 1305180 1305180 1305180 1305180 1305180 1305180 1305180 1305180 1305180 1305180 1305180 1305180 1305180 1305180 1305180 1305180 13’

The full debug output is attached below.

We already tried switching to Python 3 and TractSeg 1.9 which did not help.

We would be happy to receive any advice.

Debug output

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: [DEBUG] path.scriptSubDirName() (from algorithm.py:52): dwi2response
dwi2response: [DEBUG] path.fromUser() (from dwi2response:76): tractseg_output/Diffusion_MNI.bvecs -> /home/bwgig/Desktop/tractseg_test/tractseg_output/Diffusion_MNI.bvecs
dwi2response: [DEBUG] path.fromUser() (from dwi2response:76): tractseg_output/Diffusion_MNI.bvals -> /home/bwgig/Desktop/tractseg_test/tractseg_output/Diffusion_MNI.bvals
dwi2response: Generated temporary directory: /home/bwgig/Desktop/tractseg_test/dwi2response-tmp-1NZG2Z/
dwi2response: [DEBUG] path.fromUser() (from dwi2response:84): tractseg_output/Diffusion_MNI.nii.gz -> /home/bwgig/Desktop/tractseg_test/tractseg_output/Diffusion_MNI.nii.gz
dwi2response: [DEBUG] path.toTemp() (from dwi2response:84): dwi.mif -> /home/bwgig/Desktop/tractseg_test/dwi2response-tmp-1NZG2Z/dwi.mif
dwi2response: [DEBUG] run.exeName() (from run.py:349): mrconvert -> mrconvert
dwi2response: [DEBUG] run.versionMatch() (from run.py:57): Version-matched executable for mrconvert: /home/bwgig/mrtrix3/bin/mrconvert
dwi2response: [DEBUG] run._shebang() (from run.py:67): File “/home/bwgig/mrtrix3/bin/mrconvert”: Not a text file
dwi2response: [DEBUG] run.exeName() (from run.py:349): dwiextract -> dwiextract
dwi2response: [DEBUG] run.versionMatch() (from run.py:57): Version-matched executable for dwiextract: /home/bwgig/mrtrix3/bin/dwiextract
dwi2response: [DEBUG] run._shebang() (from run.py:67): File “/home/bwgig/mrtrix3/bin/dwiextract”: Not a text file
dwi2response: [DEBUG] run.command() (from dwi2response:84): To execute: [[’/home/bwgig/mrtrix3/bin/mrconvert’, ‘/home/bwgig/Desktop/tractseg_test/tractseg_output/Diffusion_MNI.nii.gz’, ‘-’, ‘-strides’, ‘0,0,0,1’, ‘-fslgrad’, ‘/home/bwgig/Desktop/tractseg_test/tractseg_output/Diffusion_MNI.bvecs’, ‘/home/bwgig/Desktop/tractseg_test/tractseg_output/Diffusion_MNI.bvals’, ‘-info’], [’/home/bwgig/mrtrix3/bin/dwiextract’, ‘-’, ‘/home/bwgig/Desktop/tractseg_test/dwi2response-tmp-1NZG2Z/dwi.mif’, ‘-singleshell’, ‘-no_bzero’, ‘-info’]]
Command: mrconvert /home/bwgig/Desktop/tractseg_test/tractseg_output/Diffusion_MNI.nii.gz - -strides 0,0,0,1 -fslgrad /home/bwgig/Desktop/tractseg_test/tractseg_output/Diffusion_MNI.bvecs /home/bwgig/Desktop/tractseg_test/tractseg_output/Diffusion_MNI.bvals | dwiextract - /home/bwgig/Desktop/tractseg_test/dwi2response-tmp-1NZG2Z/dwi.mif -singleshell -no_bzero
mrconvert: [INFO] opening image “/home/bwgig/Desktop/tractseg_test/tractseg_output/Diffusion_MNI.nii.gz”…
mrconvert: [INFO] Axes and transform of image “/home/bwgig/Desktop/tractseg_test/tractseg_output/Diffusion_MNI.nii.gz” altered to approximate RAS coordinate system
mrconvert: [INFO] image “/home/bwgig/Desktop/tractseg_test/tractseg_output/Diffusion_MNI.nii.gz” opened with dimensions 145x174x145x41, voxel spacing 1.25x1.25x1.25x1, datatype Float32LE
mrconvert: [INFO] found 41x4 diffusion gradient table
mrconvert: [100%] uncompressing image “/home/bwgig/Desktop/tractseg_test/tractseg_output/Diffusion_MNI.nii.gz”
mrconvert: [INFO] opening image “0,0,0,1”…
mrconvert: [INFO] creating image “-”…
mrconvert: [INFO] image “/tmp/mrtrix-tmp-KYs1vo.mif” created with dimensions 145x174x145x41, voxel spacing 1.25x1.25x1.25x1, datatype Float32LE
mrconvert: [100%] copying from “/home/bwgi…output/Diffusion_MNI.nii.gz” to “/tmp/mrtrix-tmp-KYs1vo.mif”
dwiextract: [INFO] opening image “-”…
dwiextract: [INFO] image “/tmp/mrtrix-tmp-KYs1vo.mif” opened with dimensions 145x174x145x41, voxel spacing 1.25x1.25x1.25x1, datatype Float32LE
dwiextract: [INFO] found 41x4 diffusion gradient table
dwiextract: [INFO] b-values will be scaled by the square of DW gradient norm
dwiextract: [INFO] Diffusion gradient encoding data clustered into 1 non-zero shells and 1 b=0 volumes
dwiextract: [INFO] creating image “/home/bwgig/Desktop/tractseg_test/dwi2response-tmp-1NZG2Z/dwi.mif”…
dwiextract: [INFO] image “/home/bwgig/Desktop/tractseg_test/dwi2response-tmp-1NZG2Z/dwi.mif” created with dimensions 145x174x145x40, voxel spacing 1.25x1.25x1.25x1, datatype Float32LE
dwiextract: [100%] extracting volumes
dwi2response: [DEBUG] path.fromUser() (from dwi2response:88): tractseg_output/nodif_brain_mask.nii.gz -> /home/bwgig/Desktop/tractseg_test/tractseg_output/nodif_brain_mask.nii.gz
dwi2response: [DEBUG] path.toTemp() (from dwi2response:88): mask.mif -> /home/bwgig/Desktop/tractseg_test/dwi2response-tmp-1NZG2Z/mask.mif
dwi2response: [DEBUG] run.exeName() (from run.py:349): mrconvert -> mrconvert
dwi2response: [DEBUG] run.versionMatch() (from run.py:57): Version-matched executable for mrconvert: /home/bwgig/mrtrix3/bin/mrconvert
dwi2response: [DEBUG] run._shebang() (from run.py:67): File “/home/bwgig/mrtrix3/bin/mrconvert”: Not a text file
dwi2response: [DEBUG] run.command() (from dwi2response:88): To execute: [[’/home/bwgig/mrtrix3/bin/mrconvert’, ‘/home/bwgig/Desktop/tractseg_test/tractseg_output/nodif_brain_mask.nii.gz’, ‘/home/bwgig/Desktop/tractseg_test/dwi2response-tmp-1NZG2Z/mask.mif’, ‘-datatype’, ‘bit’, ‘-info’]]
Command: mrconvert /home/bwgig/Desktop/tractseg_test/tractseg_output/nodif_brain_mask.nii.gz /home/bwgig/Desktop/tractseg_test/dwi2response-tmp-1NZG2Z/mask.mif -datatype bit
mrconvert: [INFO] opening image “/home/bwgig/Desktop/tractseg_test/tractseg_output/nodif_brain_mask.nii.gz”…
mrconvert: [INFO] Axes and transform of image “/home/bwgig/Desktop/tractseg_test/tractseg_output/nodif_brain_mask.nii.gz” altered to approximate RAS coordinate system
mrconvert: [INFO] image “/home/bwgig/Desktop/tractseg_test/tractseg_output/nodif_brain_mask.nii.gz” opened with dimensions 145x174x145x41, voxel spacing 1.25x1.25x1.25x1, datatype Int16LE
mrconvert: [100%] uncompressing image “/home/bwgig/Desktop/tractseg_test/tractseg_output/nodif_brain_mask.nii.gz”
mrconvert: [INFO] creating image “/home/bwgig/Desktop/tractseg_test/dwi2response-tmp-1NZG2Z/mask.mif”…
mrconvert: [INFO] image “/home/bwgig/Desktop/tractseg_test/dwi2response-tmp-1NZG2Z/mask.mif” created with dimensions 145x174x145x41, voxel spacing 1.25x1.25x1.25x1, datatype Bit
mrconvert: [100%] copying from “/home/bwgi…put/nodif_brain_mask.nii.gz” to “/home/bwgi…esponse-tmp-1NZG2Z/mask.mif”
dwi2response: Changing to temporary directory (/home/bwgig/Desktop/tractseg_test/dwi2response-tmp-1NZG2Z/)
dwi2response: [DEBUG] path.newTemporary() (from image.py:11): /home/bwgig/Desktop/tractseg_test/dwi2response-tmp-1NZG2Z/mrtrix-tmp-ZARRZV.json
dwi2response: [DEBUG] run.exeName() (from run.py:349): mrinfo -> mrinfo
dwi2response: [DEBUG] run.versionMatch() (from image.py:12): Version-matched executable for mrinfo: /home/bwgig/mrtrix3/bin/mrinfo
dwi2response: [DEBUG] run.exeName() (from image.py:12): /home/bwgig/mrtrix3/bin/mrinfo -> /home/bwgig/mrtrix3/bin/mrinfo
dwi2response: Loading header for image file ‘mask.mif’
dwi2response: [DEBUG] image.init() (from dwi2response:97): [’/home/bwgig/mrtrix3/bin/mrinfo’, ‘mask.mif’, ‘-json_all’, ‘/home/bwgig/Desktop/tractseg_test/dwi2response-tmp-1NZG2Z/mrtrix-tmp-ZARRZV.json’]
dwi2response: [DEBUG] image.init() (from dwi2response:97): {’_intensity_offset’: 0.0, ‘_format’: u’MRtrix’, ‘_transform’: [[1.0, 0.0, 0.0, -90.0], [-0.0, 1.0, 0.0, -126.0], [-0.0, 0.0, 1.0, -72.0], [0.0, 0.0, 0.0, 1.0]], ‘_intensity_scale’: 1.0, ‘_datatype’: u’Bit’, ‘_name’: u’mask.mif’, ‘_keyval’: {u’command_history’: u’/home/bwgig/mrtrix3/bin/mrconvert “/home/bwgig/Desktop/tractseg_test/tractseg_output/nodif_brain_mask.nii.gz” “/home/bwgig/Desktop/tractseg_test/dwi2response-tmp-1NZG2Z/mask.mif” “-datatype” “bit” “-info” (version=3.0_RC3-135-g2b8e7d0c-dirty)’, u’mrtrix_version’: u’3.0_RC3-135-g2b8e7d0c-dirty’, u’comments’: u’6.0.0’}, ‘_size’: [145, 174, 145, 41], ‘_spacing’: [1.25, 1.25, 1.25, 1.0], ‘_strides’: [-1, 2, 3, 4]}
dwi2response: [DEBUG] path.newTemporary() (from image.py:11): /home/bwgig/Desktop/tractseg_test/dwi2response-tmp-1NZG2Z/mrtrix-tmp-1YEX87.json
dwi2response: [DEBUG] run.exeName() (from run.py:349): mrinfo -> mrinfo
dwi2response: [DEBUG] run.versionMatch() (from image.py:12): Version-matched executable for mrinfo: /home/bwgig/mrtrix3/bin/mrinfo
dwi2response: [DEBUG] run.exeName() (from image.py:12): /home/bwgig/mrtrix3/bin/mrinfo -> /home/bwgig/mrtrix3/bin/mrinfo
dwi2response: Loading header for image file ‘dwi.mif’
dwi2response: [DEBUG] image.init() (from dwi2response:97): [’/home/bwgig/mrtrix3/bin/mrinfo’, ‘dwi.mif’, ‘-json_all’, ‘/home/bwgig/Desktop/tractseg_test/dwi2response-tmp-1NZG2Z/mrtrix-tmp-1YEX87.json’]
dwi2response: [DEBUG] image.init() (from dwi2response:97): {’_intensity_offset’: 0.0, ‘_format’: u’MRtrix’, ‘_transform’: [[1.0, 0.0, 0.0, -90.0], [-0.0, 1.0, 0.0, -126.0], [-0.0, 0.0, 1.0, -72.0], [0.0, 0.0, 0.0, 1.0]], ‘_intensity_scale’: 1.0, ‘_datatype’: u’Float32LE’, ‘_name’: u’dwi.mif’, ‘_keyval’: {u’command_history’: u’/home/bwgig/mrtrix3/bin/mrconvert “/home/bwgig/Desktop/tractseg_test/tractseg_output/Diffusion_MNI.nii.gz” “-” “-strides” “0,0,0,1” “-fslgrad” “/home/bwgig/Desktop/tractseg_test/tractseg_output/Diffusion_MNI.bvecs” “/home/bwgig/Desktop/tractseg_test/tractseg_output/Diffusion_MNI.bvals” “-info” (version=3.0_RC3-135-g2b8e7d0c-dirty)\n/home/bwgig/mrtrix3/bin/dwiextract “-” “/home/bwgig/Desktop/tractseg_test/dwi2response-tmp-1NZG2Z/dwi.mif” “-singleshell” “-no_bzero” “-info” (version=3.0_RC3-135-g2b8e7d0c-dirty)’, u’dw_scheme’: [[0.9986789595, 0.04836884299, 0.01734332229, 1000.0], [0.03916667057, -0.9885227763, 0.1459064514, 1000.0], [0.01601056684, -0.8857527055, -0.4638812417, 1000.0], [0.8693183555, -0.4333174734, 0.2377426427, 1000.0], [0.8590441221, -0.3448709767, -0.3782951304, 1000.0], [0.8359949889, 0.2774859466, -0.4734067257, 1000.0], [0.8296204094, 0.551690959, 0.08583159167, 1000.0], [0.8063130778, 0.1290877999, 0.5772309421, 1000.0], [0.5465192789, -0.2920385129, 0.7848759041, 1000.0], [0.4907179799, -0.7624357628, 0.421767201, 1000.0], [0.5532825507, -0.8221928678, -0.1337060478, 1000.0], [0.4346122622, -0.615059575, -0.6578859329, 1000.0], [0.5055791499, -0.1191063534, -0.854519397, 1000.0], [0.3939854334, 0.4150513356, -0.82006577, 1000.0], [0.4913037218, 0.7806065491, -0.3863600244, 1000.0], [0.4243433651, 0.890927135, 0.1618071341, 1000.0], [0.510798647, 0.5626508369, 0.6500067522, 1000.0], [0.07014248007, 0.4215551867, 0.9040858682, 1000.0], [0.09038756134, -0.1102748126, 0.9897825794, 1000.0], [0.04334309729, -0.6986993603, 0.7141012392, 1000.0], [0.9985849679, 0.04905547751, 0.02053343637, 1000.0], [0.03954159162, -0.9875326602, 0.152367016, 1000.0], [0.01786697115, -0.8886762101, -0.4581870415, 1000.0], [0.8691911647, -0.4308484044, 0.2426445376, 1000.0], [0.8603751534, -0.3461907495, -0.3740408538, 1000.0], [0.836642519, 0.2754246812, -0.4734665145, 1000.0], [0.8288712438, 0.5529733279, 0.0848113192, 1000.0], [0.8044833333, 0.1327874072, 0.5789422001, 1000.0], [0.544585104, -0.2872836811, 0.7879690039, 1000.0], [0.4902429815, -0.7594588949, 0.4276493961, 1000.0], [0.5544503178, -0.8224794211, -0.1269348135, 1000.0], [0.4375439673, -0.6189700299, -0.6522510091, 1000.0], [0.5091454604, -0.1239591514, -0.8517071263, 1000.0], [0.3975411364, 0.4100108353, -0.8208849858, 1000.0], [0.4921992514, 0.7789431094, -0.3885711379, 1000.0], [0.4230508925, 0.8922108453, 0.1580751396, 1000.0], [0.5084454731, 0.5666467399, 0.6483784953, 1000.0], [0.06726855852, 0.4268270399, 0.9018279321, 1000.0], [0.08778581058, -0.1049370707, 0.9905967205, 1000.0], [0.04162391876, -0.6953214389, 0.7174925407, 1000.0]], u’mrtrix_version’: u’3.0_RC3-135-g2b8e7d0c-dirty’, u’comments’: u’6.0.0’}, ‘_size’: [145, 174, 145, 40], ‘_spacing’: [1.25, 1.25, 1.25, 1.0], ‘_strides’: [-2, 3, 4, 1]}
dwi2response: [DEBUG] run.exeName() (from run.py:349): mrstats -> mrstats
dwi2response: [DEBUG] run.versionMatch() (from image.py:189): Version-matched executable for mrstats: /home/bwgig/mrtrix3/bin/mrstats
dwi2response: [DEBUG] run.exeName() (from image.py:189): /home/bwgig/mrtrix3/bin/mrstats -> /home/bwgig/mrtrix3/bin/mrstats
dwi2response: Command: ‘/home/bwgig/mrtrix3/bin/mrstats mask.mif -output count -mask mask.mif’ (piping data to local storage)
dwi2response: Result: 1305180
1305180
1305180
1305180
1305180
1305180
1305180
1305180
1305180
1305180
1305180
1305180
1305180
1305180
1305180
1305180
1305180
1305180
1305180
1305180
1305180
1305180
1305180
1305180
1305180
1305180
1305180
1305180
1305180
1305180
1305180
1305180
1305180
1305180
1305180
1305180
1305180
1305180
1305180
1305180
1305180
Traceback (most recent call last):
File “/home/bwgig/mrtrix3/bin/dwi2response”, line 102, in
if int(image.statistic(‘mask.mif’, ‘count’, ‘-mask mask.mif’)) == 0:
ValueError: invalid literal for int() with base 10: ‘1305180 1305180 1305180 1305180 1305180 1305180 1305180 1305180 1305180 1305180 1305180 1305180 1305180 1305180 1305180 1305180 1305180 1305180 1305180 1305180 1305180 1305180 13’

@Lucius


#8

I assume that dwi2response does not know how to handle the multiline output of mrstats. Because the statement in bin/dwiresponse:102 should only check if the mask file is empty or not - which it clearly is not - I commented out the if statement for now. The command finishes without an error if commented out.

I don’t know how a real fix for this problem would look like at the moment.


#9

Seems to me that the issue might be due to a multi volume (4D) mask image? No idea where it came from, but I expect the problematic call expects a single value for the count, which would be the case if the image (the mask) was a 3D volume, as expected. Is that the case?


#10

mrconvert: [INFO] image “/home/bwgig/Desktop/tractseg_test/tractseg_output/nodif_brain_mask.nii.gz” opened with dimensions 145x174x145x41, voxel spacing 1.25x1.25x1.25x1, datatype Int16LE

Yes, the input mask image is 4D. In general we try to have commands that expect a 3D image still work if they receive a 4D image with only one volume (i.e. dimensions XxYxZx1), but in cases like this the expected behaviour is ambiguous. Ideally dwi2response would check for this earlier on, and provide a more explicit error message up-front.