question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow making evokeds per event type

See original GitHub issue

Describe the new feature or enhancement

It is very common that you want Evokeds for each event type, for example:

epochs = mne.Epochs(raw, events, {'left': 1, 'right': 2})
evokeds = [epochs['left'].average(), epochs['right'].average()]  # <-- Make this easier

Describe your proposed implementation

Add a parameter to the Epochs.average method:

evokeds = epochs.average(per_event_type=True)

Furthermore, the .comment attribute should be set to the event type.

Describe possible alternatives

Keep the following list comprehension as canonical solution:

evokeds = [epochs[cond] for cond in epochs.event_id.keys()]
for ev, cond in zip(evokeds, epochs.event_id.keys()): 
    ev.comment = cond

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
drammockcommented, Oct 15, 2021

summarizing a conversation with @agramfort during office hours:

  1. Let’s not bother supporting the list-of-lists and stick with just the 2 options for now.
  2. don’t return a dict, return a list (because of how we do write_evokeds)
  3. make sure to set the evoked.comment to the value of the event_id key (so it’s easy to recover )
  4. then all that is left is we just need to decide the right name for the parameter (I’m happy with grouping too)
0reactions
agramfortcommented, Oct 16, 2021

works for me. Sleeping over it I like

epochs.average(by_event_id=True | False)

Read more comments on GitHub >

github_iconTop Results From Across the Web

mne.Evoked — MNE 1.2.2 documentation - MNE-Python
Make animation of evoked data as topomap timeseries. anonymize ([daysback, keep_his ... Get a list of channel type for each channel.
Read more >
Averaging ERPs: Creating MNE Evoked objects
Create Evoked objects#. Unlike Epochs , which by definition contain multiple trials and in which each trial has an associated condition label (event...
Read more >
Additional support for MFF · Issue #8038 · mne-tools/mne-python
We may need to create a new type of MFF events class to store this information, as it appears that event info is...
Read more >
Event-related potential - Wikipedia
An event-related potential (ERP) is the measured brain response that is the direct result of ... Evoked potentials and induced potentials are subtypes...
Read more >
Hosting Candidates at Charitable Events | Bolder Advocacy
hosting a candidate for this type of event, the organization should follow these ... Make every effort to ensure the event does not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found