Skip to content

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

Merged
BabaSanfour merged 32 commits intomainfrom
feature/viz
Mar 30, 2026
Merged

feat(viz): Add DSS/benchmark/zapline visualization modules and theme + enhance examples (closes #22)#24
BabaSanfour merged 32 commits intomainfrom
feature/viz

Conversation

@snesmaeili
Copy link
Copy Markdown
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
Copy Markdown

codecov bot commented Mar 2, 2026

Codecov Report

❌ Patch coverage is 95.88560% with 82 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.89%. Comparing base (05fe813) to head (79a7f92).
⚠️ Report is 33 commits behind head on main.

Files with missing lines Patch % Lines
mne_denoise/viz/stats.py 86.53% 18 Missing and 31 partials ⚠️
mne_denoise/qa.py 79.27% 15 Missing and 8 partials ⚠️
mne_denoise/viz/signals.py 98.28% 2 Missing and 2 partials ⚠️
mne_denoise/viz/spectra.py 99.28% 1 Missing and 2 partials ⚠️
mne_denoise/viz/theme.py 96.59% 1 Missing and 2 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #24      +/-   ##
==========================================
+ Coverage   90.27%   95.89%   +5.61%     
==========================================
  Files          32       38       +6     
  Lines        2622     4019    +1397     
  Branches      465      747     +282     
==========================================
+ Hits         2367     3854    +1487     
+ Misses        145       80      -65     
+ Partials      110       85      -25     
Flag Coverage Δ
unittests 95.89% <95.88%> (+5.61%) ⬆️

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

Files with missing lines Coverage Δ
mne_denoise/__init__.py 100.00% <100.00%> (ø)
mne_denoise/viz/__init__.py 100.00% <100.00%> (ø)
mne_denoise/viz/_seaborn.py 100.00% <100.00%> (ø)
mne_denoise/viz/_summary_panels.py 100.00% <100.00%> (ø)
mne_denoise/viz/_utils.py 100.00% <100.00%> (+26.31%) ⬆️
mne_denoise/viz/components.py 100.00% <100.00%> (+20.00%) ⬆️
mne_denoise/viz/summary.py 100.00% <100.00%> (ø)
mne_denoise/viz/spectra.py 99.28% <99.28%> (ø)
mne_denoise/viz/theme.py 96.59% <96.59%> (ø)
mne_denoise/viz/signals.py 98.28% <98.28%> (ø)
... and 2 more

... and 2 files with indirect coverage changes

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

snesmaeili and others added 18 commits March 2, 2026 16:01
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
Comment thread docs/testing.rst Outdated
Comment thread mne_denoise/qa/metrics.py Outdated
Comment thread mne_denoise/viz/_metrics.py Outdated
Comment thread mne_denoise/viz/_theme.py Outdated
Comment thread mne_denoise/benchmarks/io.py Outdated
Comment thread mne_denoise/viz/benchmark.py Outdated
Comment thread mne_denoise/viz/comparison.py Outdated
Comment thread mne_denoise/viz/components.py
Comment thread tests/test_viz.py Outdated
Comment thread mne_denoise/viz/dss.py Outdated
Comment thread mne_denoise/benchmarks/__init__.py Outdated
Comment thread examples/dss/plot_07_spectrogram_dss.py
Comment thread mne_denoise/viz/summary/__init__.py Outdated
@BabaSanfour BabaSanfour marked this pull request as ready for review March 30, 2026 18:47
@BabaSanfour BabaSanfour merged commit 0c41743 into main Mar 30, 2026
16 checks passed
@BabaSanfour BabaSanfour deleted the feature/viz branch March 30, 2026 18:56
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