Skip to content
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

Add subcortical figures for infant data to executive summary #945

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
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
8 changes: 4 additions & 4 deletions xcp_d/interfaces/execsummary.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,14 @@ def collect_inputs(self):
ANAT_REGISTRATION_DESCS = [
"AtlasOnAnat",
"AnatOnAtlas",
# "AtlasOnSubcorticals",
# "SubcorticalsOnAtlas",
"AtlasOnSubcorticals",
"SubcorticalsOnAtlas",
]
ANAT_REGISTRATION_TITLES = [
"Atlas On {modality}", # noqa: FS003
"{modality} On Atlas", # noqa: FS003
# "Atlas On {modality} Subcorticals", # noqa: FS003
# "{modality} Subcorticals On Atlas", # noqa: FS003
"Atlas On {modality} Subcorticals", # noqa: FS003
"{modality} Subcorticals On Atlas", # noqa: FS003
]
TASK_REGISTRATION_DESCS = [
"TaskOnT1w",
Expand Down
1 change: 1 addition & 0 deletions xcp_d/workflows/anatomical.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ def init_postprocess_anat_wf(
# fmt:on

execsummary_anatomical_plots_wf = init_execsummary_anatomical_plots_wf(
input_type=input_type,
t1w_available=t1w_available,
t2w_available=t2w_available,
)
Expand Down
64 changes: 60 additions & 4 deletions xcp_d/workflows/execsummary.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,7 @@ def init_execsummary_functional_plots_wf(

@fill_doc
def init_execsummary_anatomical_plots_wf(
input_type,
t1w_available,
t2w_available,
name="execsummary_anatomical_plots_wf",
Expand All @@ -539,12 +540,14 @@ def init_execsummary_anatomical_plots_wf(

with mock_config():
wf = init_execsummary_anatomical_plots_wf(
input_type="nibabies",
t1w_available=True,
t2w_available=True,
)

Parameters
----------
%(input_type)s
t1w_available : bool
Generally True.
t2w_available : bool
Expand All @@ -561,6 +564,8 @@ def init_execsummary_anatomical_plots_wf(
"""
workflow = Workflow(name=name)

output_dir = config.execution.xcp_d_dir

inputnode = pe.Node(
niu.IdentityInterface(
fields=[
Expand Down Expand Up @@ -622,8 +627,45 @@ def init_execsummary_anatomical_plots_wf(
])
# fmt:on

# TODO: Add subcortical overlay images as well.
# 1. Binarize atlas.
# Add subcortical overlay images as well.
if input_type == "nibabies":
# 1. TODO: Binarize atlas.

plot_subcort_on_atlas_wf = init_plot_custom_slices_wf(
output_dir=output_dir,
desc="SubcorticalsOnAtlas",
name="plot_subcort_on_atlas_wf",
)

# fmt:off
workflow.connect([
(inputnode, plot_subcort_on_atlas_wf, [
(anat, "inputnode.name_source"),
("template", "inputnode.overlay_file"),
]),
(resample_anat, plot_subcort_on_atlas_wf, [
("out_file", "inputnode.underlay_file"),
]),
])
# fmt:on

plot_atlas_on_subcort_wf = init_plot_custom_slices_wf(
output_dir=output_dir,
desc="AtlasOnSubcorticals",
name="plot_atlas_on_subcort_wf",
)

# fmt:off
workflow.connect([
(inputnode, plot_atlas_on_subcort_wf, [
(anat, "inputnode.name_source"),
("template", "inputnode.underlay_file"),
]),
(resample_anat, plot_atlas_on_subcort_wf, [
("out_file", "inputnode.overlay_file"),
]),
])
# fmt:on

return workflow

Expand All @@ -636,8 +678,7 @@ def init_plot_custom_slices_wf(
):
"""Plot a custom selection of slices with Slicer.

This workflow is used to produce subcortical registration plots specifically for
infant data.
This workflow is used to produce subcortical registration plots specifically for infant data.

Workflow Graph
.. workflow::
Expand Down Expand Up @@ -665,6 +706,21 @@ def init_plot_custom_slices_wf(
underlay_file
overlay_file
name_source

Notes
-----
1. Grab sub2atl_ROI.2.nii.gz from DCAN infant pipeline derivatives.
- TODO: Find the equivalent file from nibabies.
2. Grab Atlas_ROIs.2.nii.gz from DCAN infant pipeline derivatives.
- TODO: Find the equivalent file from nibabies.
3. Binarize Atlas_ROIs.2.nii.gz.
4. Use slicer to overlay sub2atl_ROI.2.nii.gz onto the binarized Atlas_ROIs.2.nii.gz for
3 x slices, 3 y slices, and 3 z slices.
5. Combine the 9 slice images into a single gif with pngappend.
6. Binarize sub2atl_ROI.2.nii.gz.
7. Use slicer to overlay Atlas_ROIs.2.nii.gz onto the binarized sub2atl_ROI.2.nii.gz for
3 x slices, 3 y slices, and 3 z slices.
8. Combine the 9 slice images into a single gif with pngappend.
"""
# NOTE: These slices are almost certainly specific to a given MNI template and resolution.
SINGLE_SLICES = ["x", "x", "x", "y", "y", "y", "z", "z", "z"]
Expand Down