Skip to content

Commit d6be1d5

Browse files
committed
Merge pull request #1454 from satra/fix/reconwf
fix: to have recon-all work with 5.3 on OSX
2 parents 9bc6c8b + 6e40eac commit d6be1d5

File tree

4 files changed

+28
-14
lines changed

4 files changed

+28
-14
lines changed

nipype/interfaces/freesurfer/tests/test_auto_Sphere.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ def test_Sphere_inputs():
2020
in_smoothwm=dict(copyfile=True,
2121
),
2222
magic=dict(argstr='-q',
23-
requires=['in_smoothwm'],
2423
),
2524
num_threads=dict(),
2625
out_file=dict(argstr='%s',

nipype/interfaces/freesurfer/utils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1668,7 +1668,6 @@ class SphereInputSpec(FSTraitedSpecOpenMP):
16681668
seed = traits.Int(argstr="-seed %d",
16691669
desc="Seed for setting random number generator")
16701670
magic = traits.Bool(argstr="-q",
1671-
requires=['in_smoothwm'],
16721671
desc="No documentation. Direct questions to analysis-bugs@nmr.mgh.harvard.edu")
16731672
in_smoothwm = File( exists=True, copyfile=True,
16741673
desc="Input surface required when -q flag is not selected")

nipype/workflows/smri/freesurfer/autorecon3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from nipype.interfaces.utility import IdentityInterface, Merge
1+
from nipype.interfaces.utility import IdentityInterface, Merge, Function
22
import nipype.pipeline.engine as pe # pypeline engine
33
from nipype.interfaces.freesurfer import *
44
from .ba_maps import create_ba_maps_wf

nipype/workflows/smri/freesurfer/recon.py

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from ....interfaces.freesurfer import AddXFormToHeader, Info
88
from ....interfaces.io import DataSink
99
from .utils import getdefaultconfig
10+
from ....pipeline.engine.base import logger
1011

1112
def create_skullstripped_recon_flow(name="skullstripped_recon_all"):
1213
"""Performs recon-all on voulmes that are already skull stripped.
@@ -84,9 +85,8 @@ def create_reconall_workflow(name="ReconAll", plugin_args=None):
8485
8586
Example
8687
-------
87-
>>> from nipype.workflows.smri.freesurfer import create_skullstripped_recon_flow
88-
>>> import nipype.interfaces.freesurfer as fs
89-
>>> recon_all = create_skullstripped_recon_flow()
88+
>>> from nipype.workflows.smri.freesurfer import create_reconall_workflow
89+
>>> recon_all = create_reconall_workflow()
9090
>>> recon_all.inputs.inputspec.subject_id = 'subj1'
9191
>>> recon_all.inputs.inputspec.subjects_dir = '.'
9292
>>> recon_all.inputs.inputspec.T1_files = 'T1.nii.gz'
@@ -105,6 +105,17 @@ def create_reconall_workflow(name="ReconAll", plugin_args=None):
105105
Outpus::
106106
postdatasink_outputspec.subject_id : name of the datasinked output folder in the subjects directory
107107
108+
Note:
109+
The input subject_id is not passed to the commands in the workflow. Commands
110+
that require subject_id are reading implicit inputs from
111+
{SUBJECTS_DIR}/{subject_id}. For those commands the subject_id is set to the
112+
default value and SUBJECTS_DIR is set to the node directory. The implicit
113+
inputs are then copied to the node directory in order to mimic a SUBJECTS_DIR
114+
structure. For example, if the command implicitly reads in brainmask.mgz, the
115+
interface would copy that input file to
116+
{node_dir}/{subject_id}/mri/brainmask.mgz and set SUBJECTS_DIR to node_dir.
117+
The workflow only uses the input subject_id to datasink the outputs to
118+
{subjects_dir}/{subject_id}.
108119
"""
109120
reconall = pe.Workflow(name=name)
110121

@@ -136,7 +147,8 @@ def create_reconall_workflow(name="ReconAll", plugin_args=None):
136147

137148
# check freesurfer version and set parameters
138149
fs_version_full = Info.version()
139-
if 'v6.0' in fs_version_full or 'dev' in fs_version_full:
150+
if fs_version_full and ('v6.0' in fs_version_full or
151+
'dev' in fs_version_full):
140152
# assuming that dev is 6.0
141153
fsvernum = 6.0
142154
fs_version = 'v6.0'
@@ -150,13 +162,17 @@ def create_reconall_workflow(name="ReconAll", plugin_args=None):
150162
else:
151163
# 5.3 is default
152164
fsvernum = 5.3
153-
if 'v5.3' in fs_version_full:
154-
fs_version = 'v5.3'
165+
if fs_version_full:
166+
if 'v5.3' in fs_version_full:
167+
fs_version = 'v5.3'
168+
else:
169+
fs_version = fs_version_full.split('-')[-1]
170+
logger.info(("Warning: Workflow may not work properly if "
171+
"FREESURFER_HOME environmental variable is not "
172+
"set or if you are using an older version of "
173+
"FreeSurfer"))
155174
else:
156-
fs_vesion = fs_version_full.split('-')[-1]
157-
print("Warning: Workflow may not work properly if FREESURFER_HOME " +
158-
"environmental variable is not set or if you are using an older " +
159-
"version of FreeSurfer")
175+
fs_version = 5.3 # assume version 5.3
160176
th3 = False
161177
shrink = None
162178
distance = 50
@@ -165,7 +181,7 @@ def create_reconall_workflow(name="ReconAll", plugin_args=None):
165181
entorhinal = False
166182
rb_date = "2008-03-26"
167183

168-
print("FreeSurfer Version: {0}".format(fs_version))
184+
logger.info("FreeSurfer Version: {0}".format(fs_version))
169185

170186
def setconfig(reg_template=None,
171187
reg_template_withskull=None,

0 commit comments

Comments
 (0)