Skip to content

feat(viz): Add DSS/benchmark/zapline visualization modules and theme + enhance examples (closes #22)#24

Draft
snesmaeili wants to merge 17 commits intomainfrom
feature/viz
Draft

feat(viz): Add DSS/benchmark/zapline visualization modules and theme + enhance examples (closes #22)#24
snesmaeili wants to merge 17 commits intomainfrom
feature/viz

Conversation

@snesmaeili
Copy link
Collaborator

feat(viz): Add DSS/benchmark/zapline visualization modules and theme + enhance examples

(Recreated from #23 which was accidentally merged)

@BabaSanfour BabaSanfour added documentation Improvements or additions to documentation enhancement New feature or request labels Mar 2, 2026
@BabaSanfour BabaSanfour changed the title feat(viz): Add DSS/benchmark/zapline visualization modules and theme + enhance examples feat(viz): Add DSS/benchmark/zapline visualization modules and theme + enhance examples (closes #22) Mar 2, 2026
…ess issues

- Fix isinstance union-type calls to use X | Y syntax (Python 3.10+)
- Replace garbled Unicode placeholders with proper characters
- Add _PUB_RC dict, use_style() context manager, _apply_style(), _finalize_fig()
- Add METHOD_COLORS dict and _get_color() helper
- Centralize all hardcoded colors to COLORS/METHOD_COLORS refs
- Standardize return types: zapline functions now return Figure (not Axes)
- Add fname parameter to all public plot functions for file saving
- Rename benchmark save_path to fname for MNE-like consistency
- Export new public API: METHOD_COLORS, use_style, _apply_style, _finalize_fig
- Fix syntax error (double comma) in dss.py
- Update tests: fix Axes->Figure assertions, add theme/helper smoke tests
@codecov
Copy link

codecov bot commented Mar 2, 2026

Codecov Report

❌ Patch coverage is 84.62178% with 370 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.04%. Comparing base (05fe813) to head (957c660).

Files with missing lines Patch % Lines
mne_denoise/viz/dss.py 66.23% 167 Missing and 40 partials ⚠️
mne_denoise/viz/zapline.py 84.39% 51 Missing and 25 partials ⚠️
mne_denoise/viz/erp.py 94.71% 15 Missing and 15 partials ⚠️
mne_denoise/viz/benchmark.py 91.56% 11 Missing and 16 partials ⚠️
mne_denoise/viz/_theme.py 86.58% 7 Missing and 4 partials ⚠️
mne_denoise/viz/erp_io.py 95.10% 1 Missing and 6 partials ⚠️
mne_denoise/viz/benchmark_io.py 95.69% 0 Missing and 4 partials ⚠️
mne_denoise/viz/comparison.py 88.88% 3 Missing and 1 partial ⚠️
mne_denoise/viz/_metrics.py 90.00% 1 Missing and 1 partial ⚠️
mne_denoise/viz/components.py 91.66% 1 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #24      +/-   ##
==========================================
- Coverage   90.27%   89.04%   -1.23%     
==========================================
  Files          32       41       +9     
  Lines        2622     4894    +2272     
  Branches      465      884     +419     
==========================================
+ Hits         2367     4358    +1991     
- Misses        145      336     +191     
- Partials      110      200      +90     
Flag Coverage Δ
unittests 89.04% <84.62%> (-1.23%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
mne_denoise/qa/__init__.py 100.00% <100.00%> (ø)
mne_denoise/qa/metrics.py 100.00% <100.00%> (ø)
mne_denoise/viz/__init__.py 100.00% <100.00%> (ø)
mne_denoise/viz/_utils.py 73.68% <ø> (ø)
mne_denoise/viz/_metrics.py 90.00% <90.00%> (ø)
mne_denoise/viz/components.py 83.78% <91.66%> (+3.78%) ⬆️
mne_denoise/viz/benchmark_io.py 95.69% <95.69%> (ø)
mne_denoise/viz/comparison.py 89.39% <88.88%> (+3.36%) ⬆️
mne_denoise/viz/erp_io.py 95.10% <95.10%> (ø)
mne_denoise/viz/_theme.py 86.58% <86.58%> (ø)
... and 4 more

... and 3 files with indirect coverage changes

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

Bug fixes:
- Export _get_color in viz/__init__.py
- Fix string channel picks crash in plot_time_course_comparison
- Handle above-Nyquist frequencies in peak_attenuation_db (return NaN)

New modules:
- mne_denoise/qa/__init__.py — QA metrics package
- mne_denoise/qa/metrics.py — peak_attenuation_db function

New scripts:
- scripts/visual_qa.py — comprehensive QA testing all 37 viz functions
  on real Runabout data (36/37 pass; plot_dss_comparison needs future
  DSS n_select/smooth/segmented params)
Review fixes from Nature Methods-style audit:
- comparison.py: replace hardcoded 'k'/'r'/'b' with COLORS['before']/COLORS['after']
- components.py: replace 'steelblue'/'gray' with COLORS['primary']/COLORS['muted']
- zapline.py: replace plt.cm.tab10 with Wong (2011) palette from COLORS dict
- dss.py: add fname param to all 5 public plot functions, use _finalize_fig
- zapline.py: add fname param to 4 dashboard functions, use _finalize_fig
- _theme.py: _finalize_fig closes figure after save when show=False
- __init__.py: remove private helpers from __all__
- qa/metrics.py: add TODO for 6 missing QA metric functions

All 322 tests pass.
…lues\n\nNew module `mne_denoise.viz.erp` with 5 pub-quality ERP benchmark\nvisualizations:\n - plot_erp_signal_diagnostics: 3×2 QA dashboard (PSD / evoked / diff wave)\n - plot_condition_interaction: diff waves + Hedges' g interaction plot\n - plot_metric_violins: violin + swarm + paired lines (generic)\n - plot_endpoint_summary: multipanel violins + null CI + paired slopes\n - plot_pipeline_slopes: multi-metric subject-level trajectories\n\nAlso fixes:\n - components.py: handle 2-D eigenvalues in plot_narrowband_scan peak marker\n\nAll 322 tests pass."
- Add 12 cells (Section 11) to viz_showcase.ipynb demonstrating all 5
  ERP benchmark functions with synthetic data
- Fix seaborn FutureWarning: add hue='Group', legend=False to all
  violinplot/stripplot calls in plot_metric_violins & plot_endpoint_summary
- Replace deprecated set_xticklabels with tick_params in both functions
- Add module-level warnings.filterwarnings in erp.py for residual
  seaborn palette warnings
- Update Summary table with ERP Benchmark row
New functions in mne_denoise/viz/erp.py:
- plot_grand_average_erp: group-mean evoked +/- between-subject SEM
- plot_grand_condition_interaction: condition x pipeline with group error bars
- plot_null_distribution: permutation null histogram + observed statistic
- plot_forest: per-subject effect-size forest plot with CI

Updated __init__.py exports (9 ERP functions + 3 constants).
Added Section 12 to viz_showcase.ipynb (10 cells, all demos pass).
…lize_fig to auto-create parent directories (mkdir -p)\n before saving figures, preventing FileNotFoundError\n- Add erp_io.py with deferred-group workflow:\n - save_subject_erp_results(): persist evokeds, diff waves,\n effect sizes, and metrics per subject\n - load_subject_erp_results(): read one subject's saved data\n - aggregate_erp_results(): collect all subjects from disk into\n ERPGroupData namedtuple ready for group plot functions\n- Export 4 new symbols from viz __init__.py\n- 322 tests pass, IO round-trip verified"
- tests/test_erp_viz.py: 92 comprehensive tests for erp.py (96% cov),
  erp_io.py (97% cov), and _theme.py mkdir fix
- mne_denoise/viz/erp.py: fix B904 (raise ... from err), fix E402
  (move relative import above warnings.filterwarnings calls),
  ruff format
- mne_denoise/viz/erp_io.py: ruff format only (no logic changes)
- docs/changes/devel/feature.rst: document ERP functions, erp_io,
  _finalize_fig fix, and test suite

Full suite: 414 passed, 11 skipped
- tests/test_qa_metrics.py: peak_attenuation_db (8 tests)
- tests/test_viz_metrics.py: suppression, distortion, variance (9 tests)
- tests/test_benchmark_io.py: save/load/aggregate IO (22 tests)
- tests/test_viz_benchmark.py: all 9 plot functions + helpers (36 tests)
- tests/test_viz_dss.py: DSS helpers + dashboards (35 tests)
- tests/test_viz_zapline_extended.py: adaptive/standard summary + helpers (42 tests)
- tests/test_utils.py: extract/reconstruct MNE objects (13 tests)
- tests/test_averaging.py: AverageBias._apply_datasets (7 tests)
- docs/testing.rst: testing documentation page
- docs/index.rst: add testing to toctree
- Make pandas imports lazy in benchmark_io.py, erp_io.py, erp.py
  so viz module can be imported without pandas (fixes docs build)
- Add per-file-ignores for scripts/ and run_erp_benchmark.py (D, E402)
- Add F404 ignore for examples (notebook __future__ import)
- Auto-fix ruff issues: unused imports, sort imports, dict literals,
  dict comprehensions, set comprehensions, SIM114
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants