mne-tools / mne-tools/mne-python

ENH: make `times` parameter of `plot_evoked_joint` more versatile

Open
#13,289 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

ENH
Dominant language
Python
Stars
3.5k
Forks
1.6k
Avg merge
1d 6h
Merged PRs (30d)
100

Description

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 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?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in mne/viz/evoked.py around the plot_evoked_joint times handling linked in the issue. Review how the current hardcoded evenly spaced and peak selections are determined, then implement the accepted peaks forms and validate invalid keys or values. Done means the requested windowed peak selection works while existing times usage remains supported.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python
Domain
data-visualization
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.