Skip to content

Commit 4673441

Browse files
author
David Ellis
committed
FIX: Fixes the 'out_file' and out_datatype inputs for MRIsConvert.
If the 'out_file' input was set in MRIsConvert it would cause and error because the 'out_file' would not match the auto generated 'out_file' name. This patch allows 'out_file' to be set.
1 parent e8e18ef commit 4673441

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

nipype/interfaces/freesurfer/tests/test_auto_MRIsConvert.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,12 @@ def test_MRIsConvert_inputs():
3030
),
3131
origname=dict(argstr='-o %s',
3232
),
33-
out_datatype=dict(mandatory=True,
33+
out_datatype=dict(xor=['out_file'],
3434
),
35-
out_file=dict(argstr='./%s',
35+
out_file=dict(argstr='%s',
3636
genfile=True,
3737
position=-1,
38+
xor=['out_datatype'],
3839
),
3940
parcstats_file=dict(argstr='--parcstats %s',
4041
),

nipype/interfaces/freesurfer/utils.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -814,10 +814,10 @@ class MRIsConvertInputSpec(FSTraitedSpec):
814814
origname = traits.String(argstr="-o %s", desc="read orig positions")
815815

816816
in_file = File(exists=True, mandatory=True, position=-2, argstr='%s', desc='File to read/convert')
817-
out_file = File(argstr='./%s', position=-1, genfile=True, desc='output filename or True to generate one')
818-
# Not really sure why the ./ is necessary but the module fails without it
817+
out_file = File(argstr='%s', position=-1, genfile=True, xor=['out_datatype'],
818+
desc='output filename or True to generate one')
819819

820-
out_datatype = traits.Enum("ico", "tri", "stl", "vtk", "gii", "mgh", "mgz", mandatory=True,
820+
out_datatype = traits.Enum("ico", "tri", "stl", "vtk", "gii", "mgh", "mgz", xor=['out_file'],
821821
desc="These file formats are supported: ASCII: .asc"
822822
"ICO: .ico, .tri GEO: .geo STL: .stl VTK: .vtk GIFTI: .gii MGH surface-encoded 'volume': .mgh, .mgz")
823823

@@ -853,12 +853,14 @@ def _list_outputs(self):
853853

854854
def _gen_filename(self, name):
855855
if name is 'out_file':
856-
return self._gen_outfilename()
856+
return os.path.abspath(self._gen_outfilename())
857857
else:
858858
return None
859859

860860
def _gen_outfilename(self):
861-
if isdefined(self.inputs.annot_file):
861+
if isdefined(self.inputs.out_file):
862+
return self.inputs.out_file
863+
elif isdefined(self.inputs.annot_file):
862864
_, name, ext = split_filename(self.inputs.annot_file)
863865
elif isdefined(self.inputs.parcstats_file):
864866
_, name, ext = split_filename(self.inputs.parcstats_file)

0 commit comments

Comments
 (0)