Skip to content

ENH: Add scalings and units to plot_compare_evokeds (#8556) - #14534

Merged
larsoner merged 1 commit into
mne-tools:mainfrom
ishaaaan17:enh/plot-compare-evokeds-scalings
Nov 17, 2026
Merged

larsoner merged 1 commit into
mne-tools:mainfrom
ishaaaan17:enh/plot-compare-evokeds-scalings

Conversation

@ishaaaan17

@ishaaaan17 ishaaaan17 commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

what does this implement/fix?

fixes #8556. (also addresses item 3 under static time series in the 2D plotting RFC #7751).

before this, mne.viz.plot_compare_evokeds had these two lines hardcoded:

units = _handle_default("units")[ch_type]
scalings = _handle_default("scalings")[ch_type]

so when the evoked data was already converted to custom scores, z-scores, regression beta weights or normalized ERPs, plot_compare_evokeds still used the default channel scalings (for example 10⁶ for EEG) and labeled the y-axis with µV or fT.

this PR adds the parameters scalings and units to plot_compare_evokeds, like mne.viz.plot_evoked has. both default to None, so nothing changes for existing code. they are also passed on correctly when there are several channel types, and in the click windows of axes="topo".

verification

  • added regression tests in mne/viz/tests/test_evoked.py::test_plot_compare_evokeds, which cover:
    • a custom dict for scaling (scalings=dict(eeg=1.0)) and units (units=dict(eeg="AU")), which rescales the y-data and changes the axis label.
    • the default picks=None path that combines channels (GFP/RMS) with custom scalings.
    • passing the settings through the recursive calls when there are several channel types (for example EEG + MEG), so that each figure gets the unit of its own channel type.
  • local pytest (pytest mne/viz/tests/test_evoked.py -k test_plot_compare_evokeds) and ruff check pass.

additional information

this implementation was developed with Google DeepMind agentic tools, and reviewed and refined with Muse. i checked it myself: the scaling resolution logic through _handle_default, how the settings are passed through multiple channel types, and i ran the test suite locally before submitting.

@ishaaaan17
ishaaaan17 force-pushed the enh/plot-compare-evokeds-scalings branch 3 times, most recently from b81f606 to 23153d1 Compare November 15, 2026 13:08
Add scalings and units parameters to mne.viz.plot_compare_evokeds to allow custom units and scaling (e.g. for z-scored or decoded data), matching the convention in mne.viz.plot_evoked.
@ishaaaan17
ishaaaan17 force-pushed the enh/plot-compare-evokeds-scalings branch from 23153d1 to f0f4b8d Compare November 15, 2026 13:27
@larsoner
larsoner merged commit 5848af4 into mne-tools:main Nov 17, 2026
25 checks passed
@larsoner

Copy link
Copy Markdown
Member

Thanks @ishaaaan17 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Scaling parameter for mne.viz.plot_compare_evokeds

2 participants