Skip to content

fix: to have recon-all work with 5.3 on OSX #1454

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 8 commits into from
Apr 26, 2016
Merged
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion nipype/interfaces/freesurfer/tests/test_auto_Sphere.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ def test_Sphere_inputs():
in_smoothwm=dict(copyfile=True,
),
magic=dict(argstr='-q',
requires=['in_smoothwm'],
),
num_threads=dict(),
out_file=dict(argstr='%s',
Expand Down
1 change: 0 additions & 1 deletion nipype/interfaces/freesurfer/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1668,7 +1668,6 @@ class SphereInputSpec(FSTraitedSpecOpenMP):
seed = traits.Int(argstr="-seed %d",
desc="Seed for setting random number generator")
magic = traits.Bool(argstr="-q",
requires=['in_smoothwm'],
desc="No documentation. Direct questions to analysis-bugs@nmr.mgh.harvard.edu")
in_smoothwm = File( exists=True, copyfile=True,
desc="Input surface required when -q flag is not selected")
Expand Down
2 changes: 1 addition & 1 deletion nipype/workflows/smri/freesurfer/autorecon3.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from nipype.interfaces.utility import IdentityInterface, Merge
from nipype.interfaces.utility import IdentityInterface, Merge, Function
import nipype.pipeline.engine as pe # pypeline engine
from nipype.interfaces.freesurfer import *
from .ba_maps import create_ba_maps_wf
Expand Down
38 changes: 27 additions & 11 deletions nipype/workflows/smri/freesurfer/recon.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from ....interfaces.freesurfer import AddXFormToHeader, Info
from ....interfaces.io import DataSink
from .utils import getdefaultconfig
from ....pipeline.engine.base import logger

def create_skullstripped_recon_flow(name="skullstripped_recon_all"):
"""Performs recon-all on voulmes that are already skull stripped.
Expand Down Expand Up @@ -84,9 +85,8 @@ def create_reconall_workflow(name="ReconAll", plugin_args=None):

Example
-------
>>> from nipype.workflows.smri.freesurfer import create_skullstripped_recon_flow
>>> import nipype.interfaces.freesurfer as fs
>>> recon_all = create_skullstripped_recon_flow()
>>> from nipype.workflows.smri.freesurfer import create_reconall_workflow
>>> recon_all = create_reconall_workflow()
>>> recon_all.inputs.inputspec.subject_id = 'subj1'
>>> recon_all.inputs.inputspec.subjects_dir = '.'
>>> recon_all.inputs.inputspec.T1_files = 'T1.nii.gz'
Expand All @@ -105,6 +105,17 @@ def create_reconall_workflow(name="ReconAll", plugin_args=None):
Outpus::
postdatasink_outputspec.subject_id : name of the datasinked output folder in the subjects directory

Note:
The input subject_id is not passed to the commands in the workflow. Commands
that require subject_id are reading implicit inputs from
{SUBJECTS_DIR}/{subject_id}. For those commands the subject_id is set to the
default value and SUBJECTS_DIR is set to the node directory. The implicit
inputs are then copied to the node directory in order to mimic a SUBJECTS_DIR
structure. For example, if the command implicitly reads in brainmask.mgz, the
interface would copy that input file to
{node_dir}/{subject_id}/mri/brainmask.mgz and set SUBJECTS_DIR to node_dir.
The workflow only uses the input subject_id to datasink the outputs to
{subjects_dir}/{subject_id}.
"""
reconall = pe.Workflow(name=name)

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

# check freesurfer version and set parameters
fs_version_full = Info.version()
if 'v6.0' in fs_version_full or 'dev' in fs_version_full:
if fs_version_full and ('v6.0' in fs_version_full or
'dev' in fs_version_full):
# assuming that dev is 6.0
fsvernum = 6.0
fs_version = 'v6.0'
Expand All @@ -150,13 +162,17 @@ def create_reconall_workflow(name="ReconAll", plugin_args=None):
else:
# 5.3 is default
fsvernum = 5.3
if 'v5.3' in fs_version_full:
fs_version = 'v5.3'
if fs_version_full:
if 'v5.3' in fs_version_full:
fs_version = 'v5.3'
else:
fs_version = fs_version_full.split('-')[-1]
logger.info(("Warning: Workflow may not work properly if "
"FREESURFER_HOME environmental variable is not "
"set or if you are using an older version of "
"FreeSurfer"))
else:
fs_vesion = fs_version_full.split('-')[-1]
print("Warning: Workflow may not work properly if FREESURFER_HOME " +
"environmental variable is not set or if you are using an older " +
"version of FreeSurfer")
fs_version = 5.3 # assume version 5.3
th3 = False
shrink = None
distance = 50
Expand All @@ -165,7 +181,7 @@ def create_reconall_workflow(name="ReconAll", plugin_args=None):
entorhinal = False
rb_date = "2008-03-26"

print("FreeSurfer Version: {0}".format(fs_version))
logger.info("FreeSurfer Version: {0}".format(fs_version))

def setconfig(reg_template=None,
reg_template_withskull=None,
Expand Down