# 5ttgen

**URL:** https://community.mrtrix.org/t/5ttgen/133
**Category:** Uncategorized
**Created:** [March 28, 2016, 9:28am UTC](https://community.mrtrix.org/t/5ttgen/133 "2016-03-28T09:28:30Z")
**Posts on this page:** 16
**Page:** 2

<div class="post-metadata">

### Author: ![Antonin\_Skoch](https://community.mrtrix.org/user_avatar/community.mrtrix.org/antonin_skoch/32/358_2.png) [@Antonin\_Skoch](https://community.mrtrix.org/u/Antonin_Skoch)
#### Post date: [April 15, 2017, 10:03am UTC](https://community.mrtrix.org/t/5ttgen/133/21 "2017-04-15T10:03:48Z")

</div>

Dear @chunhungyeh,

it depends on type of installation:

[https://www.jiscmail.ac.uk/cgi-bin/webadmin?A2=ind1508&L=FSL&P=R92607&1=FSL&9=A&J=on&d=No+Match%3BMatch%3BMatches&z=4](https://www.jiscmail.ac.uk/cgi-bin/webadmin?A2=ind1508&L=FSL&P=R92607&1=FSL&9=A&J=on&d=No+Match%3BMatch%3BMatches&z=4)

[http://neuro.debian.net/debian/extracts/fsl/README.Debian](http://neuro.debian.net/debian/extracts/fsl/README.Debian)

See the relevant code of `fsl_sub` of my Debian package 5.0.9 version of `fsl_sub`:

```
# Allow to override the above automatic detection result with FSLPARALLEL
if [-n "$FSLPARALLEL"] ; then
    # Whenever FSLPARALLEL is set enfore using SGE even if no SGE_ROOT is set
    # which, for example, is the case on Debian systems running SGE
    METHOD=SGE
    # TODO: move cluster engine detection here to be able to support more than
    # just SGE
    if ["$FSLPARALLEL" = "condor"] ; then
        # if condor shall be used, simply switch to Condor's qsub emulation
        qsub_cmd="condor_qsub"
    fi
else
    METHOD=NONE
fi

```

Therefore, even unsetting `SGE_ROOT` would not work in this case when global variable `FSLPARALLEL` is set. Conversely, when FSLPARALLEL is not set, none of the FSL jobs gets submitted to gridengine. Therefore, `FSLPARALLEL` is the primary variable controlling gridengine submission in FSL in 5.0.9 version installed as Debian package.

---

<div class="post-metadata">

### Author: ![chunhungyeh](https://community.mrtrix.org/user_avatar/community.mrtrix.org/chunhungyeh/32/4570_2.png) [@chunhungyeh](https://community.mrtrix.org/u/chunhungyeh)
#### Post date: [April 15, 2017, 11:21pm UTC](https://community.mrtrix.org/t/5ttgen/133/22 "2017-04-15T23:21:26Z")

</div>

Hi @Antonin_Skoch,

Ah ok, so the code of `fsl_sub` is different from my FSL 5.0.9 installed via FSL’s install script:

```auto
###########################################################################
# The following section determines what to do when fsl_sub is called
# by an FSL program. If SGE_ROOT is set it will attempt to pass the
# commands onto the cluster, otherwise it will run the commands
# itself. There are two values for the METHOD variable, "SGE" and
# "NONE". Note that a user can unset SGE_ROOT if they don't want the
# cluster to be used.
###########################################################################
METHOD=SGE
unset module
if ["x$SGE_ROOT" = "x"] ; then
	METHOD=NONE
else
	QCONF=`which qconf`
	if ["x$QCONF" = "x"]; then
		METHOD=NONE
		echo "Warning: SGE_ROOT environment variable is set but Grid Engine software not found, will run locally" >&2
	fi
fi

```

I was not aware of such installation dependency (thanks for the information). I think @rsmith may have figured out a solution to deal with the problem more fundamentally, so that we do not need to unset any environment variable before running `5ttgen` in the next major update of MRtrix3.

Cheers.

---

<div class="post-metadata">

### Author: ![Carlos\_Gutierrez](https://community.mrtrix.org/letter_avatar_proxy/v4/letter/c/ad7895/32.png) [@Carlos\_Gutierrez](https://community.mrtrix.org/u/Carlos_Gutierrez)
#### Post date: [April 16, 2017, 2:15pm UTC](https://community.mrtrix.org/t/5ttgen/133/23 "2017-04-16T14:15:33Z")

</div>

Regrettably, none of them worked. I unset them, but I still getting the same error. Wondering whether is there a problem in my data.

Carloss-MacBook-Pro:mrtrix\_test carlosengutierrez$ echo $SGE\_ROOT

Carloss-MacBook-Pro:mrtrix\_test carlosengutierrez$ echo $FSLPARALLEL

Carloss-MacBook-Pro:mrtrix\_test carlosengutierrez$ 5ttgen fsl 8.mif 5tt.mif -nocleanup  
5ttgen:  
5ttgen: 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.  
5ttgen:  
5ttgen: Generated temporary directory: /tmp/5ttgen-tmp-CNSPG0/  
Command: mrconvert /Users/carlosengutierrez/datathon/mrtrix\_test/8.mif /tmp/5ttgen-tmp-CNSPG0/input.mif  
5ttgen: Changing to temporary directory (/tmp/5ttgen-tmp-CNSPG0/)  
Command: mrconvert input.mif T1.nii -stride -1,+2,+3  
Command: maskfilter /usr/local/fsl/data/standard/MNI152\_T1\_1mm\_brain\_mask\_dil.nii.gz dilate mni\_mask.nii -npass 4  
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 -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] Missing .vtk file for structure L\_Accu; run\_first\_all must have failed  
5ttgen: Changing back to original directory (/Users/carlosengutierrez/datathon/mrtrix\_test)  
5ttgen: Contents of temporary directory kept, location: /tmp/5ttgen-tmp-CNSPG0/

Carloss-MacBook-Pro:mrtrix\_test carlosengutierrez$ mrinfo 8.mif

* * *

Image: “8.mif”

* * *

Dimensions: 256 x 80 x 320  
Voxel size: 1.5 x 3 x 1.5  
Data strides: [1 3 -2]  
Format: MRtrix  
Data type: signed 16 bit integer (little endian)  
Intensity scaling: offset = 0, multiplier = 7.5575500000000002e-06  
Transform: 0.9999 0.002821 -0.01607 -234.9  
-0.003831 0.998 -0.06319 -93.06  
0.01585 0.06324 0.9979 -292.5  
comments: 15\_HighRes\_MP\_RAGE\_150um  
mrtrix\_version: 005da18a

---

<div class="post-metadata">

### Author: ![Antonin\_Skoch](https://community.mrtrix.org/user_avatar/community.mrtrix.org/antonin_skoch/32/358_2.png) [@Antonin\_Skoch](https://community.mrtrix.org/u/Antonin_Skoch)
#### Post date: [April 16, 2017, 3:14pm UTC](https://community.mrtrix.org/t/5ttgen/133/24 "2017-04-16T15:14:18Z")

</div>

I see that there is no number after run\_first\_all invocation in your terminal output, therefore I would suspect that it is not a gridengine issue.

I would suggest to `run run_first_all` command manually and see what the command line output is.

---

<div class="post-metadata">

### Author: ![Carlos\_Gutierrez](https://community.mrtrix.org/letter_avatar_proxy/v4/letter/c/ad7895/32.png) [@Carlos\_Gutierrez](https://community.mrtrix.org/u/Carlos_Gutierrez)
#### Post date: [April 17, 2017, 4:25am UTC](https://community.mrtrix.org/t/5ttgen/133/25 "2017-04-17T04:25:48Z")

</div>

Thank you for your answers. I found out that some structures and files are not being created, when `fslmerge` tries to merge the segmentation the error shows up. I run `cat *.logs/*.e*` command and it shows:

a) I think this error is a problem in my T1.nii original data

WARNING: NO INTERIOR VOXELS TO ESTIMATE MODE  
vector::\_M\_range\_check  
Cannot open volume first-L\_Accu\_corr for reading!  
Cannot open volume first-L\_Accu\_first for reading!

b) I removed L\_Accu when running `run_first_all`, however I got a problem in new structures, for the case of the \_corr files, \_first.nii.gz and \_first.vtk are created, but not \_corr.nii.gz :

Image Exception : #22 :: ERROR: Could not open image first-L\_Pall\_corr  
Image Exception : #22 :: ERROR: Could not open image first\_all\_none\_firstseg  
ERROR: Could not open image first-L\_Puta\_corr

Thanks for your help.

---

<div class="post-metadata">

### Author: ![Antonin\_Skoch](https://community.mrtrix.org/user_avatar/community.mrtrix.org/antonin_skoch/32/358_2.png) [@Antonin\_Skoch](https://community.mrtrix.org/u/Antonin_Skoch)
#### Post date: [April 17, 2017, 11:41am UTC](https://community.mrtrix.org/t/5ttgen/133/26 "2017-04-17T11:41:15Z")

</div>

OK, so this is issue with FIRST itself. I think that you can get better support using FSL mailing list in this case.

My suggestion would be to troubleshoot FIRST, mainly to check the image registration:

[https://fsl.fmrib.ox.ac.uk/fsl/fslwiki/FIRST/UserGuide#Registration](https://fsl.fmrib.ox.ac.uk/fsl/fslwiki/FIRST/UserGuide#Registration)

And I will try to verify validity of the files which have been created:  
What the \_first.nii.gz files look like? Are they valid binary masks?  
What the \_first.vtk files look like?

Antonin

---

<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 22, 2017, 6:36am UTC](https://community.mrtrix.org/t/5ttgen/133/27 "2017-04-22T06:36:24Z")

</div>

> I think @rsmith may have figured out a solution to deal with the problem more fundamentally, so that we do not need to unset any environment variable before running 5ttgen in the next major update of _MRtrix3_.

For the sake of completeness, since it was mentioned here (but wasn’t actually the problem):

What I’ve tried to do in the update is provide a Python library function that will _wait_ until a particular file is both present, and has no other process writing to it. Therefore, rather than trying to disable SGE, `run_first_all` will instead be free to make use of SGE, and `5ttgen` will simply wait until `run_first_all`’s outputs have been produced. Fingers crossed…

---

<div class="post-metadata">

### Author: ![aszymanski](https://community.mrtrix.org/letter_avatar_proxy/v4/letter/a/e36b37/32.png) [@aszymanski](https://community.mrtrix.org/u/aszymanski)
#### Post date: [May 18, 2017, 3:11pm UTC](https://community.mrtrix.org/t/5ttgen/133/28 "2017-05-18T15:11:02Z")

</div>

Hello,

I’m curious if someone could help me with an issue I’m having with 5ttgen, which seems to be related to this topic. It has been stuck at

```auto

```

for nearly an entire day. What’s curious is that this doesn’t always happen, and all 5ttgen files will be created when it does work. The only difference between it not working right now vs times it has worked is that I did a more thorough skullstripping of the T1 before doing a rigid-body registration to the diffusion series. I can’t imagine this would have any impact, but for the sake of providing information, that is the only difference I can think of.

Any idea as to why it’s taking so long/not working?

Thank you 🙂

---

<div class="post-metadata">

### Author: ![Antonin\_Skoch](https://community.mrtrix.org/user_avatar/community.mrtrix.org/antonin_skoch/32/358_2.png) [@Antonin\_Skoch](https://community.mrtrix.org/u/Antonin_Skoch)
#### Post date: [May 19, 2017, 5:03am UTC](https://community.mrtrix.org/t/5ttgen/133/29 "2017-05-19T05:03:42Z")

</div>

Dear @aszymanski,

I would suspect that for some reason your particular instance of `first` either did not yet finish or exited with error. I would suggest to go to temporary directory of `first` and inspect logs, as in [quote=“Carlos\_Gutierrez, post:25, topic:133”]  
I run cat _.logs/_.e\* command  
[/quote]  
which could help you to diagnose the reason.

Antonin

---

<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: [May 19, 2017, 10:54am UTC](https://community.mrtrix.org/t/5ttgen/133/30 "2017-05-19T10:54:48Z")

</div>

Oh noes, not again! 😒

That message you quoted relates to changes I made in version `3.0_RC1` that aim to permit FSL’s `run_first_all` script to use Sun Grid Engine (SGE), since that’s the capability that has seemingly caused the greatest amount of grievance with `5ttgen fsl`.

Unfortunately it also makes it quite tricky to detect errors: `run_first_all` may exit “successfully” once the relevant jobs have been submitted to SGE, but `5ttgen fsl` needs to wait until the files created by `run_first_all` actually appear; alternatively, `run_first_all` may fail for some other reason, will still return “successfully”, but those files will never appear.

As suggested by @Antonin_Skoch, the FIRST logs will hopefully give some indication - the terminal output of `5ttgen fsl` should tell you where the script temporary directory was created, and the FIRST directory resides within that. Letting us know whether or not your system is using SGE (`echo $SGE_ROOT`) would also help.

* * *

As an aside: Something I’ve considered trying recently is calling [`fsl_anat`](https://fsl.fmrib.ox.ac.uk/fsl/fslwiki/fsl_anat) from within `5ttgen fsl` and manipulating its output, rather than executing the FSL command stages manually myself with a bit of bastardization in between. If anybody has any thoughts or experiences on this, do let me know.

Rob

---

<div class="post-metadata">

### Author: ![aszymanski](https://community.mrtrix.org/letter_avatar_proxy/v4/letter/a/e36b37/32.png) [@aszymanski](https://community.mrtrix.org/u/aszymanski)
#### Post date: [May 23, 2017, 3:13pm UTC](https://community.mrtrix.org/t/5ttgen/133/31 "2017-05-23T15:13:14Z")

</div>

Hello,

So I ran cat \* . logs/_.e_ within one of the 5ttgen tmp directories, which gave me this output:

````auto
[USER 5ttgen-tmp-8WWY88]$ cat *.logs/*.e*
WARNING: NO INTERIOR VOXELS TO ESTIMATE MODE
vector::_M_range_check
vector::_M_range_check
Image Exception : #22 :: ERROR: Could not open image first-R_Accu_corr
terminate called after throwing an instance of 'RBD_COMMON::BaseException'
/bin/sh: line 1: 6404 Aborted /usr/local/packages/fsl-5.0.1/bin/fslmerge -t first_all_none_firstseg first-L_Accu_corr first-R_Accu_corr first-L_Caud_corr first-R_Caud_corr first-L_Pall_corr first-R_Pall_corr first-L_Puta_corr first-R_Puta_corr first-L_Thal_corr first-R_Thal_corr
Image Exception : #22 :: ERROR: Could not open image first-R_Accu_first
terminate called after throwing an instance of 'RBD_COMMON::BaseException'
/bin/sh: line 1: 6405 Aborted /usr/local/packages/fsl-5.0.1/bin/fslmerge -t first_all_none_origsegs first-L_Accu_first first-R_Accu_first first-L_Caud_first first-R_Caud_first first-L_Pall_first first-R_Pall_first first-L_Puta_first first-R_Puta_first first-L_Thal_first first-R_Thal_first
Image Exception : #22 :: ERROR: Could not open image first_all_none_origsegs
Aborted
```

And yes, the cluster I am using to execute these commands is using SGE. 

We are really interested in obtaining the 5ttgen images because we are interested in comparing CSF & WM segmentation between 5ttgen & dhollander, so getting 5ttgen working would be wonderful.

Please let me know if there is any more information I can provide. I really appreciate the help :relaxed:
````

---

<div class="post-metadata">

### Author: ![Antonin\_Skoch](https://community.mrtrix.org/user_avatar/community.mrtrix.org/antonin_skoch/32/358_2.png) [@Antonin\_Skoch](https://community.mrtrix.org/u/Antonin_Skoch)
#### Post date: [May 25, 2017, 8:10am UTC](https://community.mrtrix.org/t/5ttgen/133/32 "2017-05-25T08:10:15Z")

</div>

Dear @aszymanski,

so the problem is, that that FIRST itself exited with error.

You could probably get more expert advice to this issue on mailing list dedicated to FIRST, which is FSL list. There are several threads on FSL list discussing reason of NO INTERIOR VOXELS TO ESTIMATE MODE error. Quick looking at them the advices were to inspect the registration and check your image voxel size.

[https://www.jiscmail.ac.uk/cgi-bin/webadmin?A2=ind1007&L=FSL&D=0&1=FSL&9=A&J=on&d=No+Match%3BMatch%3BMatches&z=4&P=147217](https://www.jiscmail.ac.uk/cgi-bin/webadmin?A2=ind1007&L=FSL&D=0&1=FSL&9=A&J=on&d=No+Match%3BMatch%3BMatches&z=4&P=147217)

[https://www.jiscmail.ac.uk/cgi-bin/webadmin?A2=ind1612&L=FSL&P=R69047&1=FSL&9=A&J=on&d=No+Match%3BMatch%3BMatches&z=4](https://www.jiscmail.ac.uk/cgi-bin/webadmin?A2=ind1612&L=FSL&P=R69047&1=FSL&9=A&J=on&d=No+Match%3BMatch%3BMatches&z=4)

See also  
[https://fsl.fmrib.ox.ac.uk/fsl/fslwiki/FIRST/UserGuide#General\_Advice\_and\_Workflow](https://fsl.fmrib.ox.ac.uk/fsl/fslwiki/FIRST/UserGuide#General_Advice_and_Workflow)

I would also suggest to check the skullstrip.

Regards,

Antonin

---

<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: [June 5, 2017, 5:40am UTC](https://community.mrtrix.org/t/5ttgen/133/33 "2017-06-05T05:40:11Z")

</div>

@aszymanski: If you can consistently reproduce that fault with your image(s), could you do me a favour and try running the original T1 through the `fsl_anat` script? If there’s some aspect of the image processing within that script that helps to prevent such errors from occurring during the `run_first_all` step, that would give me direction in which to try solutions for `5ttgen`.

---

<div class="post-metadata">

### Author: ![aszymanski](https://community.mrtrix.org/letter_avatar_proxy/v4/letter/a/e36b37/32.png) [@aszymanski](https://community.mrtrix.org/u/aszymanski)
#### Post date: [June 5, 2017, 5:45pm UTC](https://community.mrtrix.org/t/5ttgen/133/34 "2017-06-05T17:45:21Z")

</div>

Hey @rsmith,

I just reran a subject’s T1 using `fsl_anat` and I still got

`````auto
terminate called after throwing an instance of 'RBD_COMMON::BaseException'
/usr/local/packages/fsl-5.0.1/bin/fsl_anat: line 152: 16220 Aborted $@```` :frowning:

Does this help you at all?
`````

---

<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: [June 5, 2017, 11:45pm UTC](https://community.mrtrix.org/t/5ttgen/133/35 "2017-06-05T23:45:18Z")

</div>

In a way: It lets me know that if I were to modify `5ttgen fsl` to use the `fsl_anat` script instead of calling the individual FSL commands, it _wouldn’t_ alleviate the `run_first_all` issue completely. Having said that, I’d be more confident in that conclusion if the image were tested against an up-to-date FSL. Any chance of sharing that particular subject image with me?

---

<div class="post-metadata">

### Author: ![aszymanski](https://community.mrtrix.org/letter_avatar_proxy/v4/letter/a/e36b37/32.png) [@aszymanski](https://community.mrtrix.org/u/aszymanski)
#### Post date: [June 6, 2017, 2:24pm UTC](https://community.mrtrix.org/t/5ttgen/133/36 "2017-06-06T14:24:29Z")

</div>

Sure! Let me just get rid of some identifiers and I can send it your way. How would you like me to send it?

[Previous page](https://community.mrtrix.org/t/5ttgen/133.md?page=1)
