# Error in "5ttgen fsl T1w\_acpc\_dc\_restore\_brain.nii.gz 5TT.mif -premasked"

**URL:** <https://community.mrtrix.org/t/error-in-5ttgen-fsl-t1w-acpc-dc-restore-brain-nii-gz-5tt-mif-premasked/273>\
**Category:** Uncategorized\
**Created:** [June 3, 2016, 1:21pm UTC](https://community.mrtrix.org/t/error-in-5ttgen-fsl-t1w-acpc-dc-restore-brain-nii-gz-5tt-mif-premasked/273 "2016-06-03T13:21:28Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sarbani](https://community.mrtrix.org/letter_avatar_proxy/v4/letter/s/a3d4f5/32.png) [@Sarbani](https://community.mrtrix.org/u/Sarbani)\
**Post date:** [June 3, 2016, 1:21pm UTC](https://community.mrtrix.org/t/error-in-5ttgen-fsl-t1w-acpc-dc-restore-brain-nii-gz-5tt-mif-premasked/273/1 "2016-06-03T13:21:28Z")

</div>

Run the below line from shell propmt:

5ttgen fsl T1w\_acpc\_dc\_restore\_brain.nii.gz 5TT.mif -premasked

Got error :

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: ./5ttgen-tmp-ROVGCQ/  
Traceback (most recent call last):  
File “C:/msys64/home/Administrator/mrtrix3/scripts/5ttgen”, line 46, in   
runCommand('mrconvert ’ + getUserPath(lib.app.args.input, True) + ’ ’ + os.path.join(lib.app.tempDir, ‘input.mif’))  
File “C:/msys64/home/Administrator/mrtrix3/scripts/lib/runCommand.py”, line 57, in runCommand  
if not binary\_sys or not os.path.samefile(binary\_sys, binary\_manual):  
AttributeError: ‘module’ object has no attribute ‘samefile’

---

<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 3, 2016, 1:52pm UTC](https://community.mrtrix.org/t/error-in-5ttgen-fsl-t1w-acpc-dc-restore-brain-nii-gz-5tt-mif-premasked/273/2 "2016-06-03T13:52:55Z")

</div>

Hi there,

OK, looks like Windows does not support that particular function (`os.path.samefile()`) prior to Python version 3.2. We’ll have to achieve that functionality using some other method (it’s trying to verify that the _MRtrix3_ binaries that it’s running come from the same installation as the script you’re running). I’ll look into posting a fix.

In the meantime, you may find that running the same script using Python3 runs just fine.

Thanks for the report  
Rob

---

<div class="post-metadata">

**Author:** ![Sarbani](https://community.mrtrix.org/letter_avatar_proxy/v4/letter/s/a3d4f5/32.png) [@Sarbani](https://community.mrtrix.org/u/Sarbani)\
**Post date:** [June 3, 2016, 2:59pm UTC](https://community.mrtrix.org/t/error-in-5ttgen-fsl-t1w-acpc-dc-restore-brain-nii-gz-5tt-mif-premasked/273/3 "2016-06-03T14:59:15Z")

</div>

Hi Rob,  
Please help how to run the same script from python3. I don’t find any documentation of running script using python3  
in mrtrix3.  
Thanks for the support.  
Sarbani

---

<div class="post-metadata">

**Author:** ![jdtournier](https://community.mrtrix.org/user_avatar/community.mrtrix.org/jdtournier/32/2594_2.png) [@jdtournier](https://community.mrtrix.org/u/jdtournier)\
**Post date:** [June 3, 2016, 4:25pm UTC](https://community.mrtrix.org/t/error-in-5ttgen-fsl-t1w-acpc-dc-restore-brain-nii-gz-5tt-mif-premasked/273/4 "2016-06-03T16:25:28Z")

</div>

It should just be a matter of adding `python3` at the start of your command, i.e.:

```
$ python3 5ttgen fsl T1w_acpc_dc_restore_brain.nii.gz 5TT.mif -premasked

```

If python3 isn’t installed, you should be able to install it using:

```
$ pacman -S python3
```

---

<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 6, 2016, 1:36am UTC](https://community.mrtrix.org/t/error-in-5ttgen-fsl-t1w-acpc-dc-restore-brain-nii-gz-5tt-mif-premasked/273/5 "2016-06-06T01:36:41Z")

</div>

OK @Sarbani, the scripts should now work on Windows using Python version 2.

---

<div class="post-metadata">

**Author:** ![Sarbani](https://community.mrtrix.org/letter_avatar_proxy/v4/letter/s/a3d4f5/32.png) [@Sarbani](https://community.mrtrix.org/u/Sarbani)\
**Post date:** [June 6, 2016, 10:24am UTC](https://community.mrtrix.org/t/error-in-5ttgen-fsl-t1w-acpc-dc-restore-brain-nii-gz-5tt-mif-premasked/273/6 "2016-06-06T10:24:44Z")

</div>

Hi @jdtournier,  
I run the script from python3 as below:  
$ python3 5ttgen fsl T1w\_acpc\_dc\_restore\_brain.nii.gz 5TT.mif -premasked  
but got error :

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-PDOGAU/  
Command: mrconvert /home/Administrator/mrtrix3/scripts/T1w\_acpc\_dc\_restore\_brain.nii.gz /tmp/5ttgen-tmp-PDOGAU/input.mif  
5ttgen: Changing to temporary directory (/tmp/5ttgen-tmp-PDOGAU/)  
5ttgen: [ERROR] Script cannot run in FSL mode on Windows  
5ttgen: Changing back to original directory (/home/Administrator/mrtrix3/scripts)  
5ttgen: Deleting temporary directory /tmp/5ttgen-tmp-PDOGAU/

Then I try to execute the script without FSL as below:  
$ python3 5ttgen T1w\_acpc\_dc\_restore\_brain.nii.gz 5TT.mif -premasked

and got error:  
Error: invalid choice: ‘T1w\_acpc\_dc\_restore\_brain.nii.gz’ (choose from ‘freesurfer’, ‘fsl’)

Please help how should I proceed.

@rsmith Thanks for the reply. Do I need to download the msys package and run the .build again before executing the command, as it seems to me a fix in the msys package.

---

<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 6, 2016, 11:20pm UTC](https://community.mrtrix.org/t/error-in-5ttgen-fsl-t1w-acpc-dc-restore-brain-nii-gz-5tt-mif-premasked/273/7 "2016-06-06T23:20:43Z")

</div>

The line you provided here:  
`python3 5ttgen T1w_acpc_dc_restore_brain.nii.gz 5TT.mif -premasked`  
does not specify which algorithm is to be used, which is expected as the first argument. Therefore, since the path to your input image is the first thing provided to the script, it reads that expecting to see the name of an algorithm; hence the error message:  
`Error: invalid choice: 'T1w_acpc_dc_restore_brain.nii.gz' (choose from 'freesurfer', 'fsl')`

> Do I need to download the msys package and run the .build again before executing the command, as it seems to me a fix in the msys package.

No, this was purely a fix in the _MRtrix3_ script library. You should therefore only need to update _MRtrix3_ using:

```auto
git pull
./build

```
