5ttgen freesurfer output not usable

I checked a lot and did not find any response, I hope you did not answer this question before.
I used the normal downloaded Mrtrix for all preprocessings, and I installed the Version 3Tissue_v5.2.8-2 to use the ss3t_csd_beta1 function. It seems to work well.
But after I used the 5ttgen with freesurfer option on a t1 image. I have no error message. But with the Version 3Tissue_v5.2.8-2 I obtained like points everywhere in the brain for the 5 volumes instead of the 5 categories volumes. So I force the script to use the 5ttgen from the old version of Mrtrix (as for the preprocessings). I worked, no errors and looks nice, when I opened it with fsleyes.
But, when I want to use this image for the next steps (5tt2gmwmi or tckgen with -act 5ttgenoutput) I have this error:
terminate called after throwing an instance of ‘std::bad_alloc’
what(): std::bad_alloc

If I use tckgen without the 5ttgen output it works. If I want to open the 5ttgenoutput with mrview it failed with the same error as before:
terminate called after throwing an instance of ‘std::bad_alloc’
what(): std::bad_alloc
Abandon (core dumped)

if I want to convert the 5ttgen output with mri_convert to have a nii.gz image, I have this error:
Cannot allocate memory
error: znzTAGskip: tag=-2, failed to calloc 9 bytes!

so for me it is a problem with the 5ttgen output, but I have no more idea to fix that. Could you help me?

have a nice day,

all the best and thank you,

Hi Caroline,

Unfortunately, we don’t provide support for this version, as stated in this post. However, if you can install the latest release version of MRtrix3 and reproduce the error, we’ll be more than happy to take a look and try to figure it out :+1:


Hi Donald,

thank you for your quick answer!
I used the latest version of Mrtrix for all preprocessings, I will then remove the Version 3Tissue_v5.2.8-2 to perform the 5ttgen, there is may be a conflict somewhere (I used the path from the last version- not the fork one - to perform the 5ttgen function).
Have a nice day and thank you,


Hi Caroline,

It looks like you have encountered an issue that I found myself and that has been addressed on the MRtrix3 master branch, but that has not yet been incorporated into a tagged MRtrix3 update.

However if I’m correct about that, then you should in fact be able to proceed without making any modification to your installed software. All you have to do is not write any image in MGH or MGZ format using any MRtrix3 command. As long as you only use MGH / MGZ images generated by FreeSurfer as image inputs, and anything being generated by MRtrix3 uses some other image format as output, you should be OK.


Hi Rob,

thank you very much for your answer! That comforts me in the procedure I followed. Well, I found the same idea to fix the problem. I kept the results.mif (nice results, everything correct) by using the -nocleanup option for 5ttgen, and it worked! So, I used this results.mif for the following steps instead of the .mgz output.

Have a nice day,

all the best,