Skip to content

Commit a7bafda

Browse files
committed
Change inputs to MRICombine and add explanation for out_file renaming.
1 parent e9a5bb8 commit a7bafda

File tree

2 files changed

+15
-18
lines changed

2 files changed

+15
-18
lines changed

nipype/interfaces/freesurfer/tests/test_auto_MRIsCombine.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,10 @@ def test_MRIsCombine_inputs():
1212
ignore_exception=dict(nohash=True,
1313
usedefault=True,
1414
),
15-
in_file1=dict(argstr='--combinesurfs %s',
15+
in_files=dict(argstr='--combinesurfs %s',
1616
mandatory=True,
1717
position=1,
1818
),
19-
in_file2=dict(argstr='%s',
20-
mandatory=True,
21-
position=2,
22-
),
2319
out_file=dict(argstr='%s',
2420
genfile=True,
2521
mandatory=True,

nipype/interfaces/freesurfer/utils.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -958,24 +958,20 @@ class MRIsCombineInputSpec(FSTraitedSpec):
958958
"""
959959
Uses Freesurfer's mris_convert to combine two surface files into one.
960960
"""
961-
in_file1 = File(exists=True, mandatory=True, position=1,
962-
argstr='--combinesurfs %s',
963-
desc='File to be combined with in_file2')
964-
in_file2 = File(exists=True, mandatory=True, position=2,
965-
argstr='%s',
966-
desc='File to be combined with in_file1')
961+
in_files = traits.List(File(Exists=True), maxlen=2, minlen=2,
962+
mandatory=True, position=1, argstr='--combinesurfs %s',
963+
desc='Two surfaces to be combined.')
967964
out_file = File(argstr='%s', position=-1, genfile=True,
968965
mandatory=True,
969-
desc='Output filename. Combined surfaces from in_file1 and '
970-
'in_file2.')
966+
desc='Output filename. Combined surfaces from in_files.')
971967

972968

973969
class MRIsCombineOutputSpec(TraitedSpec):
974970
"""
975971
Uses Freesurfer's mris_convert to combine two surface files into one.
976972
"""
977973
out_file = File(exists=True, desc='Output filename. Combined surfaces from '
978-
'in_file1 and in_file2.')
974+
'in_files.')
979975

980976

981977
class MRIsCombine(FSCommand):
@@ -990,18 +986,23 @@ class MRIsCombine(FSCommand):
990986
991987
>>> import nipype.interfaces.freesurfer as fs
992988
>>> mris = fs.MRIsCombine()
993-
>>> mris.inputs.in_file1 = 'lh.pial'
994-
>>> mris.inputs.in_file2 = 'rh.pial'
995-
>>> mris.inputs.out_file = 'out.stl'
989+
>>> mris.inputs.in_files = ['lh.pial', 'rh.pial']
990+
>>> mris.inputs.out_file = 'bh.pial'
996991
>>> mris.cmdline # doctest: +ALLOW_UNICODE
997-
'mris_convert --combinesurfs lh.pial rh.pial out.stl'
992+
'mris_convert --combinesurfs lh.pial rh.pial bh.pial'
998993
>>> mris.run() # doctest: +SKIP
999994
"""
1000995
_cmd = 'mris_convert'
1001996
input_spec = MRIsCombineInputSpec
1002997
output_spec = MRIsCombineOutputSpec
1003998

1004999
def _list_outputs(self):
1000+
"""
1001+
If the output file is not specified starting with 'lh.' or 'rh.',
1002+
FreeSurfer prepends 'lh.' to the filename. It never adds 'rh.', even if
1003+
both input files are from the right hemisphere. Output out_file must be
1004+
adjusted to accommodate this.
1005+
"""
10051006
outputs = self.output_spec().get()
10061007
if any(self.inputs.out_file.startswith(pre) for pre in ['lh.', 'rh.']):
10071008
outputs['out_file'] = self.inputs.out_file

0 commit comments

Comments
 (0)