Skip to content

Reuse saved ICA component maps when generating component figures - #1356

Open
tsalo wants to merge 13 commits into
ME-ICA:mainfrom
tsalo:simplify-component-plots
Open

Reuse saved ICA component maps when generating component figures#1356
tsalo wants to merge 13 commits into
ME-ICA:mainfrom
tsalo:simplify-component-plots

Conversation

@tsalo

@tsalo tsalo commented Feb 9, 2026

Copy link
Copy Markdown
Member

Closes none.

Changes proposed in this pull request:

  • Reuse saved ICA component maps when generating component figures instead of recalculating weights.
  • Load the 4D component NIfTI once and iterate over components linearly.
  • Refactor single-component figure generation into a dedicated helper.
  • Preserve non-orthogonalized mixing matrices for standard component maps, reports, and external-regressor correlations when TEDORT is enabled.
  • Save orthogonalized component maps separately as desc-ICAOrth_components.nii.gz in verbose TEDORT runs.
  • Apply consistent component-map handling in tedana and ica_reclassify.
  • Correct mixing-matrix shapes and stale parameters in writeresults documentation.
  • Add regression tests for component-map selection and single-load figure generation.

@tsalo tsalo added refactoring issues proposing/requesting changes to the code which do not impact behavior reports issues related to boilerplate generation or visual reports labels Feb 9, 2026
@codecov

codecov Bot commented Feb 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.28571% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.52%. Comparing base (fd18a66) to head (74229f9).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
tedana/reporting/static_figures.py 91.30% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1356      +/-   ##
==========================================
+ Coverage   90.43%   90.52%   +0.09%     
==========================================
  Files          31       31              
  Lines        5100     5107       +7     
  Branches      937      937              
==========================================
+ Hits         4612     4623      +11     
+ Misses        326      322       -4     
  Partials      162      162              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates tedana’s static component figure generation to reuse already-saved ICA component beta maps (instead of recomputing them) and adds joblib-based parallelization for per-component figure creation.

Changes:

  • Update comp_figures to load "ICA components img" from the output registry rather than recomputing beta maps.
  • Refactor per-component plotting into a helper and run it in parallel via joblib.Parallel.
  • Update workflow call sites to match the new comp_figures signature (and pass n_threads from tedana_workflow).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
tedana/workflows/tedana.py Updates comp_figures call signature and passes n_threads.
tedana/workflows/ica_reclassify.py Updates comp_figures call signature after removing ts/mask parameters.
tedana/reporting/static_figures.py Implements loading cached component beta maps and parallel per-component figure generation.
Comments suppressed due to low confidence (2)

tedana/workflows/ica_reclassify.py:596

  • comp_figures now reads spatial maps from "ICA components img" written by io.writeresults using mixing (after any TEDORT orthogonalization), but this call passes mixing_orig. That can make the displayed time series inconsistent with the displayed spatial maps when tedort is used.
        reporting.static_figures.comp_figures(
            component_table=component_table,
            mixing=mixing_orig,
            io_generator=io_generator,
            png_cmap=png_cmap,

tedana/reporting/static_figures.py:402

  • comp_figures behavior changed significantly (now depends on an on-disk "ICA components img" and adds parallel execution), but there’s no test coverage for this function while tedana.reporting does have tests. Consider adding a unit test that mocks nb.load/plot_component to verify it uses the expected file key and iterates over all components (and optionally exercises n_threads>1).
def comp_figures(component_table, mixing, io_generator, png_cmap, n_threads=1):
    """Create static figures that highlight certain aspects of tedana processing.

    This includes a figure for each component showing the component time course,
    the spatial weight map and a fast Fourier transform of the time course.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tedana/workflows/tedana.py
Comment thread tedana/reporting/static_figures.py Outdated
Comment thread tedana/reporting/static_figures.py Outdated
Comment thread tedana/reporting/static_figures.py Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 7 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tedana/io.py
Comment thread tedana/resources/config/outputs.json Outdated
Comment thread tedana/tests/data/nih_five_echo_outputs_verbose.txt Outdated
Comment thread tedana/workflows/ica_reclassify.py
Comment thread tedana/reporting/static_figures.py Outdated
Comment thread tedana/reporting/static_figures.py Outdated
Comment thread tedana/io.py Outdated
@tsalo tsalo changed the title Parallelize component figure creation Reuse saved ICA component maps when generating component figures Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactoring issues proposing/requesting changes to the code which do not impact behavior reports issues related to boilerplate generation or visual reports

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants