ENH: Modularize tedana.py workflow into pipeline stages#1280
Draft
eurunuela wants to merge 1 commit intoME-ICA:mainfrom
Draft
ENH: Modularize tedana.py workflow into pipeline stages#1280eurunuela wants to merge 1 commit intoME-ICA:mainfrom
eurunuela wants to merge 1 commit intoME-ICA:mainfrom
Conversation
Introduced PipelineContext and modularized the tedana workflow into discrete pipeline stages for improved maintainability and memory management. Added new modules pipeline_context.py and pipeline_stages.py, updated __init__.py to expose new workflow API, and refactored tedana_workflow to use the new context and orchestration function.
Collaborator
Author
|
I have found Claude Opus 4.5 to be incredibly good at refactoring code in the past, so I thought I'd give this a go at modularizing our |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1280 +/- ##
==========================================
- Coverage 89.86% 89.41% -0.46%
==========================================
Files 29 31 +2
Lines 4383 4584 +201
Branches 725 748 +23
==========================================
+ Hits 3939 4099 +160
- Misses 295 334 +39
- Partials 149 151 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR refactors the monolithic
tedana_workflow()function (~800 lines) into a modular pipeline architecture with distinct stages, improving maintainability, testability, and memory efficiency.Changes
PipelineContextdataclass (pipeline_context.py): Centralizes all workflow state (configuration, data arrays, masks, decomposition results) in a single container, reducing parameter passing between functionspipeline_stages.py): Organizes the workflow into 9 logical stages with 20+ self-contained functionstedana_workflow(): Now creates aPipelineContextand delegates torun_tedana_pipeline(), reducing the function from ~800 to ~30 linesclear_intermediate_data(),get_memory_usage()) with garbage collectionPipeline Stages
setup_output_directory,validate_inputs,initialize_component_selector,setup_io_generatorload_data,validate_tr,load_external_regressors,handle_precomputed_filescreate_masksfit_decay_modelcompute_optimal_combinationperform_pca_decomposition,perform_ica_decomposition,compute_component_metrics,perform_component_selection,run_decomposition_with_restartssave_component_outputs,apply_tedort,write_denoised_data,save_registry_and_metadata,finalize_report_textgenerate_reportscleanupBenefits
tedana_workflow()now returnsPipelineContextfor programmatic access to results (component table, mixing matrix, selector, etc.)File Changes
pipeline_context.pypipeline_stages.pytedana.py__init__.pyTest Plan
🤖 Generated with Claude Code