# 5ttgen - run first all error

**URL:** <https://community.mrtrix.org/t/5ttgen-run-first-all-error/5736>\
**Category:** Uncategorized\
**Created:** [April 27, 2022, 1:39pm UTC](https://community.mrtrix.org/t/5ttgen-run-first-all-error/5736 "2022-04-27T13:39:49Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ozgezer](https://community.mrtrix.org/user_avatar/community.mrtrix.org/ozgezer/32/4008_2.png) [@ozgezer](https://community.mrtrix.org/u/ozgezer)\
**Post date:** [April 27, 2022, 1:39pm UTC](https://community.mrtrix.org/t/5ttgen-run-first-all-error/5736/1 "2022-04-27T13:39:50Z")

</div>

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](https://community.mrtrix.org/t/5ttgen-fsl-error-only-0-of-10-structures-were-segmented-successfully/1448) 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 🍀

```auto
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!

---

<div class="post-metadata">

**Author:** ![rsmith](https://community.mrtrix.org/user_avatar/community.mrtrix.org/rsmith/32/2672_2.png) [@rsmith](https://community.mrtrix.org/u/rsmith)\
**Post date:** [April 29, 2022, 6:58am UTC](https://community.mrtrix.org/t/5ttgen-run-first-all-error/5736/2 "2022-04-29T06:58:33Z")

</div>

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!  
Rob

---

<div class="post-metadata">

**Author:** ![ozgezer](https://community.mrtrix.org/user_avatar/community.mrtrix.org/ozgezer/32/4008_2.png) [@ozgezer](https://community.mrtrix.org/u/ozgezer)\
**Post date:** [April 29, 2022, 11:01am UTC](https://community.mrtrix.org/t/5ttgen-run-first-all-error/5736/3 "2022-04-29T11:01:48Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![brc0520](https://community.mrtrix.org/user_avatar/community.mrtrix.org/brc0520/32/3908_2.png) [@brc0520](https://community.mrtrix.org/u/brc0520)\
**Post date:** [June 16, 2022, 7:02am UTC](https://community.mrtrix.org/t/5ttgen-run-first-all-error/5736/4 "2022-06-16T07:02:20Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ozgezer](https://community.mrtrix.org/user_avatar/community.mrtrix.org/ozgezer/32/4008_2.png) [@ozgezer](https://community.mrtrix.org/u/ozgezer)\
**Post date:** [June 17, 2022, 1:14pm UTC](https://community.mrtrix.org/t/5ttgen-run-first-all-error/5736/5 "2022-06-17T13:14:32Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![Joanne](https://community.mrtrix.org/user_avatar/community.mrtrix.org/joanne/32/3677_2.png) [@Joanne](https://community.mrtrix.org/u/Joanne)\
**Post date:** [August 27, 2022, 2:30am UTC](https://community.mrtrix.org/t/5ttgen-run-first-all-error/5736/6 "2022-08-27T02:30:08Z")

</div>

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.  
Joan.

 ![image](https://community.mrtrix.org/uploads/default/original/2X/4/476aef862f6f7246a954ae43d4463466b81603d5.jpeg)

---

<div class="post-metadata">

**Author:** ![NicDC](https://community.mrtrix.org/user_avatar/community.mrtrix.org/nicdc/32/1779_2.png) [@NicDC](https://community.mrtrix.org/u/NicDC)\
**Post date:** [September 6, 2022, 8:34am UTC](https://community.mrtrix.org/t/5ttgen-run-first-all-error/5736/7 "2022-09-06T08:34:35Z")

</div>

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,  
Nick

---

<div class="post-metadata">

**Author:** ![Joanne](https://community.mrtrix.org/user_avatar/community.mrtrix.org/joanne/32/3677_2.png) [@Joanne](https://community.mrtrix.org/u/Joanne)\
**Post date:** [September 7, 2022, 11:23am UTC](https://community.mrtrix.org/t/5ttgen-run-first-all-error/5736/8 "2022-09-07T11:23:47Z")

</div>

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

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

Kind regards,  
Joan
