Skip to content

Commit 3bd1cf0

Browse files
committed
RF/DOC: Simplify and document MRIsCombine slightly more
1 parent 1437dc4 commit 3bd1cf0

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

nipype/interfaces/freesurfer/utils.py

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -976,16 +976,18 @@ class MRIsCombineOutputSpec(TraitedSpec):
976976

977977
class MRIsCombine(FSSurfaceCommand):
978978
"""
979-
Uses Freesurfer's mris_convert to combine two surface files into one.
979+
Uses Freesurfer's ``mris_convert`` to combine two surface files into one.
980980
981981
For complete details, see the `mris_convert Documentation.
982982
<https://surfer.nmr.mgh.harvard.edu/fswiki/mris_convert>`_
983983
984-
If given an out_file that does not begin with 'lh.' or 'rh.',
985-
mris_convert will prepend 'lh.' to the file name.
986-
To avoid this behavior, consider setting out_file = './<filename>', or
984+
If given an ``out_file`` that does not begin with ``'lh.'`` or ``'rh.'``,
985+
``mris_convert`` will prepend ``'lh.'`` to the file name.
986+
To avoid this behavior, consider setting ``out_file = './<filename>'``, or
987987
leaving out_file blank.
988988
989+
In a Node/Workflow, ``out_file`` is interpreted literally.
990+
989991
Example
990992
-------
991993
@@ -1003,24 +1005,21 @@ class MRIsCombine(FSSurfaceCommand):
10031005

10041006
def _list_outputs(self):
10051007
outputs = self._outputs().get()
1006-
outputs['out_file'] = self._associated_file(self.inputs.in_files[0],
1007-
self.inputs.out_file)
1008-
return outputs
10091008

1010-
@staticmethod
1011-
def _associated_file(in_file, out_name):
1012-
"""Unlike the standard _associated_file, which uses the prefix from
1013-
in_file, in MRIsCombine, it uses 'lh.' as the prefix for the output
1014-
file no matter what the inputs are.
1015-
"""
1016-
path, base = os.path.split(out_name)
1017-
if path == '':
1018-
hemis = ('lh.', 'rh.')
1019-
if base[:3] not in hemis:
1020-
base = 'lh.' + base
1021-
return os.path.abspath(os.path.join(path, base))
1009+
# mris_convert --combinesurfs uses lh. as the default prefix
1010+
# regardless of input file names, except when path info is
1011+
# specified
1012+
path, base = os.path.split(self.inputs.out_file)
1013+
if path == '' and base[:3] not in ('lh.', 'rh.'):
1014+
base = 'lh.' + base
1015+
outputs['out_file'] = os.path.abspath(os.path.join(path, base))
1016+
1017+
return outputs
10221018

10231019
def _normalize_filenames(self):
1020+
""" In a Node context, interpret out_file as a literal path to
1021+
reduce surprise.
1022+
"""
10241023
if isdefined(self.inputs.out_file):
10251024
self.inputs.out_file = os.path.abspath(self.inputs.out_file)
10261025

0 commit comments

Comments
 (0)