nipy / nipype

Workflows and interfaces for neuroimaging packages
https://nipype.readthedocs.org/en/latest/
Other
746 stars 530 forks source link

Interface BET failed to run Error #2332

Closed Cynthia0629 closed 6 years ago

Cynthia0629 commented 6 years ago

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 <input> <output> [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 <f>      fractional intensity threshold (0->1); default=0.5; smaller values give larger brain outline estimates
  -g <g>      vertical gradient in fractional intensity threshold (-1->1); default=0; positive values give larger brain outline at bottom, smaller at top
  -r <r>      head radius (mm not voxels); initial surface sphere is set to half of this
  -c <x y z>  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 <T2>    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.

mgxd commented 6 years ago

@Cynthia0629 it seems like your FSLDIR environmental variable is missing a directory.

Could you try setting FSLDIR=/usr/share/fsl/5.0 and retrying?

What version of Nipype are you using? You can check in a command line

python -c "import nipype; print(nipype.__version__)"
Cynthia0629 commented 6 years ago

Yes,I'm sure I did. And the result of the command line python -c "import nipype; print(nipype.version)" is 0.13.1

mgxd commented 6 years ago

Okay, let's verify that your python environment isn't interfering - can you run the following the same way that you tried to run your code in your original example?

import os
from nipype.interfaces import fsl

print(os.getenv('FSLDIR'))
print(fsl.Info().version())
Cynthia0629 commented 6 years ago

When I run the code in the terminal the result is that

import os from nipype.interfaces import fsl

print(os.getenv('FSLDIR')) /usr/share/fsl/5.0 print(fsl.Info().version()) 5.0.9


But when I tried it with nipype, It became that:

/home/sunny/anaconda3/bin/python /home/sunny/PycharmProjects/nipype/test_environment.py None None

mgxd commented 6 years ago

@Cynthia0629 How did you run the code for your second case?

But when I tried it with nipype, It became that: /home/sunny/anaconda3/bin/python /home/sunny/PycharmProjects/nipype/test_environment.py None None

Perhaps you'll need to export FSLDIR=/usr/share/fsl/5.0 rather than just defining it, could you try running this command in a terminal and then in the same terminal running python /home/sunny/PycharmProjects/nipype/test_environment.py again?


EDIT: can you also provide the OS and version you are running this on

Cynthia0629 commented 6 years ago

Sorry,I think I've exported it already. Maybe I didn't make it clearly.If I just run python /home/sunny/PycharmProjects/nipype/test_environment.py in the terminal, I can get the result as:

/usr/share/fsl/5.0 5.0.9

But when I tried it with pycharm,the name of IDE I use.It bacame none again. The OS I use is ubuntu 14.04 trusty and the IDE I use is Pycharm community 2017.1.2 I use python3 and anaconda3 also. Thank you very much for your reply!

mgxd commented 6 years ago

@Cynthia0629 it seems to me this is more of a Pycharm issue than Nipype - but could you try setting your FSLDIR environmental variable within Pycharm? Something like this

Cynthia0629 commented 6 years ago

Sorry,I've tried that ,but it didn't work either.But what can be sure is that it is a Pycharm issue. And I ran it successfully with spyder.Anyway,I can try to do something with my data now. It is so kind of you. Thank you very much!