Skip to content

Commit 46476cb

Browse files
committed
fix: automask bug when apply_mask is not specified
1 parent 044333b commit 46476cb

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

nipype/interfaces/afni/preprocess.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,9 @@ class AutomaskInputSpec(AFNITraitedSpec):
562562
hash_files=False)
563563

564564
apply_mask = File(desc="output file from 3dAutomask",
565-
argstr='-apply_prefix %s')
565+
argstr='-apply_prefix %s',
566+
genfile=True,
567+
hash_files=False)
566568

567569
clfrac = traits.Float(desc='sets the clip level fraction' +
568570
' (must be 0.1-0.9). ' +
@@ -610,8 +612,10 @@ class Automask(AFNICommand):
610612
output_spec = AutomaskOutputSpec
611613

612614
def _gen_filename(self, name):
613-
if name == 'out_file' or name == 'brain_file':
615+
if name == 'out_file':
614616
return self._list_outputs()[name]
617+
if name == 'apply_mask':
618+
return self._list_outputs()['brain_file']
615619
return None
616620

617621
def _list_outputs(self):
@@ -623,8 +627,8 @@ def _list_outputs(self):
623627
outputs['out_file'] = os.path.abspath(self.inputs.out_file)
624628

625629
if not isdefined(self.inputs.apply_mask):
626-
outputs['brain_file'] = self._gen_fname(
627-
self.inputs.in_file, suffix=self.inputs.apply_suffix)
630+
outputs['brain_file'] = self._gen_fname(self.inputs.in_file,
631+
suffix=self.inputs.apply_suffix)
628632
else:
629633
outputs['brain_file'] = os.path.abspath(self.inputs.apply_mask)
630634
return outputs

nipype/interfaces/afni/tests/test_preprocess.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -356,17 +356,20 @@ def test_maskave():
356356
yield assert_equal, getattr(instance.inputs.traits()[key], metakey), value
357357

358358
def test_automask():
359-
input_map = dict(apply_mask = dict(argstr='-apply_prefix %s',),
359+
input_map = dict(apply_mask = dict(argstr='-apply_prefix %s',
360+
hash_files=False,genfile=True,),
361+
apply_suffix = dict(usedefault=True,),
360362
args = dict(argstr='%s',),
361363
clfrac = dict(argstr='-dilate %s',),
362364
dilate = dict(argstr='-dilate %s',),
363365
environ = dict(usedefault=True,),
364366
erode = dict(argstr='-erode %s',),
365367
ignore_exception = dict(usedefault=True,),
366368
in_file = dict(argstr='%s',mandatory=True,),
367-
out_file = dict(argstr='-prefix %s',),
369+
mask_suffix = dict(usedefault=True,),
370+
out_file = dict(hash_files=False,genfile=True,
371+
argstr='-prefix %s',),
368372
outputtype = dict(),
369-
suffix = dict(),
370373
)
371374
instance = afni.Automask()
372375
for key, metadata in input_map.items():

0 commit comments

Comments
 (0)