Skip to content

[RTM] ENH: Validate graymid inputs from FreeSurferSource #494

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 28, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions fmriprep/interfaces/freesurfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"""
from __future__ import print_function, division, absolute_import, unicode_literals

from nipype.interfaces.base import isdefined, File
from nipype.interfaces.base import isdefined, InputMultiPath
from nipype.interfaces import freesurfer as fs


Expand All @@ -34,7 +34,7 @@ def cmdline(self):


class MakeMidthicknessInputSpec(fs.utils.MRIsExpandInputSpec):
graymid = File(desc='Existing graymid/midthickness file')
graymid = InputMultiPath(desc='Existing graymid/midthickness file')


class MakeMidthickness(fs.MRIsExpand):
Expand All @@ -44,9 +44,27 @@ class MakeMidthickness(fs.MRIsExpand):

@property
def cmdline(self):
import os.path as op
cmd = super(MakeMidthickness, self).cmdline
if not isdefined(self.inputs.graymid):
if not isdefined(self.inputs.graymid) or len(self.inputs.graymid) < 1:
return cmd

return "cp {} {}".format(self.inputs.graymid,
self._list_outputs()['out_file'])
# Possible graymid values inclue {l,r}h.{graymid,midthickness}
# Prefer midthickness to graymid, require to be of the same hemisphere
# as input
source = None
in_base = op.basename(self.inputs.in_file)
mt = self._associated_file(in_base, 'midthickness')
gm = self._associated_file(in_base, 'graymid')

for surf in self.inputs.graymid:
if op.basename(surf) == mt:
source = surf
break
if op.basename(surf) == gm:
source = surf

if source is None:
return cmd

return "cp {} {}".format(source, self._list_outputs()['out_file'])