From ac3b2c5a7207a2afda5718ea07ee8058eeac9eeb Mon Sep 17 00:00:00 2001 From: Taylor Salo Date: Fri, 22 Sep 2023 13:10:59 -0400 Subject: [PATCH 1/4] Add subcort-on-atlas figures. --- xcp_d/workflows/anatomical.py | 1 + xcp_d/workflows/execsummary.py | 41 ++++++++++++++++++++++++++++++++-- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/xcp_d/workflows/anatomical.py b/xcp_d/workflows/anatomical.py index e91feac5e..458cc54e9 100644 --- a/xcp_d/workflows/anatomical.py +++ b/xcp_d/workflows/anatomical.py @@ -277,6 +277,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, output_dir=output_dir, diff --git a/xcp_d/workflows/execsummary.py b/xcp_d/workflows/execsummary.py index f98b66aab..78061f7b3 100644 --- a/xcp_d/workflows/execsummary.py +++ b/xcp_d/workflows/execsummary.py @@ -581,6 +581,7 @@ def init_execsummary_functional_plots_wf( @fill_doc def init_execsummary_anatomical_plots_wf( + input_type, t1w_available, t2w_available, output_dir, @@ -596,6 +597,7 @@ def init_execsummary_anatomical_plots_wf( from xcp_d.workflows.execsummary import init_execsummary_anatomical_plots_wf wf = init_execsummary_anatomical_plots_wf( + input_type="nibabies", t1w_available=True, t2w_available=True, output_dir=".", @@ -604,6 +606,7 @@ def init_execsummary_anatomical_plots_wf( Parameters ---------- + %(input_type)s t1w_available : bool Generally True. t2w_available : bool @@ -684,6 +687,41 @@ def init_execsummary_anatomical_plots_wf( ]) # fmt:on + if input_type == "nibabies": + plot_subcort_on_atlas_wf = init_plot_custom_slices_wf( + output_dir=output_dir, + desc="SubcorticalOnAtlas", + name="plot_subcort_on_atlas_wf", + ) + + # fmt:off + workflow.connect([ + (inputnode, plot_subcort_on_atlas_wf, [ + ("t1w", "inputnode.name_source"), + ("template", "inputnode.overlay_file"), + ]), + (resample_t1w, plot_subcort_on_atlas_wf, [ + ("out_file", "inputnode.underlay_file"), + ]), + ]) + # fmt:on + + plot_t1w_on_subcort_wf = init_plot_custom_slices_wf( + output_dir=output_dir, + desc="T1wOnSubcortical", + name="plot_t1w_on_subcort_wf", + ) + + # fmt:off + workflow.connect([ + (inputnode, plot_t1w_on_subcort_wf, [ + ("t1w", "inputnode.name_source"), + ("template", "inputnode.underlay_file"), + ]), + (resample_t1w, plot_t1w_on_subcort_wf, [("out_file", "inputnode.overlay_file")]), + ]) + # fmt:on + # Atlas in T2w, T2w in Atlas if t2w_available: # Resample T2w to match resolution of template data @@ -751,8 +789,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:: From 8404afc59a4ec7b66ade3ffb378fa7e6c1a84b4b Mon Sep 17 00:00:00 2001 From: Taylor Salo Date: Fri, 22 Sep 2023 13:55:01 -0400 Subject: [PATCH 2/4] Update execsummary.py --- xcp_d/workflows/execsummary.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/xcp_d/workflows/execsummary.py b/xcp_d/workflows/execsummary.py index 78061f7b3..961d75593 100644 --- a/xcp_d/workflows/execsummary.py +++ b/xcp_d/workflows/execsummary.py @@ -690,7 +690,7 @@ def init_execsummary_anatomical_plots_wf( if input_type == "nibabies": plot_subcort_on_atlas_wf = init_plot_custom_slices_wf( output_dir=output_dir, - desc="SubcorticalOnAtlas", + desc="SubcorticalsOnAtlas", name="plot_subcort_on_atlas_wf", ) @@ -706,19 +706,19 @@ def init_execsummary_anatomical_plots_wf( ]) # fmt:on - plot_t1w_on_subcort_wf = init_plot_custom_slices_wf( + plot_atlas_on_subcort_wf = init_plot_custom_slices_wf( output_dir=output_dir, - desc="T1wOnSubcortical", + desc="AtlasOnSubcorticals", name="plot_t1w_on_subcort_wf", ) # fmt:off workflow.connect([ - (inputnode, plot_t1w_on_subcort_wf, [ + (inputnode, plot_atlas_on_subcort_wf, [ ("t1w", "inputnode.name_source"), ("template", "inputnode.underlay_file"), ]), - (resample_t1w, plot_t1w_on_subcort_wf, [("out_file", "inputnode.overlay_file")]), + (resample_t1w, plot_atlas_on_subcort_wf, [("out_file", "inputnode.overlay_file")]), ]) # fmt:on From 6533a397580ffae27a3434085118c045023fff19 Mon Sep 17 00:00:00 2001 From: Taylor Salo Date: Tue, 26 Sep 2023 13:12:38 -0400 Subject: [PATCH 3/4] Document the subcort plot workflow. --- xcp_d/workflows/execsummary.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/xcp_d/workflows/execsummary.py b/xcp_d/workflows/execsummary.py index b87ed0a72..4760756f3 100644 --- a/xcp_d/workflows/execsummary.py +++ b/xcp_d/workflows/execsummary.py @@ -698,6 +698,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"] From 74bdd87027528bc503fa619c2830fb11bc9ce34a Mon Sep 17 00:00:00 2001 From: Taylor Salo Date: Tue, 16 Apr 2024 13:42:55 -0400 Subject: [PATCH 4/4] Add subcortical figures to executive summary. --- xcp_d/interfaces/execsummary.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xcp_d/interfaces/execsummary.py b/xcp_d/interfaces/execsummary.py index f5b2b6500..7dc6a6403 100644 --- a/xcp_d/interfaces/execsummary.py +++ b/xcp_d/interfaces/execsummary.py @@ -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",