Skip to content

Commit

Permalink
Merge pull request #569 from effigies/fix/probtissue
Browse files Browse the repository at this point in the history
[RTM] ENH: Output T1-space tissue probability maps, MNI-space segmentations
  • Loading branch information
effigies committed Jun 20, 2017
2 parents 6ce3f53 + ff9f703 commit 6bf9739
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Expand Up @@ -2,6 +2,7 @@ Next release
============

* [ENH] Add --anat-only workflow option (#560)
* [FIX] Output all tissue class/probability maps (#569)

0.4.6 (14th of June 2017)
=========================
Expand Down
39 changes: 33 additions & 6 deletions fmriprep/workflows/anatomical.py
Expand Up @@ -43,7 +43,7 @@ def init_anat_preproc_wf(skull_strip_ants, output_spaces, template, debug, frees
outputnode = pe.Node(niu.IdentityInterface(
fields=['t1_preproc', 't1_brain', 't1_mask', 't1_seg', 't1_tpms',
't1_2_mni', 't1_2_mni_forward_transform', 't1_2_mni_reverse_transform',
'mni_mask', 'mni_tpms',
'mni_mask', 'mni_seg', 'mni_tpms',
'subjects_dir', 'subject_id', 'fs_2_t1_transform', 'surfaces']),
name='outputnode')

Expand Down Expand Up @@ -96,6 +96,12 @@ def init_anat_preproc_wf(skull_strip_ants, output_spaces, template, debug, frees
name='mni_mask'
)

mni_seg = pe.Node(
ants.ApplyTransforms(dimension=3, default_value=0, float=True,
interpolation='NearestNeighbor'),
name='mni_seg'
)

mni_tpms = pe.MapNode(
ants.ApplyTransforms(dimension=3, default_value=0, float=True,
interpolation='Linear'),
Expand All @@ -121,20 +127,24 @@ def init_anat_preproc_wf(skull_strip_ants, output_spaces, template, debug, frees

t1_2_mni.inputs.template = template_str
mni_mask.inputs.reference_image = ref_img
mni_seg.inputs.reference_image = ref_img
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')]),
(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')]),
(t1_seg, mni_tpms, [('probability_maps', 'input_image')]),
(t1_2_mni, mni_tpms, [('composite_transform', 'transforms')]),
(t1_2_mni, outputnode, [
('warped_image', 't1_2_mni'),
('composite_transform', 't1_2_mni_forward_transform'),
('inverse_composite_transform', 't1_2_mni_reverse_transform')]),
(mni_mask, outputnode, [('output_image', 'mni_mask')]),
(mni_seg, outputnode, [('output_image', 'mni_seg')]),
(mni_tpms, outputnode, [('output_image', 'mni_tpms')]),
])

Expand Down Expand Up @@ -193,9 +203,11 @@ def init_anat_preproc_wf(skull_strip_ants, output_spaces, template, debug, frees
('t1_preproc', 'inputnode.t1_preproc'),
('t1_mask', 'inputnode.t1_mask'),
('t1_seg', 'inputnode.t1_seg'),
('t1_tpms', 'inputnode.t1_tpms'),
('t1_2_mni_forward_transform', 'inputnode.t1_2_mni_forward_transform'),
('t1_2_mni', 'inputnode.t1_2_mni'),
('mni_mask', 'inputnode.mni_mask'),
('mni_seg', 'inputnode.mni_seg'),
('mni_tpms', 'inputnode.mni_tpms'),
('surfaces', 'inputnode.surfaces'),
]),
Expand Down Expand Up @@ -599,22 +611,28 @@ def init_anat_derivatives_wf(output_dir, output_spaces, template, freesurfer,

inputnode = pe.Node(
niu.IdentityInterface(
fields=['source_file', 't1_preproc', 't1_mask', 't1_seg',
fields=['source_file', 't1_preproc', 't1_mask', 't1_seg', 't1_tpms',
't1_2_mni_forward_transform', 't1_2_mni', 'mni_mask',
'mni_tpms', 'surfaces']),
'mni_seg', 'mni_tpms', 'surfaces']),
name='inputnode')

ds_t1_preproc = pe.Node(
DerivativesDataSink(base_directory=output_dir, suffix='preproc'),
name='ds_t1_preproc', run_without_submitting=True)

ds_t1_mask = pe.Node(
DerivativesDataSink(base_directory=output_dir, suffix='brainmask'),
name='ds_t1_mask', run_without_submitting=True)

ds_t1_seg = pe.Node(
DerivativesDataSink(base_directory=output_dir, suffix='dtissue'),
name='ds_t1_seg', run_without_submitting=True)

ds_t1_mask = pe.Node(
DerivativesDataSink(base_directory=output_dir, suffix='brainmask'),
name='ds_t1_mask', run_without_submitting=True)
ds_t1_tpms = pe.Node(
DerivativesDataSink(base_directory=output_dir,
suffix='class-{extra_value}_probtissue'),
name='ds_t1_tpms', run_without_submitting=True)
ds_t1_tpms.inputs.extra_values = ['CSF', 'GM', 'WM']

suffix_fmt = 'space-{}_{}'.format
ds_t1_mni = pe.Node(
Expand All @@ -627,6 +645,11 @@ def init_anat_derivatives_wf(output_dir, output_spaces, template, freesurfer,
suffix=suffix_fmt(template, 'brainmask')),
name='ds_mni_mask', run_without_submitting=True)

ds_mni_seg = pe.Node(
DerivativesDataSink(base_directory=output_dir,
suffix=suffix_fmt(template, 'dtissue')),
name='ds_mni_seg', run_without_submitting=True)

ds_mni_tpms = pe.Node(
DerivativesDataSink(base_directory=output_dir,
suffix=suffix_fmt(template, 'class-{extra_value}_probtissue')),
Expand Down Expand Up @@ -660,6 +683,8 @@ def get_gifti_name(in_file):
('t1_mask', 'in_file')]),
(inputnode, ds_t1_seg, [('source_file', 'source_file'),
('t1_seg', 'in_file')]),
(inputnode, ds_t1_tpms, [('source_file', 'source_file'),
('t1_tpms', 'in_file')]),
])

if freesurfer:
Expand All @@ -677,6 +702,8 @@ def get_gifti_name(in_file):
('t1_2_mni', 'in_file')]),
(inputnode, ds_mni_mask, [('source_file', 'source_file'),
('mni_mask', 'in_file')]),
(inputnode, ds_mni_seg, [('source_file', 'source_file'),
('mni_seg', 'in_file')]),
(inputnode, ds_mni_tpms, [('source_file', 'source_file'),
('mni_tpms', 'in_file')]),
])
Expand Down

0 comments on commit 6bf9739

Please sign in to comment.