Repository: nipy/nipype

Issue:
Fix/vol2surf
surf_reg option was broken.
We ran the tests, but weren't sure whether that went ok



Discussion:
we considered that, too, but thought rather to mimic freesurfer's original behavior:
If --surfreg is not specified, it defaults to using sphere.reg.
What do you think? 

@SaOligg88 -

for this to work we need to ensure versioning is in place (and it's only somewhat in place). say for example, freesurfer changes the default from sphere.reg to fancynew.reg. then from a nipype perspective it won't rerun a node because it doesn't know that some default has changed, and from a reproducibility perspective running an older script may not generate the same output because it's actually being called with different parameters.

so i would suggest that we start moving towards encoding the defaults where we can. we will over time start moving the specification to the underlying software themselves (e.g., like slicer), such that these things are automatically picked up together with versioning.

@soligschlager are you still working on this PR? Do you need help?
@soligschlager - please let us know if you're planning to work on this PR, otherwise I'll try to review and finish.
Hi there, no, unfortunately I'm not. Thanks for checking.
@soligschlager - thank you for answering. I will review and check what is still missing.

Resolving patch:
diff --git a/nipype/interfaces/freesurfer/utils.py b/nipype/interfaces/freesurfer/utils.py
--- a/nipype/interfaces/freesurfer/utils.py
+++ b/nipype/interfaces/freesurfer/utils.py
@@ -139,8 +139,9 @@ class SampleToSurfaceInputSpec(FSTraitedSpec):
     subject_id = traits.String(desc="subject id")
     target_subject = traits.String(argstr="--trgsubject %s",
                                    desc="sample to surface of different subject than source")
-    surf_reg = traits.Bool(argstr="--surfreg", requires=["target_subject"],
-                           desc="use surface registration to target subject")
+    surf_reg = traits.Either(traits.Bool, traits.Str(),
+                             argstr="--surfreg %s", requires=["target_subject"],
+                             desc="use surface registration to target subject")
     ico_order = traits.Int(argstr="--icoorder %d", requires=["target_subject"],
                            desc="icosahedron order when target_subject is 'ico'")
 
@@ -238,6 +239,10 @@ def _format_arg(self, name, spec, value):
 
             if value in implicit_filetypes:
                 return ""
+        if name == 'surf_reg':
+            if value is True:
+                return spec.argstr % 'sphere.reg'
+
         return super(SampleToSurface, self)._format_arg(name, spec, value)
 
     def _get_outfilename(self, opt="out_file"):


Test patch:
diff --git a/nipype/interfaces/freesurfer/tests/test_auto_SampleToSurface.py b/nipype/interfaces/freesurfer/tests/test_auto_SampleToSurface.py
--- a/nipype/interfaces/freesurfer/tests/test_auto_SampleToSurface.py
+++ b/nipype/interfaces/freesurfer/tests/test_auto_SampleToSurface.py
@@ -93,7 +93,7 @@ def test_SampleToSurface_inputs():
     ),
     subject_id=dict(),
     subjects_dir=dict(),
-    surf_reg=dict(argstr='--surfreg',
+    surf_reg=dict(argstr='--surfreg %s',
     requires=['target_subject'],
     ),
     surface=dict(argstr='--surf %s',