Skip to content

Commit e7b4c53

Browse files
author
David Ellis
committed
FIX: Ensures 'out_file' of MRIsConvert is an absolute path.
This commit ensures that 'out_file' of MRIsConvert is an absolute path. MRIsConvert requires an absolute path or a path beginning with "./". This commit also ensures that either out_file or out_datatype are defined.
1 parent 4673441 commit e7b4c53

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

nipype/interfaces/freesurfer/utils.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -814,10 +814,12 @@ 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, xor=['out_datatype'],
817+
out_file = File(argstr='%s', position=-1, genfile=True,
818+
xor=['out_datatype'], mandatory=True,
818819
desc='output filename or True to generate one')
819820

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

@@ -846,6 +848,11 @@ class MRIsConvert(FSCommand):
846848
input_spec = MRIsConvertInputSpec
847849
output_spec = MRIsConvertOutputSpec
848850

851+
def _format_arg(self, name, spec, value):
852+
if name == "out_file" and not os.path.isabs(value):
853+
value = os.path.abspath(value)
854+
return super(MRIsConvert, self)._format_arg(name, spec, value)
855+
849856
def _list_outputs(self):
850857
outputs = self.output_spec().get()
851858
outputs["converted"] = os.path.abspath(self._gen_outfilename())

0 commit comments

Comments
 (0)