Skip to content

Commit 4f47553

Browse files
committed
try to determine output dir from fsf file, to deal with cases where the output dir is not in the cwd
1 parent f380f5b commit 4f47553

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

nipype/interfaces/fsl/model.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -384,16 +384,26 @@ class FEAT(FSLCommand):
384384
def _list_outputs(self):
385385
outputs = self._outputs().get()
386386
is_ica = False
387+
outputs['feat_dir']=None
387388
with open(self.inputs.fsf_file, 'rt') as fp:
388389
text = fp.read()
389390
if "set fmri(inmelodic) 1" in text:
390391
is_ica = True
391-
392-
if is_ica:
393-
outputs['feat_dir'] = glob(os.path.join(os.getcwd(), '*ica'))[0]
394-
else:
395-
outputs['feat_dir'] = glob(os.path.join(os.getcwd(), '*feat'))[0]
396-
392+
for line in text.split('\n'):
393+
if line.find("set fmri(outputdir)")>-1:
394+
try:
395+
outputdir_spec=line.split('"')[-2]
396+
if os.path.exists(outputdir_spec):
397+
outputs['feat_dir']=outputdir_spec
398+
399+
except:
400+
pass
401+
if not outputs['feat_dir']:
402+
if is_ica:
403+
outputs['feat_dir'] = glob(os.path.join(os.getcwd(), '*ica'))[0]
404+
else:
405+
outputs['feat_dir'] = glob(os.path.join(os.getcwd(), '*feat'))[0]
406+
print 'Outputs from FEATmodel:',outputs
397407
return outputs
398408

399409

0 commit comments

Comments
 (0)