Skip to content

ENH: make times parameter of plot_evoked_joint more versatile #13289

@sappelhoff

Description

@sappelhoff

plot_evoked_joint accepts a times parameter:

mne-python/mne/viz/evoked.py

Lines 1818 to 1822 in 8df70ae

times : float | array of float | "auto" | "peaks"
The time point(s) to plot. If ``"auto"``, 5 evenly spaced topographies
between the first and last time instant will be shown. If ``"peaks"``,
finds time points automatically by checking for 3 local maxima in
Global Field Power. Defaults to ``"peaks"``.

I think the following changes would be an improvement:

  • make it possible to determine the number of evenly spaced topos via "auto" (currently hardcoded to 5) and "peaks" (currently hardcoded to 3)
  • make it possible to determine a window (or one window per peak) in which "peaks" should be found (currently hardcoded to full time window)

suggested API:

  • accept a dict mapping a single str key to value(s):
  • if "auto", must be either:
    • an integer bigger than 1, corresponding to the number of evenly spaced topos to be plotted
    • a tuple of the form (n, (tmin, tmax)) to plot n evenly spaced topos in the window (tmin, tmax)
  • if "peaks", must be either:
    • an integer bigger than 1, corresponding to the number of peaks (over full time window) to be plotted
    • a tuple of tuples, where each tuple refers to a (tmin, tmax) of a window in which to plot the peak of that window

For example

times = "auto"  # will plot 5 evenly spaced peaks over the whole window
times = np.linspace(0.2, 0.6, 3)  # will plot 3 evenly spaced peaks between 0.2 and 0.6

times = {"peaks": 1}  # will plot 1 single peak within the full time window
times = {"peaks": ((0, 0.1))}  # will plot single peak within 0 to 0.1s window
times = {"peaks": ((0, 0.1), (0.5, 0.8))}  # will plot two peaks within their windows

times = {"mykey": 5}  # error, only "peaks" is an accepted keys

From just thinking about it (haven't looked at the code yet), this should be fairly straight forward, and helpful.

WDYT?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions