5ttgen Freesurfer Fail

Hello experts,

I am running the 5ttgen command and getting the following error, could you please tell me what this means and how I can go about fixing it? Thanks a lot!

Akilas-MacBook-Air:SB301001 akilasekar$ 5ttgen freesurfer raparc+aseg.nii 5ttseg.mif -sgm_amyg_hipp

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: /Users/akilasekar/Desktop/SB301001/5ttgen-tmp-FJVMEW/

Command: mrconvert /Users/akilasekar/Desktop/SB301001/raparc+aseg.nii /Users/akilasekar/Desktop/SB301001/5ttgen-tmp-FJVMEW/input.mif

5ttgen: Changing to scratch directory (/Users/akilasekar/Desktop/SB301001/5ttgen-tmp-FJVMEW/)

Command: labelconvert input.mif /Applications/freesurfer/7.1.1/FreeSurferColorLUT.txt /usr/local/mrtrix3/share/mrtrix3/_5ttgen/FreeSurfer2ACT_sgm_amyg_hipp.txt indices.mif

Command: mrthreshold indices.mif - -abs 0.5 | mrgrid indices.mif crop indices_cropped.mif -mask -

5ttgen: [ERROR] mrthreshold indices.mif - -abs 0.5 | mrgrid indices.mif crop indices_cropped.mif -mask - (freesurfer.py:71)

5ttgen: [ERROR] Information from failed command:

Hi Akila,

Is that all the information provided by that command? The output of the problematic command seems to be missing, I’m wondering whether the last bits of the output were cut off?

Cheers,
Donald

Hi Donald,

Thanks for your reply! Below this error output were these two lines:

mrgrid: [ERROR] axis 0 is empty: (255:1)

5ttgen:

5ttgen: [ERROR] For debugging, inspect contents of scratch directory: /Users/akilasekar/Desktop/SB301001/5ttgen-tmp-FJVMEW/

5ttgen: Scratch directory retained; location: /Users/akilasekar/Desktop/SB301001/5ttgen-tmp-FJVMEW/

Sorry they got cut off while copy pasting!

Regards,

Akila

No worries. The error message suggests that the input.mif image contains only zeros, which I think would imply either that the parcellation image supplied is empty (i.e. raparc+aseg.nii is empty – contains zero values only), or that the parcellation image uses a different labelling scheme than expected in the FreeSurferColourLUT, such that none of the indices in the parcellation can be mapped onto indices post labelconvert.

I’m not sure why either of these things would happen, but the first thing is to double-check that your raparc+aseg.nii image is OK. For instance, what does mrstats raparc+aseg.nii report? What does mrinfo raparc+aseg.nii report?

Hi Donald,

Thanks for the help!

This is the information I got:
Akilas-MacBook-Air:SB301001 akilasekar$ mrstats raparc+aseg.nii
volume mean median std min max count
[ 0 ] 0 0 0 0 0 5242880
Akilas-MacBook-Air:SB301001 akilasekar$ mrinfo raparc+aseg.nii


Image name: “raparc+aseg.nii”


Dimensions: 256 x 256 x 80
Voxel size: 0.9063 x 0.9063 x 2
Data strides: [ -1 2 3 ]
Format: NIfTI-1.1
Data type: signed 32 bit integer (big endian)
Intensity scaling: offset = 0, multiplier = 1
Transform: 1 0 0 -118.1
-0 1 0 -87.65
-0 0 1 -86.01
comments: spm - realigned

I used SPM to co-register the structural data and cerebellar ROIs into diffusion space, is this possible that something went wrong there?

Thanks!

Ok, clearly the input image contains zeros only, so that explains the failure. As to why that parcellation image contains no information in the first place, I don’t know… We’d need to see exactly what steps you took to produce it. Can you post the exact commands that went into creating your raparc+aseg.nii file?

  1. I pre-processed the structural and dwi images using Freesurfer (recon all) and mrtrix (dwipreproc, de-noising, B1 field inhomogeneity correction) - from which I got the aprac+aseg
  2. I isolated my ROIs from Freesurfer: Akilas-MacBook-Air:SB301001 akilasekar$ isolate_labels.csh --vol aparc+aseg.mgz --outprefix aparc+aseg_labels --L $label 47
  3. SPM for Co-registration using the images from screenshot 1 and I got the following results in screenshot 2

Thanks a lot for your help!

Regards,
Akila

OK, just a couple of thoughts on this:

  • I don’t anticipate using the parcellation as one the images in the registration will work very well, even with mutual information. I think you’d be better off using the original T1 – assuming it’s aligned with the parcellation itself.

  • it looks like you’d be regridding the parcellation image onto the DWI image using cubic splines. That’s not a good idea for two reasons: (i) you’re loosing resolution when you don’t need to, it’s perfectly fine (indeed, recommended) for the 5TT image to remain at the native T1 resolution; and (ii) if you use anything other than nearest-neighbour interpolation, the output values won’t correspond to the original (integer) labels anymore.

So I recommend re-thinking the coregistration approach here…

1 Like

Hi Donald,

Thanks a lot for your inputs, I slightly modified the approach and got the following stats:

Akilas-MacBook-Air:B301001 akilasekar$ mrstats raparc+aseg.nii 
      volume       mean     median        std        min        max      count
       [ 0 ]    73.2576          0    339.454          0       2035    5242880
Akilas-MacBook-Air:B301001 akilasekar$

This is correct?

Thanks!

Regards,
Akila

Well, it certainly looks more promising, in that there are non-zero values in there! The max value is more in line with what I’d expect as well. But it’s impossible to tell whether this is correct solely on the basis of what you’re showing here… It depends what steps you took – I’d be looking for using the T1 as the source image, applying the transformation to the aparc+aseg image, without regridding / reslicing. I can’t remember exactly what that looks like in SPM though…

Hi Donald,

Thanks for your help! I tried doing the 5ttgen command on an isolated ROI from FreeSurfer and I got the following stats but the same error message:

Akilas-MacBook-Air:Desktop akilasekar$ mrstats raparc+aseg_labels_label7.nii
volume mean median std min max count
[ 0 ] 0.0012043 0 0.0346821 0 1 5242880

Akilas-MacBook-Air:Desktop akilasekar$ 5ttgen freesurfer raparc+aseg_labels_label7.nii 5ttseg_label7.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: /Users/akilasekar/Desktop/5ttgen-tmp-UB30QR/

Command: mrconvert /Users/akilasekar/Desktop/raparc+aseg_labels_label7.nii /Users/akilasekar/Desktop/5ttgen-tmp-UB30QR/input.mif

5ttgen: Changing to scratch directory (/Users/akilasekar/Desktop/5ttgen-tmp-UB30QR/)

Command: labelconvert input.mif /Applications/freesurfer/7.1.1/FreeSurferColorLUT.txt /usr/local/mrtrix3/share/mrtrix3/_5ttgen/FreeSurfer2ACT.txt indices.mif

Command: mrthreshold indices.mif - -abs 0.5 | mrgrid indices.mif crop indices_cropped.mif -mask -

5ttgen: [ERROR] mrthreshold indices.mif - -abs 0.5 | mrgrid indices.mif crop indices_cropped.mif -mask - (freesurfer.py:71)

5ttgen: [ERROR] Information from failed command:

5ttgen:

mrgrid: [ERROR] axis 0 is empty: (255:1)

5ttgen:

5ttgen: [ERROR] For debugging, inspect contents of scratch directory: /Users/akilasekar/Desktop/5ttgen-tmp-UB30QR/

5ttgen: Scratch directory retained; location: /Users/akilasekar/Desktop/5ttgen-tmp-UB30QR/

I also wanted to know for region specific tractography do you run the 5ttgen command on individual ROIs or the whole brain?

Thanks!

OK, I’m pretty sure you don’t want to feed individually extracted nodes to 5ttgen – that’s not how it works. I expect you need to give it the original aparc+aseg FreeSurfer output as-is, and it’ll work out what’s white matter / gray matter / etc from that.

If you need to extract individual nodes, you can do that as you seem to have done already, and you can use that as an ROI in the tckgen call directly – but you can’t generate the 5TT image from that. Remember that the 5TT image is used for anatomically-constrained tractography – have a read of the original paper if you’re not sure what I mean here.

Hi Donald,

Thats super helpful! Thanks a lot.

One last question could you give me an example command for the tckgen call specifically for an ROI? I am going to be using the following script for ROI specific tractography is this about right:

tckgen -seed_gmwmi 5tt_mask.mif -act 5ttseg.mif -crop_at_gmwmi -seeds 1000000 fod.mif wholebrain.tck -force

tcksift wholebrain.tck fod.mif sift1_wholebrain.tck

tcksift2 wholebrain.tck fod.mif wholebrain_sift2_weights.txt

tckstat

tcksample

Thanks a lot!

Akila

Ok, a few comments:

  • if you’re going to apply SIFT or SIFT2, you need to perform whole-brain tractography. If you need to subsequently extract specific bundles based on ROIs, use the tckedit command on the whole-brain tractogram.

  • You should use either tcksift or tcksift2 – but not both! Personally, I would recommend tcksift2 in pretty much all circumstances (only exception currently is for the whole-brain template tractogram in the FBA pipeline, but that might also change in the not too distant future).

  • I’m not sure what your intention is regarding the tckstat and tcksample commands, but I would recommend you look at the options for tck2connectome, in case what you need to do is actually better done within the context of that command.

Regarding your tckgen call, the main question mark is where that 5tt_mask.nii comes from, but assuming that one checks out, I think it looks OK.

By the way, did you know you can write -seeds 1m instead of -seeds 1000000…? :wink:

By the way, did you know you can write -seeds 1m instead of -select 1000000 …? :wink:

Correction: You can write -seeds 1m instead of -seeds 1000000.
-seeds and -select do two different things… :grimacing: