ACT issue

I am trying to run ACT using the freesurfer algorithm but keep getting the following issue with 5TTGen. The freesurfer Lut file should be all integer values? I am confused about why this is occurring/how to troubleshoot. For reference, I am working with Human Connectome Data.

I am running the following code…

cd ${SUBJECTS_DIR}/CONNECTOME/dwi/${subj}/T1w/
rm -f 5TT.mif
5ttgen freesurfer -force T1w_acpc_dc_restore_1.25.nii.gz 5TT.mif
5tt2vis -force 5TT.mif vis.mif
labelconvert -force ${SUBJECTS_DIR}/CONNECTOME/anat/freesurfer/${subj}/mri/aparc+aseg.mgz /data/bswift-1/dcallow/CONNECTOME/FreeSurferColorLUT.txt /data/bswift-1/dcallow/CONNECTOME$
labelsgmfix -force nodes.mif T1w_acpc_dc_restore_1.25.nii.gz /data/bswift-1/dcallow/CONNECTOME/fs_default.txt nodes_fixSFM.mif -premasked

#extract mean bo
mrconvert -force ${SUBJECTS_DIR}/CONNECTOME/dwi/${subj}/T1w/Diffusion/wmfod.mif - -coord 3 0 | mrcat ${SUBJECTS_DIR}/CONNECTOME/dwi/${subj}/T1w/Diffusion/csf.mif ${SUBJECTS_DIR}/CO$

tckgen -force ${SUBJECTS_DIR}/CONNECTOME/dwi/${subj}/T1w/Diffusion/wmfod.mif 100M.tck -act 5TT.mif -backtrack -crop_at_gmwmi -seed_dynamic ${SUBJECTS_DIR}/CONNECTOME/dwi/${subj}/T1$
tcksift -force 100M.tck ${SUBJECTS_DIR}/CONNECTOME/dwi/${subj}/T1w/Diffusion/wmfod.mif 10M_SIFT.tck -act 5TT.mif -term_number 10M

And get the following output

set subj= ( 100307 )

cd /data/bswift-1/dcallow/CONNECTOME/dwi

cd /data/bswift-1/dcallow/CONNECTOME/dwi/100307/T1w/

/data/bswift-0/software/MRtrix3Tissue/bin/5ttgen freesurfer -force T1w_acpc_dc_restore_1.25.nii.gz 5TT.mif

5ttgen: 

5ttgen: *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.*

5ttgen: 

5ttgen: *Generated scratch directory: /a/ha-nfs-2-ib/export/data/bswift-1/dcallow/CONNECTOME/dwi/100307/T1w/5ttgen-tmp-DJ1JYF/*

*Command:* mrconvert /a/ha-nfs-2-ib/export/data/bswift-1/dcallow/CONNECTOME/dwi/100307/T1w/T1w_acpc_dc_restore_1.25.nii.gz /a/ha-nfs-2-ib/export/data/bswift-1/dcallow/CONNECTOME/dwi/100307/T1w/5ttgen-tmp-DJ1JYF/input.mif

5ttgen: *Changing to scratch directory (/a/ha-nfs-2-ib/export/data/bswift-1/dcallow/CONNECTOME/dwi/100307/T1w/5ttgen-tmp-DJ1JYF/)*

*Command:* labelconvert input.mif /data/bswift-0/software/freesurfer-dev/FreeSurferColorLUT.txt /a/ha-nfs-1-ib/export/data/bswift-0/software/MRtrix3Tissue/share/mrtrix3/_5ttgen/FreeSurfer2ACT.txt indices.mif

5ttgen: **[ERROR] labelconvert input.mif /data/bswift-0/software/freesurfer-dev/FreeSurferColorLUT.txt /a/ha-nfs-1-ib/export/data/bswift-0/software/MRtrix3Tissue/share/mrtrix3/_5ttgen/FreeSurfer2ACT.txt indices.mif** *(freesurfer.py:49)*

5ttgen: **[ERROR] Information from failed command:**

5ttgen:

labelconvert: Image "input.mif" stored with floating-point type; need to check for non-integer or negative values

]

labelconvert: [ERROR] Floating-point number detected in image "input.mif"; label images should contain integers only

5ttgen:

5ttgen: **[ERROR] For debugging, inspect contents of scratch directory: /a/ha-nfs-2-ib/export/data/bswift-1/dcallow/CONNECTOME/dwi/100307/T1w/5ttgen-tmp-DJ1JYF/**

5ttgen: *Scratch directory retained; location: /a/ha-nfs-2-ib/export/data/bswift-1/dcallow/CONNECTOME/dwi/100307/T1w/5ttgen-tmp-DJ1JYF/*

5tt2vis -force 5TT.mif vis.mif

5tt2vis: [WARNING] existing output files will be overwritten

5tt2vis: **[ERROR] failed to open key/value file "5TT.mif": No such file or directory**

5tt2vis: **[ERROR] error opening image "5TT.mif"**

labelconvert -force /data/bswift-1/dcallow/CONNECTOME/anat/freesurfer/100307/mri/aparc+aseg.mgz /data/bswift-1/dcallow/CONNECTOME/FreeSurferColorLUT.txt /data/bswift-1/dcallow/CONNECTOME/fs_default.txt nodes.mif

labelconvert: [WARNING] existing output files will be overwritten

labelconvert: Image "/data/bswift-1/dcallow/CONNECTOME/anat/freesurfer/100307/mri/aparc+aseg.mgz" stored with signed integer type; need to check for negative values

labelconvert: [100%] uncompressing image "/data/bswift-1/dcallow/CONNECTOME/anat/freesurfer/100307/mri/aparc+aseg.mgz"

labelconvert: [100%] Verifying parcellation image

labelconvert: [100%] uncompressing image "/data/bswift-1/dcallow/CONNECTOME/anat/freesurfer/100307/mri/aparc+aseg.mgz"

labelsgmfix -force nodes.mif T1w_acpc_dc_restore_1.25.nii.gz /data/bswift-1/dcallow/CONNECTOME/fs_default.txt nodes_fixSFM.mif -premasked

labelsgmfix: 

labelsgmfix: *Note that this script makes use of commands / algorithms that have relevant articles for citation; INCLUDING FROM EXTERNAL SOFTWARE PACKAGES. Please consult the help page (-help option) for more information.*

labelsgmfix: 

labelsgmfix: [WARNING] Voxel size of input T1 image larger than expected for T1-weighted images ([1.25, 1.25, 1.25]); image will be resampled to 1mm isotropic in order to maximise chance of FSL FIRST script succeeding

labelsgmfix: *Generated scratch directory: /a/ha-nfs-2-ib/export/data/bswift-1/dcallow/CONNECTOME/dwi/100307/T1w/labelsgmfix-tmp-0YWHMW/*

*Command:* mrconvert /a/ha-nfs-2-ib/export/data/bswift-1/dcallow/CONNECTOME/dwi/100307/T1w/nodes.mif /a/ha-nfs-2-ib/export/data/bswift-1/dcallow/CONNECTOME/dwi/100307/T1w/labelsgmfix-tmp-0YWHMW/parc.mif

*Command:* mrgrid /a/ha-nfs-2-ib/export/data/bswift-1/dcallow/CONNECTOME/dwi/100307/T1w/T1w_acpc_dc_restore_1.25.nii.gz regrid - -voxel 1.0 -interp sinc | mrcalc - 0.0 -max - | mrconvert - /a/ha-nfs-2-ib/export/data/bswift-1/dcallow/CONNECTOME/dwi/100307/T1w/labelsgmfix-tmp-0YWHMW/T1.nii -strides -1,+2,+3

labelsgmfix: *Changing to scratch directory (/a/ha-nfs-2-ib/export/data/bswift-1/dcallow/CONNECTOME/dwi/100307/T1w/labelsgmfix-tmp-0YWHMW/)*

*Command:* run_first_all -m none -s L_Accu,R_Accu,L_Caud,R_Caud,L_Pall,R_Pall,L_Puta,R_Puta,L_Thal,R_Thal -i T1.nii -b -o first

Hi Daniel,

$ /data/bswift-0/software/MRtrix3Tissue/bin/5ttgen freesurfer -force T1w_acpc_dc_restore_1.25.nii.gz 5TT.mif`

5ttgen: **[ERROR] Information from failed command:**

    labelconvert: Image "input.mif" stored with floating-point type; need to check for non-integer or negative values
    labelconvert: [ERROR] Floating-point number detected in image "input.mif"; label images should contain integers only

This specific error is being produced because 5ttgen freesurfer does not receive as input a T1-weighted image; its input is instead a FreeSurfer segmentation image.

It might be easy to get confused by the error message in this specific instance because while it is labelconvert that is raising the error, it’s actually not your own labelconvert call, but an instance of labelconvert being executed within 5ttgen freesurfer.

The origin of the error is that the input image to this command cannot be reasonably interpreted as a label image. E.g. If a voxel in your “parcellation image” contains the value 48.7, should one consider that voxel to be a member of parcel 49? Observation of such a value is actually more likely to be indicative of some upstream mistake in data processing (e.g. providing a T1-weighted image as input instead of a parcellation image); which is why the command produces an error rather than attempting to proceed.

Rob

Dear Rob,
I got this very same error and, as far as I can check, the freesurfer aparc+aseg parcellation I’m using does contain interger numbers (using mrview and clicking along the parcels).

5ttgen: [ERROR] labelconvert input.mif /home/diegolozano-soldevilla/freesurfer/FreeSurferColorLUT.txt /data/mrtrix3/share/mrtrix3/_5ttgen/FreeSurfer2ACT.txt indices.mif (freesurfer.py:64)
5ttgen: [ERROR] Information from failed command:
5ttgen:
        labelconvert: Image "input.mif" stored with floating-point type; need to check for non-integer or negative values
        labelconvert: Verifying parcellation image... [============================]
        labelconvert: [ERROR] Floating-point number detected in image "input.mif"; label images should contain integers only

In order to debug the error, do you know a mrtrix tools (or any other) that can extract all indices or metadata from freesurfer aparc+aseg parcellations in order to find those non-interger or negative values?

Thanks beforehand

1 Like

Hi Diego,

To find non-integer values in a floating-point image, I would suggest something like:

mrcalc input.mif -round input.mif -sub -datatype bit - | mrview input.mif -roi.load -

Or if you want to have the problematic voxel locations reported:

mrcalc input.mif -round input.mif -sub -datatype bit - | maskdump -

Rob

Dear Rob,
Thank you very much for your prompt reply and sorry for the delay in my response. I tried your suggestions and I could not figure out where the problem comes from. Indeed I just realized that the *.nii to *.mif file conversion creates non-interger values outside of GM. As seen in the image below, the volumetric custom schaefer parcellation yields an exact 0 while the input.mif does not (mrview interpolation is deactivated):

$ mrconvert schaefer200-17_unified_parcellation_volume.nii input.mif
$ mrview schaefer200-17_unified_parcellation_volume.nii -interpolation 0  -overlay.load input.mif -overlay.interpolation 0

What I don’t understand is that the mrcalc trick yields nothing but I guess it’s what creates the 5ttgen freesurfer error

$ mrcalc input.mif -round input.mif -sub -datatype bit - | maskdump -
mrcalc: [100%] computing: (round (input.mif) - input.mif)

At this point I guess that the question should be more along the lines of how to interface the cortical schaefer parcellation into the 5ttgen (freesurfer?) convention?. I guess I would need an equivalent of the FreeSurfer2ACT.txt file to link the Schaefer LUT file to get the indices.mif file? Any tips are more than welcome!

In anticipation, I apologize for the detour of the original question and thanks beforehand for your attention and time.

Diego

Dear Rob,
I fixed the non-interger problem! It was my bad since the schaefer200-17_unified_parcellation_volume.nii datatype was single precision: creating one with uint32 (or int32) solved the problem. As a result, the input.mif contains only interger number.
This allowed me to design the custom Schaefer200 plus 16 subcortical (Desikan) parcels mrtrix3/share/mrtrix3/_5ttgen/schaefer2162ACT.txt that looks like this:

1	Left-VisCent-ExStr-1
1	Left-VisCent-ExStr-2
1	Left-VisCent-Striate-1
1	Left-VisCent-ExStr-3
1	Left-VisCent-ExStr-4
1	Left-VisCent-ExStr-5
1	Left-VisPeri-ExStrInf-1
1	Left-VisPeri-ExStrInf-2
1	Left-VisPeri-ExStrInf-3
.
.
.
2	Left-Thalamus 
2	Left-Caudate
2	Left-Putamen
2	Left-Pallidum 
2	Left-Hippocampus
2	Left-Amygdala
2	Left-Accumbens-a
2	Left-cerebellum
2	Right-Thalamus 
2	Right-Caudate
2	Right-Putamen
2	Right-Pallidum
2	Right-Hippocampus
2	Right-Amygdala
2	Right-Accumbens-a
2	Right-cerebellum

plus the custom schaefer2016_default.txt labelconvert file that looks like this

1	Left-VisCent-ExStr-1	120	18	134	0
2	Left-VisCent-ExStr-2	120	18	136	0
3	Left-VisCent-Striate-1	120	18	137	0
4	Left-VisCent-ExStr-3	120	18	138	0
5	Left-VisCent-ExStr-4	120	18	139	0
6	Left-VisCent-ExStr-5	120	18	140	0
7	Left-VisPeri-ExStrInf-1	255	1	1	0
8	Left-VisPeri-ExStrInf-2	255	1	2	0
9	Left-VisPeri-ExStrInf-3	255	1	3	0
.
.
.
201 	Left-Thalamus 0   118 14  0
202 	Left-Caudate  122 186 220 0
203 	Left-Putamen  236 13  176 0
204 	Left-Pallidum 12  48  255 0
205 	Left-Hippocampus  220 216 20  0
206 	Left-Amygdala 103 255 255 0
207 	Left-Accumbens-a 255 165 0   0
208 	Left-cerebellum 230 148 34  0
209 	Right-Thalamus 0   118 14  0
210 	Right-Caudate 122 186 220 0
211 	Right-Putamen 236 13  176 0
212 	Right-Pallidum 13  48  255 0
213 	Right-Hippocampus 220 216 20  0
214 	Right-Amygdala 103 255 255 0
215 	Right-Accumbens-a 255 165 0   0
216 	Right-cerebellum 230 148 34  0

In order to generated the 5ttgen “schaefer2016” custom code, I did the following:

labelconvert schaefer200-17_unified_parcellation_volume.nii schaefer216_default.txt schaefer2162ACT.txt indices.mif
mrcalc indices.mif 1 -eq cgm.mif
mrcalc indices.mif 2 -eq sgm.mif

# here the hack to bypass the problem of the WM, CSF and path definition in Schaefer2016
labelconvert ../03-calc_images/aparc+aseg.nii fs_default.txt Freesurfer2ACT.txt indices2.mif
mrcalc indices2.mif 3 -eq wm.mif
mrcalc indices2.mif 4 -eq csf.mif 
mrcalc indices2.mif 5 -eq path.mif
mrcat cgm.mif sgm.mif wm.mif csf.mif path.mif - -axis 3 | mrconvert - result2.mif -datatype float32

mrinfo result2.mif 
************************************************
Image name:          "result2.mif"
************************************************
  Dimensions:        256 x 256 x 256 x 5
  Voxel size:        1 x 1 x 1 x ?
  Data strides:      [ -1 4 -3 2 ]
  Format:            MRtrix
  Data type:         32 bit float (little endian)
  Intensity scaling: offset = 0, multiplier = 1
  Transform:                    1   -0.005376   -0.001591      -126.9
                         0.005383           1    0.004516      -128.9
                         0.001566   -0.004524           1        -126
  command_history:   variable
                     mrcat cgm.mif sgm.mif wm.mif csf.mif path.mif - -axis 3  (version=3.0.2-25-g24b61f68)
                     mrconvert - result2.mif -datatype float32 -force  (version=3.0.2-25-g24b61f68)
  comments:          FreeSurfer Jan 18 2017
                     LUT: schaefer2162ACT.txt
                     LUT: FreeSurfer2ACT.txt
  mrtrix_version:    3.0.2-25-g24b61f68





The problem builds down in tckgen, which never progressed from 0% after 5 hours of computation using 128 cores:

time tckgen wmfod.mif t04_schaefer216.tck -act result2.mif -backtrack -crop_at_gmwmi \
-seed_dynamic wmfod.mif -minlength 30 -select 10M \
-mask ../03-calc_images/wmmask_1mm.nii.gz -nthreads 128 

As you can see, I combined the desikan wm.mif, csf.mif and path.mif because I currently don’t know how to fix this properly. Could you please suggest me any hints regarding this?

In anticipation, thank you very much for your attention and time!
Diego