Skip to content

Commit

Permalink
RF: Switch to more targeted morphometry datasinks
Browse files Browse the repository at this point in the history
  • Loading branch information
effigies committed Oct 2, 2023
1 parent b49ac4c commit 3b5b230
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 36 deletions.
13 changes: 9 additions & 4 deletions smriprep/workflows/anatomical.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,9 @@ def init_anat_preproc_wf(
ds_surfaces_wf = init_ds_surfaces_wf(
bids_root=bids_root, output_dir=output_dir, surfaces=["inflated"]
)
ds_curv_wf = init_ds_surface_metrics_wf(

Check warning on line 315 in smriprep/workflows/anatomical.py

View check run for this annotation

Codecov / codecov/patch

smriprep/workflows/anatomical.py#L315

Added line #L315 was not covered by tests
bids_root=bids_root, output_dir=output_dir, metrics=["curv"], name="ds_curv_wf"
)

# fmt:off
workflow.connect([
Expand All @@ -320,18 +323,20 @@ def init_anat_preproc_wf(
('outputnode.subjects_dir', 'inputnode.subjects_dir'),
('outputnode.subject_id', 'inputnode.subject_id'),
('outputnode.fsnative2t1w_xfm', 'inputnode.fsnative2t1w_xfm'),
# Just for collation. These can probably go away at some point.
('outputnode.thickness', 'inputnode.thickness'),
('outputnode.sulc', 'inputnode.sulc'),
]),
(anat_fit_wf, ds_surfaces_wf, [
('outputnode.t1w_valid_list', 'inputnode.source_files'),
]),
(surface_derivatives_wf, ds_surfaces_wf, [
('outputnode.inflated', 'inputnode.inflated'),
]),
(anat_fit_wf, ds_curv_wf, [
('outputnode.t1w_valid_list', 'inputnode.source_files'),
]),
(surface_derivatives_wf, ds_curv_wf, [
('outputnode.curv', 'inputnode.curv'),
]),
(surface_derivatives_wf, anat_second_derivatives_wf, [
('outputnode.morphometrics', 'inputnode.morphometrics'),
('outputnode.out_aseg', 'inputnode.t1w_fs_aseg'),
('outputnode.out_aparc', 'inputnode.t1w_fs_aparc'),
('outputnode.cifti_morph', 'inputnode.cifti_morph'),
Expand Down
22 changes: 0 additions & 22 deletions smriprep/workflows/outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,6 @@ def init_anat_second_derivatives_wf(
"anat2std_xfm",
"sphere_reg",
"sphere_reg_fsLR",
"morphometrics",
"t1w_fs_aseg",
"t1w_fs_aparc",
"cifti_morph",
Expand Down Expand Up @@ -1011,22 +1010,6 @@ def init_anat_second_derivatives_wf(
if not freesurfer:
return workflow

from niworkflows.interfaces.surf import Path2BIDS

# Morphometrics
name_morphs = pe.MapNode(
Path2BIDS(),
iterfield="in_file",
name="name_morphs",
run_without_submitting=True,
)
ds_morphs = pe.MapNode(
DerivativesDataSink(base_directory=output_dir, extension=".shape.gii"),
iterfield=["in_file", "hemi", "suffix"],
name="ds_morphs",
run_without_submitting=True,
)

# Parcellations
ds_t1w_fsaseg = pe.Node(
DerivativesDataSink(base_directory=output_dir, desc="aseg", suffix="dseg", compress=True),
Expand All @@ -1043,11 +1026,6 @@ def init_anat_second_derivatives_wf(

# fmt:off
workflow.connect([
(inputnode, name_morphs, [('morphometrics', 'in_file')]),
(inputnode, ds_morphs, [('morphometrics', 'in_file'),
('source_files', 'source_file')]),
(name_morphs, ds_morphs, [('hemi', 'hemi'),
('suffix', 'suffix')]),
(inputnode, ds_t1w_fsaseg, [('t1w_fs_aseg', 'in_file'),
('source_files', 'source_file')]),
(inputnode, ds_t1w_fsparc, [('t1w_fs_aparc', 'in_file'),
Expand Down
12 changes: 2 additions & 10 deletions smriprep/workflows/surfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,8 +630,6 @@ def init_surface_derivatives_wf(
"subject_id",
"fsnative2t1w_xfm",
"reference",
"thickness",
"sulc",
]
),
name="inputnode",
Expand All @@ -640,7 +638,7 @@ def init_surface_derivatives_wf(
niu.IdentityInterface(
fields=[
"inflated",
"morphometrics",
"curv",
"out_aseg",
"out_aparc",
"cifti_morph",
Expand All @@ -655,8 +653,6 @@ def init_surface_derivatives_wf(
aseg_to_native_wf = init_segs_to_native_wf()
aparc_to_native_wf = init_segs_to_native_wf(segmentation="aparc_aseg")

all_morph = pe.Node(niu.Merge(3), name="all_morph")

# fmt:off
workflow.connect([
# Configuration
Expand All @@ -682,15 +678,11 @@ def init_surface_derivatives_wf(
('fsnative2t1w_xfm', 'inputnode.fsnative2t1w_xfm'),
]),

# Collate morphometry from inputnode and workflows
(inputnode, all_morph, [('thickness', 'in1'), ('sulc', 'in2')]),
(gifti_morph_wf, all_morph, [('outputnode.curv', 'in3')]),

# Output
(gifti_surfaces_wf, outputnode, [('outputnode.inflated', 'inflated')]),
(aseg_to_native_wf, outputnode, [('outputnode.out_file', 'out_aseg')]),
(aparc_to_native_wf, outputnode, [('outputnode.out_file', 'out_aparc')]),
(all_morph, outputnode, [('out', 'morphometrics')]),
(gifti_morph_wf, outputnode, [('outputnode.curv', 'curv')]),
])
# fmt:on

Expand Down

0 comments on commit 3b5b230

Please sign in to comment.