Search code examples
pythonwindowsimage-processingbioinformaticsnipype

"command 'bet' could not be found on host" error while using BET in FSL on Windows 10 via Python 3.5


I need to perform brain extraction on .nii images. I am using Anaconda on Windows 10 and have an environment based on Python 3.5.4. On Nipype I found the BET from FSL and I followed the code:

mybet = fsl.BET()
mybet.inputs.in_file = 'example.nii'
mybet.inputs.out_file = 'example_bet.nii' 
result = mybet.run()

Please note that I expect the output file example_bet.nii to be created by fsl.BET, not to be an image to be overwritten. I can only find solutions based on Unix systems and it seems one needs to have FSL installed on a Unix-based OS, which is not possible without a Virtual Machine in Windows. Well, this is the output I get:

171122-12:02:48,988 interface WARNING:
     FSLOUTPUTTYPE environment variable is not set. Setting FSLOUTPUTTYPE=NIFTI

---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
<ipython-input-12-5b900fbd5263> in <module>()
      2 mybet.inputs.in_file = 'prova.nii'
      3 mybet.inputs.out_file = 'prova_bet.nii'
----> 4 result = mybet.run()

~\Anaconda3\envs\tensorflow\lib\site-packages\nipype\interfaces\base.py in run(self, **inputs)
   1079                         version=self.version)
   1080         try:
-> 1081             runtime = self._run_wrapper(runtime)
   1082             outputs = self.aggregate_outputs(runtime)
   1083             runtime.endTime = dt.isoformat(dt.utcnow())

~\Anaconda3\envs\tensorflow\lib\site-packages\nipype\interfaces\base.py in _run_wrapper(self, runtime)
   1722 
   1723     def _run_wrapper(self, runtime):
-> 1724         runtime = self._run_interface(runtime)
   1725         return runtime
   1726 

~\Anaconda3\envs\tensorflow\lib\site-packages\nipype\interfaces\fsl\preprocess.py in _run_interface(self, runtime)
    142         # in stderr and if it's set, then update the returncode
    143         # accordingly.
--> 144         runtime = super(BET, self)._run_interface(runtime)
    145         if runtime.stderr:
    146             self.raise_exception(runtime)

~\Anaconda3\envs\tensorflow\lib\site-packages\nipype\interfaces\base.py in _run_interface(self, runtime, correct_return_codes)
   1748         if not exist_val:
   1749             raise IOError("command '%s' could not be found on host %s" %
-> 1750                           (self.cmd.split()[0], runtime.hostname))
   1751         setattr(runtime, 'command_path', cmd_path)
   1752         setattr(runtime, 'dependencies', get_dependencies(executable_name,

OSError: command 'bet' could not be found on host DESKTOP-MYPC
Interface BET failed to run. 

Do I need to switch to Linux or is there a way around it?


Solution

  • You can only use FSL on Windows via Docker, Virtual Machine, or Windows Subsystem for Linux. Running it naively is not possible.