5ttgen - run first all error

Hi all,

I have recently started to work on MRtrix and I am getting the error below when I try to run 5ttgen fsl T1.mif 5tt_nocoreg.mif. I checked previous posts and errors, I have all standard files error and my error files in first.logs folder are empty. So I am not sure what causes the error, I would appreciate any help or suggestions a lot :four_leaf_clover:

Command:  standard_space_roi T1.nii T1_preBET.nii.gz -maskMASK mni_mask.nii -roiFOV
Command:  bet T1_preBET.nii.gz T1_BET.nii.gz -f 0.15 -R
Command:  fast T1_BET.nii.gz
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 -o first
5ttgen: [ERROR] FSL FIRST has failed; only 0 of 10 structures were segmented successfully (check /cubric/data/c1958866/Diff_proc/update/sub_03_volumes/5ttgen-tmp-DU4LWC/first.logs)

Many thanks in advance!

Welcome Ozge!

In the absence of any information at all in log files, I’m really limited in capacity to diagnose…

  1. The first barrier is the fact that it’s an FSL command that is (supposedly) failing. It happens to be being invoked from within an MRtrix3 wrapper, so the first diagnosis step is to separate the two. Take an image for which executing run_first_all should be possible, isolate it from any and all references to MRtrix3, and execute run_first_all as a standalone command.

  2. run_first_all is being executed on the input T1-weighted image. I know that T1-weighted images that include a lot of spinal column can be problematic for FSL’s bet tool; that’s why the standard_space_roi command is called beforehand. So you could try executing run_first_all on image T1_preBET.nii.gz instead? The other alternative is to run it on image T1_BET.nii.gz, and provide the -b option to run_first_all.

  3. Also, if you’re providing 5ttgen fsl with an image that has already been skull-stripped, but are not specifying the -premasked option, that could conceivably lead to issues here (and the results of bet would likely look pretty ordinary in this case also).

Good luck!

Hi @rsmith,

Many thanks for your reply. I guess it was due to FSL command failing, I used an in-house MATLAB implementation including the analysis and it is working alright. I still tried the options you provided but run_first_all did not work individually. I will update if I can achieve to run 5ttgen fsl by itself later. However, it is all good for me now and thanks a lot for your time and response!

Hi @ozgezer,

I came across the same problem as you.

I ran run_first_all individually as suggested by Rob and found that /usr/local/fsl/bin/fsl_sub was missing. No idea how this happened as I did a clean fsl installation sometime in late 2021 (ie version 6).

I managed to get it working by reinstalling fsl. I am posting this so that others who have a similar problem can benefit from this.

1 Like

Hi @brc0520,

Thanks for letting me know, I will give it a look around and see whether it can be solved with reinstalling.

Much appreciated!

Dear all,

Warm greetings. I had a similar error running the “5ttgen" command. In my case, only 6 of the 10 structures were segmented successfully. I have attached a snapshot of the error.

I have some information in the log file, but i don’t really know how to diagnose what the problem may be.

Thanks so much for your prompt response.

Hello @Joanne ,

To diagnose, as @rsmith indicated, it is best to try and run the run_first_all command directly on your T1 image, with the -d flag. These will keep all intermittent output for you to visualize and see at which stage processing fails for each of these structures. You can then try different fixes and when you have the desired output, you can include this in the 5TT image using the 5ttedit -sgm option.

Important checks and possible fixes include:

  1. Check orientation of the image - FSL commands often fail if you don’t reorient to MNI152 orientation, so run fslreorient2std on your T1 and use that as input instead.
  2. Check whether using the whole-head T1 instead of the skull-extracted image works. run_first_all generally prefers having the whole head.
  3. Check the registration to MNI template (*_to_std_sub.nii.gz) - if poor, you can register this yourself with flirt and pass the correct transformation to run_first_all using the -a flag
  4. If none of these are the problem, and it still doesn’t work, you could try running the first four steps of FreeSurfer recon-all (upto intensity normalization) and try with the norm.mgz as input to run_first_all (after converting to nii.gz)

Hope this helps,


Thanks for your detailed response Nick, i really do appreciate it.

I’ll revisit it accordingly and go through the important checks.

Kind regards,

1 Like