@@ -692,6 +692,33 @@ class BrainExtraction(ANTSCommand):
692692 output_spec = BrainExtractionOutputSpec
693693 _cmd = 'antsBrainExtraction.sh'
694694
695+ def _run_interface (self , runtime , correct_return_codes = (0 ,)):
696+ out_environ = self ._get_environ ()
697+ if out_environ .get ('ANTSPATH' ) is None :
698+ runtime .environ .update (out_environ )
699+ executable_name = self .cmd .split ()[0 ]
700+ exist_val , cmd_path = _exists_in_path (executable_name ,
701+ runtime .environ )
702+ if not exist_val :
703+ raise IOError ("command '%s' could not be found on host %s" %
704+ (self .cmd .split ()[0 ], runtime .hostname ))
705+
706+ runtime .environ .update ({'ANTSPATH' : cmd_path })
707+
708+ runtime = super (BrainExtraction , self )._run_interface (runtime )
709+
710+ if 'we cant find the N4 program' in runtime .stdout :
711+ errmsg = ('antsBrainExtraction.sh requires the environment variable '
712+ 'ANTSPATH to be defined' )
713+ if runtime .stderr is None :
714+ runtime .stderr = errmsg
715+ else :
716+ runtime .stderr += '\n ' + errmsg
717+ runtime .returncode = 1
718+ self .raise_exception (runtime )
719+
720+ return runtime
721+
695722 def _list_outputs (self ):
696723 outputs = self ._outputs ().get ()
697724 outputs ['BrainExtractionMask' ] = os .path .join (os .getcwd (),
0 commit comments