ENH: make `times` parameter of `plot_evoked_joint` more versatile
plot_evoked_joint accepts a times parameter:
https://github.com/mne-tools/mne-python/blob/8df70aea97c42a58d02e1c121679e9c1b2c62869/mne/viz/evoked.py#L1818-L1822
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 plotnevenly 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?
Looks reasonable except this one:
times = {"auto": (3, (0.1, 0.8))}
Can be more compactly written as
times=np.linspace(0.1, 8, 3)
So I'd rather just put that suggestion in the docstring somewhere, "if you want to use evenly spaced time points in an interval ..."
So I'd rather just put that suggestion in the docstring somewhere, "if you want to use evenly spaced time points in an interval ..."
Makes sense to me. And then auto is just np.linspace(tmin, tmax, 5) with tmin and tmax being what they are in the data.
xref to #12857. It would be nice if what was decided there (but never implemented yet) also worked here (or vice-versa) so that we were internally consistent.