Skip to content

Commit b92d0f8

Browse files
Use name_source/name_template for VolSymm interface.
1 parent c5d93c1 commit b92d0f8

File tree

1 file changed

+14
-37
lines changed

1 file changed

+14
-37
lines changed

nipype/interfaces/minc/minc.py

Lines changed: 14 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4047,13 +4047,20 @@ class VolSymmInputSpec(CommandLineInputSpec):
40474047
desc='output xfm trans file',
40484048
genfile=True,
40494049
argstr='%s',
4050-
position=-2)
4050+
position=-2,
4051+
name_source=['input_file'],
4052+
hash_files=False,
4053+
name_template='%s_vol_symm.xfm',
4054+
keep_extension=False)
40514055

40524056
output_file = File(
40534057
desc='output file',
40544058
genfile=True,
40554059
argstr='%s',
4056-
position=-1,)
4060+
position=-1,
4061+
name_source=['input_file'],
4062+
hash_files=False,
4063+
name_template='%s_vol_symm.mnc')
40574064

40584065
# This is a dummy input.
40594066
input_grid_files = InputMultiPath(
@@ -4124,42 +4131,12 @@ class VolSymm(CommandLine):
41244131
output_spec = VolSymmOutputSpec
41254132
_cmd = 'volsymm'
41264133

4127-
def _gen_filename(self, name):
4128-
if name == 'output_file':
4129-
output_file = self.inputs.output_file
4130-
4131-
if isdefined(output_file):
4132-
return os.path.abspath(output_file)
4133-
else:
4134-
return aggregate_filename(
4135-
[self.inputs.input_file], 'volsymm_output')
4136-
elif name == 'trans_file':
4137-
trans_file = self.inputs.trans_file
4138-
4139-
if isdefined(trans_file):
4140-
return os.path.abspath(trans_file)
4141-
else:
4142-
return aggregate_filename(
4143-
[self.inputs.input_file], 'volsymm_output') + '.xfm'
4144-
else:
4145-
raise NotImplemented
4146-
4147-
def _gen_outfilename(self):
4148-
return self._gen_filename('output_file')
4149-
41504134
def _list_outputs(self):
4151-
outputs = self.output_spec().get()
4152-
outputs['output_file'] = os.path.abspath(
4153-
self._gen_filename('output_file'))
4154-
outputs['trans_file'] = os.path.abspath(
4155-
self._gen_filename('trans_file'))
4135+
outputs = super(VolSymm, self)._list_outputs()
41564136

4157-
# FIXME Is this the sensible? No other way to tell if the grid files
4158-
# were produced.
4159-
# FIXME This is safe to assume?
4160-
assert os.path.exists(outputs['trans_file'])
4161-
if 'grid' in open(outputs['trans_file'], 'r').read():
4162-
outputs['output_grid'] = re.sub(
4163-
'.(nlxfm|xfm)$', '_grid_0.mnc', outputs['trans_file'])
4137+
# Have to manually check for the grid files.
4138+
if os.path.exists(outputs['trans_file']):
4139+
if 'grid' in open(outputs['trans_file'], 'r').read():
4140+
outputs['output_grid'] = re.sub('.(nlxfm|xfm)$', '_grid_0.mnc', outputs['trans_file'])
41644141

41654142
return outputs

0 commit comments

Comments
 (0)