Skip to content

Commit beb5eb2

Browse files
name template for XfmConcat
1 parent fd1d808 commit beb5eb2

File tree

1 file changed

+13
-31
lines changed

1 file changed

+13
-31
lines changed

nipype/interfaces/minc/minc.py

Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3028,7 +3028,10 @@ class XfmConcatInputSpec(CommandLineInputSpec):
30283028
desc='output file',
30293029
genfile=True,
30303030
argstr='%s',
3031-
position=-1,)
3031+
position=-1,
3032+
name_source=['input_files'],
3033+
hash_files=False,
3034+
name_template='%s_xfmconcat.xfm')
30323035

30333036
verbose = traits.Bool(
30343037
desc='Print out log messages. Default: False.',
@@ -3042,7 +3045,6 @@ class XfmConcatInputSpec(CommandLineInputSpec):
30423045

30433046
class XfmConcatOutputSpec(TraitedSpec):
30443047
output_file = File(desc='output file', exists=True)
3045-
# FIXME is exists=True always the case?
30463048
output_grids = OutputMultiPath(desc='output grids', exists=True)
30473049

30483050

@@ -3064,36 +3066,16 @@ class XfmConcat(CommandLine):
30643066
output_spec = XfmConcatOutputSpec
30653067
_cmd = 'xfmconcat'
30663068

3067-
def _gen_filename(self, name):
3068-
if name == 'output_file':
3069-
output_file = self.inputs.output_file
3070-
3071-
if isdefined(output_file):
3072-
return os.path.abspath(output_file)
3073-
else:
3074-
return aggregate_filename(
3075-
self.inputs.input_files,
3076-
'xfmconcat_output') + '.xfm'
3077-
else:
3078-
raise NotImplemented
3079-
3080-
def _gen_outfilename(self):
3081-
return self._gen_filename('output_file')
3082-
30833069
def _list_outputs(self):
3084-
outputs = self.output_spec().get()
3085-
outputs['output_file'] = os.path.abspath(self._gen_outfilename())
3086-
3087-
# FIXME Is this the sensible? No other way to tell if the grid files
3088-
# were produced.
3089-
# FIXME This is safe to assume?
3090-
assert os.path.exists(outputs['output_file'])
3091-
if 'grid' in open(outputs['output_file'], 'r').read():
3092-
outputs['output_grids'] = glob.glob(
3093-
re.sub(
3094-
'.(nlxfm|xfm)$',
3095-
'_grid_*.mnc',
3096-
outputs['output_file']))
3070+
outputs = super(XfmConcat, self)._list_outputs()
3071+
3072+
if os.path.exists(outputs['output_file']):
3073+
if 'grid' in open(outputs['output_file'], 'r').read():
3074+
outputs['output_grids'] = glob.glob(
3075+
re.sub(
3076+
'.(nlxfm|xfm)$',
3077+
'_grid_*.mnc',
3078+
outputs['output_file']))
30973079

30983080
return outputs
30993081

0 commit comments

Comments
 (0)