Skip to content

Commit 373ef6a

Browse files
name template for XfmAvg
1 parent 674de74 commit 373ef6a

File tree

1 file changed

+10
-26
lines changed

1 file changed

+10
-26
lines changed

nipype/interfaces/minc/minc.py

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3284,7 +3284,11 @@ class XfmAvgInputSpec(CommandLineInputSpec):
32843284
desc='output file',
32853285
genfile=True,
32863286
argstr='%s',
3287-
position=-1,)
3287+
position=-1,
3288+
name_source=['input_files'],
3289+
hash_files=False,
3290+
name_template='%s_xfmavg.xfm',
3291+
keep_extension=False)
32883292

32893293
verbose = traits.Bool(
32903294
desc='Print out log messages. Default: False.',
@@ -3314,7 +3318,6 @@ class XfmAvgInputSpec(CommandLineInputSpec):
33143318

33153319
class XfmAvgOutputSpec(TraitedSpec):
33163320
output_file = File(desc='output file', exists=True)
3317-
# FIXME is exists=True always correct?
33183321
output_grid = File(desc='output grid file', exists=True)
33193322

33203323

@@ -3343,32 +3346,13 @@ class XfmAvg(CommandLine):
33433346
output_spec = XfmAvgOutputSpec
33443347
_cmd = 'xfmavg'
33453348

3346-
def _gen_filename(self, name):
3347-
if name == 'output_file':
3348-
output_file = self.inputs.output_file
3349-
3350-
if isdefined(output_file):
3351-
return os.path.abspath(output_file)
3352-
else:
3353-
return aggregate_filename(
3354-
self.inputs.input_files, 'xfmavg_output') + '.xfm'
3355-
else:
3356-
raise NotImplemented
3357-
3358-
def _gen_outfilename(self):
3359-
return self._gen_filename('output_file')
3360-
33613349
def _list_outputs(self):
3362-
outputs = self.output_spec().get()
3363-
outputs['output_file'] = os.path.abspath(self._gen_outfilename())
3350+
outputs = super(XfmAvg, self)._list_outputs()
33643351

3365-
# FIXME Is this the sensible? No other way to tell if the grid files
3366-
# were produced.
3367-
# FIXME This is safe to assume?
3368-
assert os.path.exists(outputs['output_file'])
3369-
if 'grid' in open(outputs['output_file'], 'r').read():
3370-
outputs['output_grid'] = re.sub(
3371-
'.(nlxfm|xfm)$', '_grid_0.mnc', outputs['output_file'])
3352+
if os.path.exists(outputs['output_file']):
3353+
if 'grid' in open(outputs['output_file'], 'r').read():
3354+
outputs['output_grid'] = re.sub(
3355+
'.(nlxfm|xfm)$', '_grid_0.mnc', outputs['output_file'])
33723356

33733357
return outputs
33743358

0 commit comments

Comments
 (0)