BET failed to run


#1

When I’m trying to run the code down here.

import nipype.interfaces.fsl as fsl
myb=fsl.BET()
myb.inputs.in_file = ‘/home/sunny/nipype_tutorial/data/sub001/struct.nii.gz’
myb.inputs.out_file = ‘/home/sunny/nipype_tutorial/output/sub001/struct_bet.nii.gz’
myb.run()

It cames an error like this:

Traceback (most recent call last):
File “/home/cynthia/PycharmProjects/FSL_installation/note_book.py”, line 4, in
from nipype.interfaces.fsl import MCFLIRT, FLIRT
File “/home/cynthia/anaconda3/lib/python3.6/site-packages/nipype/interfaces/fsl/init.py”, line 13, in
from .model import (Level1Design, FEAT, FEATModel, FILMGLS, FEATRegister,
File “/home/cynthia/anaconda3/lib/python3.6/site-packages/nipype/interfaces/fsl/model.py”, line 661, in
class FILMGLS(FSLCommand):
File “/home/cynthia/anaconda3/lib/python3.6/site-packages/nipype/interfaces/fsl/model.py”, line 694, in FILMGLS
if Info.version() and LooseVersion(Info.version()) > LooseVersion(‘5.0.6’):
File “/home/cynthia/anaconda3/lib/python3.6/site-packages/nipype/interfaces/fsl/base.py”, line 77, in version
out = open(’%s/etc/fslversion’ % (basedir)).read()
FileNotFoundError: [Errno 2] No such file or directory: ‘/usr/share/fsl/etc/fslversion’

By the way, when I type fsl in the terminal, I can see the FSLGUI and I can do bet with the GUI successfully. And when I type bet in the terminal It cames like this:

sunny@cynthia-PC:~$ bet

Usage: bet [options]

Main bet2 options:
-o generate brain surface outline overlaid onto original image
-m generate binary brain mask
-s generate approximate skull image
-n don’t generate segmented brain image output
-f fractional intensity threshold (0->1); default=0.5; smaller values give larger brain outline estimates
-g vertical gradient in fractional intensity threshold (-1->1); default=0; positive values give larger brain outline at bottom, smaller at top
-r head radius (mm not voxels); initial surface sphere is set to half of this
-c centre-of-gravity (voxels not mm) of initial mesh surface.
-t apply thresholding to segmented brain image and mask
-e generates brain surface as mesh in .vtk format

Variations on default bet2 functionality (mutually exclusive options):
(default) just run bet2
-R robust brain centre estimation (iterates BET several times)
-S eye & optic nerve cleanup (can be useful in SIENA)
-B bias field & neck cleanup (can be useful in SIENA)
-Z improve BET if FOV is very small in Z (by temporarily padding end slices)
-F apply to 4D FMRI data (uses -f 0.3 and dilates brain mask slightly)
-A run bet2 and then betsurf to get additional skull and scalp surfaces (includes registrations)
-A2 as with -A, when also feeding in non-brain-extracted T2 (includes registrations)

Miscellaneous options:
-v verbose (switch on diagnostic messages)
-h display this help, then exits
-d debug (don’t delete temporary intermediate images)

Is there anyone who can tell me what I can do to fix this? I’m really confused with it.


#2

Sorry, Don’t have anything to add, just connecting the conversation here with the one on github, so people know what’s already been tried.


#3

Hi,
I just tried installing nipype and fsl and it did gave me issues from pycharm.
Then I tried running the python code from terminal with the python with which I installed nipype, and it worked perfectly.
try running your code from a python script from terminal


#4

Thank you very much! Actually it just was a Pycharm issue.And It runs well in spyder.