|
14 | 14 | import os
|
15 | 15 | from ...external.due import BibTeX
|
16 | 16 | from ...utils.filemanip import split_filename, copyfile
|
17 |
| -from ..base import TraitedSpec, File, traits, InputMultiPath, OutputMultiPath, isdefined |
| 17 | +from ..base import (TraitedSpec, File, traits, InputMultiPath, OutputMultiPath, isdefined, |
| 18 | + _exists_in_path) |
18 | 19 | from .base import ANTSCommand, ANTSCommandInputSpec
|
19 | 20 |
|
20 | 21 |
|
@@ -693,20 +694,22 @@ class BrainExtraction(ANTSCommand):
|
693 | 694 | _cmd = 'antsBrainExtraction.sh'
|
694 | 695 |
|
695 | 696 | def _run_interface(self, runtime, correct_return_codes=(0,)):
|
| 697 | + # antsBrainExtraction.sh requires ANTSPATH to be defined |
696 | 698 | out_environ = self._get_environ()
|
697 | 699 | if out_environ.get('ANTSPATH') is None:
|
698 | 700 | runtime.environ.update(out_environ)
|
699 | 701 | executable_name = self.cmd.split()[0]
|
700 |
| - exist_val, cmd_path = _exists_in_path(executable_name, |
701 |
| - runtime.environ) |
| 702 | + exist_val, cmd_path = _exists_in_path(executable_name, runtime.environ) |
702 | 703 | if not exist_val:
|
703 | 704 | raise IOError("command '%s' could not be found on host %s" %
|
704 | 705 | (self.cmd.split()[0], runtime.hostname))
|
705 | 706 |
|
706 |
| - runtime.environ.update({'ANTSPATH': cmd_path}) |
| 707 | + # Set the environment variable if found |
| 708 | + runtime.environ.update({'ANTSPATH': os.path.dirname(cmd_path)}) |
707 | 709 |
|
708 | 710 | runtime = super(BrainExtraction, self)._run_interface(runtime)
|
709 | 711 |
|
| 712 | + # Still, double-check if it didn't found N4 |
710 | 713 | if 'we cant find the N4 program' in runtime.stdout:
|
711 | 714 | errmsg = ('antsBrainExtraction.sh requires the environment variable '
|
712 | 715 | 'ANTSPATH to be defined')
|
|
0 commit comments