Skip to content

Commit 3a5e190

Browse files
committed
Merge pull request #839 from chrisfilo/enh/recon_skullstrip
Added new workflow for doing recon all on skullstripped data.
2 parents 9099a58 + 715a536 commit 3a5e190

File tree

4 files changed

+79
-2
lines changed

4 files changed

+79
-2
lines changed

CHANGES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Next Release
33

44
* API: Interfaces to external packages are no longer available in the top-level ``nipype`` namespace, and must be imported directly (e.g. ``from nipype.interfaces import fsl``).
55
* ENH: New ANTs interface: ApplyTransformsToPoints
6+
* ENH: New FreeSurfer workflow: create_skullstripped_recon_flow()
67
* FIX: MRTrix tracking algorithms were ignoring mask parameters.
78

89
Release 0.9.2 (January 31, 2014)

nipype/interfaces/freesurfer/preprocess.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -649,8 +649,7 @@ class ReconAll(CommandLine):
649649
('nuintensitycor', ['mri/nu.mgz']),
650650
('normalization', ['mri/T1.mgz']),
651651
('skullstrip',
652-
['mri/transforms/talairach_with_skull.lta',
653-
'mri/brainmask.auto.mgz',
652+
['mri/brainmask.auto.mgz',
654653
'mri/brainmask.mgz']),
655654
#autorecon2
656655
('gcareg', ['mri/transforms/talairach.lta']),
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
from .utils import (create_getmask_flow, create_get_stats_flow, create_tessellation_flow)
22
from .bem import create_bem_flow
3+
from .recon import create_skullstripped_recon_flow
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import nipype.pipeline.engine as pe
2+
import nipype.interfaces.freesurfer as fs
3+
import nipype.interfaces.utility as niu
4+
5+
def create_skullstripped_recon_flow(name="skullstripped_recon_all"):
6+
"""Performs recon-all on voulmes that are already skull stripped.
7+
FreeSurfer failes to perform skullstrippig on some volumes (especially
8+
MP2RAGE). This can be avoided by doing skullstripping before runnig recon-all
9+
(using for example SPECTRE algorithm)
10+
11+
Example
12+
-------
13+
>>> from nipype.workflows.smri.freesurfer import create_skullstripped_recon_flow
14+
>>> recon_flow = create_skullstripped_recon_flow()
15+
>>> recon_flow.inputs.inputspec.subject_id = 'subj1'
16+
>>> recon_flow.inputs.inputspec.T1_files = 'T1.nii.gz'
17+
>>> recon_flow.run() # doctest: +SKIP
18+
19+
20+
Inputs::
21+
inputspec.T1_files : skullstripped T1_files (mandatory)
22+
inputspec.subject_id : freesurfer subject id (optional)
23+
inputspec.subjects_dir : freesurfer subjects directory (optional)
24+
25+
Outputs::
26+
27+
outputspec.subject_id : freesurfer subject id
28+
outputspec.subjects_dir : freesurfer subjects directory
29+
"""
30+
wf = pe.Workflow(name=name)
31+
32+
inputnode = pe.Node(niu.IdentityInterface(fields=['subject_id',
33+
'subjects_dir',
34+
'T1_files']),
35+
name='inputspec')
36+
37+
autorecon1 = pe.Node(fs.ReconAll(), name="autorecon1")
38+
autorecon1.plugin_args={'submit_specs': 'request_memory = 2500'}
39+
autorecon1.inputs.directive = "autorecon1"
40+
autorecon1.inputs.args = "-noskullstrip"
41+
autorecon1._interface._can_resume = False
42+
43+
wf.connect(inputnode, "T1_files", autorecon1, "T1_files")
44+
wf.connect(inputnode, "subjects_dir", autorecon1, "subjects_dir")
45+
wf.connect(inputnode, "subject_id", autorecon1, "subject_id")
46+
47+
48+
def link_masks(subjects_dir, subject_id):
49+
import os
50+
os.symlink(os.path.join(subjects_dir, subject_id, "mri", "T1.mgz"),
51+
os.path.join(subjects_dir, subject_id, "mri", "brainmask.auto.mgz"))
52+
os.symlink(os.path.join(subjects_dir, subject_id, "mri", "brainmask.auto.mgz"),
53+
os.path.join(subjects_dir, subject_id, "mri", "brainmask.mgz"))
54+
return subjects_dir, subject_id
55+
56+
masks = pe.Node(niu.Function(input_names=['subjects_dir', 'subject_id'],
57+
output_names=['subjects_dir', 'subject_id'],
58+
function=link_masks), name="link_masks")
59+
60+
wf.connect(autorecon1, "subjects_dir", masks, "subjects_dir")
61+
wf.connect(autorecon1, "subject_id", masks, "subject_id")
62+
63+
64+
autorecon_resume = pe.Node(fs.ReconAll(), name="autorecon_resume")
65+
autorecon_resume.plugin_args={'submit_specs': 'request_memory = 2500'}
66+
autorecon_resume.inputs.args = "-no-isrunning"
67+
wf.connect(masks, "subjects_dir", autorecon_resume, "subjects_dir")
68+
wf.connect(masks, "subject_id", autorecon_resume, "subject_id")
69+
70+
outputnode = pe.Node(niu.IdentityInterface(fields=['subject_id',
71+
'subjects_dir']),
72+
name='outputspec')
73+
74+
wf.connect(autorecon_resume, "subjects_dir", outputnode, "subjects_dir")
75+
wf.connect(autorecon_resume, "subject_id", outputnode, "subject_id")
76+
return wf

0 commit comments

Comments
 (0)