Show extra events in epochs plot

I would like to see additional event types that were not used to create epochs in the epochs plot. This is possible, as @drammock has shown with his MWE:

import mne

folder = mne.datasets.sample.data_path()
file = folder / 'MEG' / 'sample' / 'sample_audvis_raw.fif'
raw = mne.io.read_raw_fif(file)

events = mne.find_events(raw, stim_channel='STI 014')
epochs = mne.Epochs(
    raw,
    events,
    event_id={'auditory/right': 2},
    preload=True,
    proj=False
)
epochs['auditory/right'][4:10].plot(events=events)

This shows event type 32 in some epochs, even though only event type 2 was used for epoching.

When I try to replicate this with a different data set (available here), I do not see any extra events:

import mne

raw = mne.io.read_raw_eeglab("6_N400_preprocessed.set", preload=True)
fs = raw.info["sfreq"]
raw.filter(0.2, None)
raw.filter(None, 20)

events, _ = mne.events_from_annotations(raw, event_id=lambda x: int(x))
events = mne.merge_events(events, [111, 112], 111)  # prime related
events = mne.merge_events(events, [121, 122], 121)  # prime unrelated
events = mne.merge_events(events, [211, 212], 211)  # target related
events = mne.merge_events(events, [221, 222], 221)  # target unrelated
events = events[2:]  # discard first two events

event_id = {
    "prime/related": 111,
    "prime/unrelated": 121,
    "target/related": 211,
    "target/unrelated": 221
}

epochs = mne.Epochs(raw, events, event_id, tmin=-0.2, tmax=1.8)
epochs[:5].plot(events=events)

I’d expect to see events of type 201 (correct ) or 202 (incorrect ) at the end of each epoch, but there is nothing:

>>> events[:7]
array([[1327,    0,  121],
       [1550,    0,  221],
       [1663,    0,  201],  # <-- within epoch 1
       [1900,    0,  121],
       [2160,    0,  221],
       [2260,    0,  201],  # <-- within epoch 3
       [2507,    0,  111]])
  • MNE version: 1.4.dev0
  • OS: macOS 11.7.3

just a note to say I can reproduce your result and I am looking into it, but was delayed. I’ll try to get back to it soon.

2 Likes

finally getting back to this: there’s a bug in epoch boundary calculation that is causing the 201 events to be wrongly judged as “not inside” the relevant epochs. It’s just luck that the events in my MWE are close enough to the epoch’s zero point to not reveal the bug. I’ll include a fix in Plot epochs.events by default by cbrnr · Pull Request #11445 · mne-tools/mne-python · GitHub

1 Like