Skip to content

Commit

Permalink
Merge pull request #761 from effigies/misc
Browse files Browse the repository at this point in the history
[RTM] Remove skull_strip_ants option, fix docstring
  • Loading branch information
oesteban committed Oct 17, 2017
2 parents 35c16a2 + fda6027 commit a536910
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 58 deletions.
2 changes: 0 additions & 2 deletions docs/workflows.rst
Expand Up @@ -26,7 +26,6 @@ slice-timing information and no fieldmap acquisitions):
reportlets_dir='.',
output_dir='.',
bids_dir='.',
skull_strip_ants=True,
skull_strip_template='OASIS',
template='MNI152NLin2009cAsym',
output_spaces=['T1w', 'fsnative',
Expand Down Expand Up @@ -63,7 +62,6 @@ T1w/T2w preprocessing
template='MNI152NLin2009cAsym',
output_spaces=['T1w', 'fsnative',
'template', 'fsaverage5'],
skull_strip_ants=True,
skull_strip_template='OASIS',
freesurfer=True,
longitudinal=False,
Expand Down
6 changes: 0 additions & 6 deletions fmriprep/cli/run.py
Expand Up @@ -141,11 +141,6 @@ def get_parser():
help='add ICA_AROMA to your preprocessing stream')
# ANTs options
g_ants = parser.add_argument_group('Specific options for ANTs registrations')
# g_ants.add_argument('--skull-strip-ants', dest="skull_strip_ants", action='store_true',
# help='use ANTs-based skull-stripping (default, slow))')
# g_ants.add_argument('--no-skull-strip-ants', dest="skull_strip_ants", action='store_false',
# help="don't use ANTs-based skull-stripping (use AFNI instead, fast)")
# g_ants.set_defaults(skull_strip_ants=True)
g_ants.add_argument('--skull-strip-template', action='store', default='OASIS',
choices=['OASIS', 'NKI'],
help='select ANTs skull-stripping template (default: OASIS))')
Expand Down Expand Up @@ -305,7 +300,6 @@ def create_workflow(opts):
anat_only=opts.anat_only,
longitudinal=opts.longitudinal,
omp_nthreads=omp_nthreads,
skull_strip_ants=True,
skull_strip_template=opts.skull_strip_template,
work_dir=work_dir,
output_dir=output_dir,
Expand Down
10 changes: 8 additions & 2 deletions fmriprep/interfaces/freesurfer.py
Expand Up @@ -67,8 +67,14 @@ class MakeMidthicknessInputSpec(fs.utils.MRIsExpandInputSpec):


class MakeMidthickness(fs.MRIsExpand):
""" Variation on RobustTemplate that simply copies the source if a single
volume is provided. """
""" Variation on MRIsExpand that checks for an existing midthickness/graymid
surface, and copies if available.
mris_expand is an expensive operation, so this avoids re-running it when the
working directory is lost.
If users provide their own midthickness/graymid file, we assume they have
created it correctly.
"""
input_spec = MakeMidthicknessInputSpec

@property
Expand Down
56 changes: 21 additions & 35 deletions fmriprep/workflows/anatomical.py
Expand Up @@ -32,7 +32,6 @@
from niworkflows.nipype.pipeline import engine as pe

from niworkflows.interfaces.registration import RobustMNINormalizationRPT
from niworkflows.anat.skullstrip import afni_wf as init_skullstrip_afni_wf
import niworkflows.data as nid
from niworkflows.interfaces.masks import BrainExtractionRPT
from niworkflows.interfaces.segmentation import FASTRPT, ReconAllRPT
Expand All @@ -46,7 +45,7 @@


# pylint: disable=R0914
def init_anat_preproc_wf(skull_strip_ants, skull_strip_template, output_spaces, template, debug,
def init_anat_preproc_wf(skull_strip_template, output_spaces, template, debug,
freesurfer, longitudinal, omp_nthreads, hires, reportlets_dir, output_dir,
name='anat_preproc_wf'):
r"""
Expand All @@ -71,7 +70,6 @@ def init_anat_preproc_wf(skull_strip_ants, skull_strip_template, output_spaces,
template='MNI152NLin2009cAsym',
output_spaces=['T1w', 'fsnative',
'template', 'fsaverage5'],
skull_strip_ants=True,
skull_strip_template='OASIS',
freesurfer=True,
longitudinal=False,
Expand All @@ -80,9 +78,6 @@ def init_anat_preproc_wf(skull_strip_ants, skull_strip_template, output_spaces,
**Parameters**
skull_strip_ants : bool
Use ANTs BrainExtraction.sh-based skull-stripping workflow.
If ``False``, uses a faster AFNI-based workflow
skull_strip_template : str
Name of ANTs skull-stripping template ('OASIS' or 'NKI')
output_spaces : list
Expand Down Expand Up @@ -201,13 +196,10 @@ def init_anat_preproc_wf(skull_strip_ants, skull_strip_template, output_spaces,
# Bias field correction is handled in skull strip workflows.

# 3. Skull-stripping
if skull_strip_ants:
skullstrip_wf = init_skullstrip_ants_wf(name='skullstrip_ants_wf',
skull_strip_template=skull_strip_template,
debug=debug,
omp_nthreads=omp_nthreads)
else:
skullstrip_wf = init_skullstrip_afni_wf(name='skullstrip_afni_wf')
skullstrip_ants_wf = init_skullstrip_ants_wf(name='skullstrip_ants_wf',
skull_strip_template=skull_strip_template,
debug=debug,
omp_nthreads=omp_nthreads)

# 4. Segmentation
t1_seg = pe.Node(FASTRPT(generate_report=True, segments=True,
Expand Down Expand Up @@ -267,11 +259,11 @@ def len_above_thresh(in_list, threshold, longitudinal):
(('out_file', len_above_thresh, 2, longitudinal), 'no_iteration'),
(('out_file', add_suffix, '_template'), 'out_file')]),
(t1_merge, t1_reorient, [('out_file', 'in_file')]),
(t1_reorient, skullstrip_wf, [('out_file', 'inputnode.in_file')]),
(skullstrip_wf, t1_seg, [('outputnode.out_file', 'in_files')]),
(skullstrip_wf, outputnode, [('outputnode.bias_corrected', 't1_preproc'),
('outputnode.out_file', 't1_brain'),
('outputnode.out_mask', 't1_mask')]),
(t1_reorient, skullstrip_ants_wf, [('out_file', 'inputnode.in_file')]),
(skullstrip_ants_wf, t1_seg, [('outputnode.out_file', 'in_files')]),
(skullstrip_ants_wf, outputnode, [('outputnode.bias_corrected', 't1_preproc'),
('outputnode.out_file', 't1_brain'),
('outputnode.out_mask', 't1_mask')]),
(t1_seg, outputnode, [('tissue_class_map', 't1_seg'),
('probability_maps', 't1_tpms')]),
])
Expand All @@ -286,9 +278,9 @@ def len_above_thresh(in_list, threshold, longitudinal):
mni_tpms.inputs.reference_image = ref_img

workflow.connect([
(skullstrip_wf, t1_2_mni, [('outputnode.bias_corrected', 'moving_image')]),
(skullstrip_wf, t1_2_mni, [('outputnode.out_mask', 'moving_mask')]),
(skullstrip_wf, mni_mask, [('outputnode.out_mask', 'input_image')]),
(skullstrip_ants_wf, t1_2_mni, [('outputnode.bias_corrected', 'moving_image')]),
(skullstrip_ants_wf, t1_2_mni, [('outputnode.out_mask', 'moving_mask')]),
(skullstrip_ants_wf, mni_mask, [('outputnode.out_mask', 'input_image')]),
(t1_2_mni, mni_mask, [('composite_transform', 'transforms')]),
(t1_seg, mni_seg, [('tissue_class_map', 'input_image')]),
(t1_2_mni, mni_seg, [('composite_transform', 'transforms')]),
Expand All @@ -314,7 +306,7 @@ def len_above_thresh(in_list, threshold, longitudinal):
('subjects_dir', 'inputnode.subjects_dir'),
('subject_id', 'inputnode.subject_id')]),
(t1_reorient, surface_recon_wf, [('out_file', 'inputnode.t1w')]),
(skullstrip_wf, surface_recon_wf, [
(skullstrip_ants_wf, surface_recon_wf, [
('outputnode.out_file', 'inputnode.skullstripped_t1')]),
(surface_recon_wf, outputnode, [
('outputnode.subjects_dir', 'subjects_dir'),
Expand All @@ -324,21 +316,18 @@ def len_above_thresh(in_list, threshold, longitudinal):
])

anat_reports_wf = init_anat_reports_wf(
reportlets_dir=reportlets_dir, skull_strip_ants=skull_strip_ants,
output_spaces=output_spaces, template=template, freesurfer=freesurfer)
reportlets_dir=reportlets_dir, output_spaces=output_spaces, template=template,
freesurfer=freesurfer)
workflow.connect([
(inputnode, anat_reports_wf, [
(('t1w', fix_multi_T1w_source_name), 'inputnode.source_file')]),
(t1_template_dimensions, anat_reports_wf, [
('out_report', 'inputnode.t1_conform_report')]),
(skullstrip_ants_wf, anat_reports_wf, [
('outputnode.out_report', 'inputnode.t1_skull_strip_report')]),
(t1_seg, anat_reports_wf, [('out_report', 'inputnode.t1_seg_report')]),
])

if skull_strip_ants:
workflow.connect([
(skullstrip_wf, anat_reports_wf, [
('outputnode.out_report', 'inputnode.t1_skull_strip_report')])
])
if freesurfer:
workflow.connect([
(surface_recon_wf, anat_reports_wf, [
Expand Down Expand Up @@ -804,7 +793,7 @@ def init_gifti_surface_wf(name='gifti_surface_wf'):
return workflow


def init_anat_reports_wf(reportlets_dir, skull_strip_ants, output_spaces,
def init_anat_reports_wf(reportlets_dir, output_spaces,
template, freesurfer, name='anat_reports_wf'):
"""
Set up a battery of datasinks to store reports in the right location
Expand Down Expand Up @@ -840,15 +829,12 @@ def init_anat_reports_wf(reportlets_dir, skull_strip_ants, output_spaces,
workflow.connect([
(inputnode, ds_t1_conform_report, [('source_file', 'source_file'),
('t1_conform_report', 'in_file')]),
(inputnode, ds_t1_skull_strip_report, [('source_file', 'source_file'),
('t1_skull_strip_report', 'in_file')]),
(inputnode, ds_t1_seg_report, [('source_file', 'source_file'),
('t1_seg_report', 'in_file')]),
])

if skull_strip_ants:
workflow.connect([
(inputnode, ds_t1_skull_strip_report, [('source_file', 'source_file'),
('t1_skull_strip_report', 'in_file')])
])
if freesurfer:
workflow.connect([
(inputnode, ds_recon_report, [('source_file', 'source_file'),
Expand Down
14 changes: 2 additions & 12 deletions fmriprep/workflows/base.py
Expand Up @@ -32,7 +32,7 @@

def init_fmriprep_wf(subject_list, task_id, run_uuid,
ignore, debug, low_mem, anat_only, longitudinal, omp_nthreads,
skull_strip_ants, skull_strip_template, work_dir, output_dir, bids_dir,
skull_strip_template, work_dir, output_dir, bids_dir,
freesurfer, output_spaces, template, medial_surface_nan, hires,
use_bbr, bold2t1w_dof, fmap_bspline, fmap_demean, use_syn, force_syn,
use_aroma, ignore_aroma_err, output_grid_ref):
Expand All @@ -57,7 +57,6 @@ def init_fmriprep_wf(subject_list, task_id, run_uuid,
anat_only=False,
longitudinal=False,
omp_nthreads=1,
skull_strip_ants=True,
skull_strip_template='OASIS',
work_dir='.',
output_dir='.',
Expand Down Expand Up @@ -100,9 +99,6 @@ def init_fmriprep_wf(subject_list, task_id, run_uuid,
See sub-workflows for specific differences
omp_nthreads : int
Maximum number of threads an individual process may use
skull_strip_ants : bool
Use ANTs BrainExtraction.sh-based skull-stripping workflow
If ``False``, uses a faster AFNI-based workflow
skull_strip_template : str
Name of ANTs skull-stripping template ('OASIS' or 'NKI')
work_dir : str
Expand Down Expand Up @@ -173,7 +169,6 @@ def init_fmriprep_wf(subject_list, task_id, run_uuid,
anat_only=anat_only,
longitudinal=longitudinal,
omp_nthreads=omp_nthreads,
skull_strip_ants=skull_strip_ants,
skull_strip_template=skull_strip_template,
reportlets_dir=reportlets_dir,
output_dir=output_dir,
Expand Down Expand Up @@ -209,7 +204,7 @@ def init_fmriprep_wf(subject_list, task_id, run_uuid,

def init_single_subject_wf(subject_id, task_id, name,
ignore, debug, low_mem, anat_only, longitudinal, omp_nthreads,
skull_strip_ants, skull_strip_template, reportlets_dir, output_dir,
skull_strip_template, reportlets_dir, output_dir,
bids_dir, freesurfer, output_spaces, template, medial_surface_nan,
hires, use_bbr, bold2t1w_dof, fmap_bspline, fmap_demean, use_syn,
force_syn, output_grid_ref, use_aroma, ignore_aroma_err):
Expand Down Expand Up @@ -237,7 +232,6 @@ def init_single_subject_wf(subject_id, task_id, name,
reportlets_dir='.',
output_dir='.',
bids_dir='.',
skull_strip_ants=True,
skull_strip_template='OASIS',
template='MNI152NLin2009cAsym',
output_spaces=['T1w', 'fsnative',
Expand Down Expand Up @@ -279,9 +273,6 @@ def init_single_subject_wf(subject_id, task_id, name,
See sub-workflows for specific differences
omp_nthreads : int
Maximum number of threads an individual process may use
skull_strip_ants : bool
Use ANTs BrainExtraction.sh-based skull-stripping workflow
If ``False``, uses a faster AFNI-based workflow
skull_strip_template : str
Name of ANTs skull-stripping template ('OASIS' or 'NKI')
reportlets_dir : str
Expand Down Expand Up @@ -384,7 +375,6 @@ def init_single_subject_wf(subject_id, task_id, name,

# Preprocessing of T1w (includes registration to MNI)
anat_preproc_wf = init_anat_preproc_wf(name="anat_preproc_wf",
skull_strip_ants=skull_strip_ants,
skull_strip_template=skull_strip_template,
output_spaces=output_spaces,
template=template,
Expand Down
1 change: 0 additions & 1 deletion fmriprep/workflows/tests/test_base.py
Expand Up @@ -20,7 +20,6 @@ def test_single_subject_wf(self, _):
anat_only=False,
longitudinal=False,
omp_nthreads=1,
skull_strip_ants=False,
skull_strip_template='OASIS',
reportlets_dir='.',
output_dir='.',
Expand Down

0 comments on commit a536910

Please sign in to comment.