Chapter 5: Events and Epoching¶
Continuing from Chapter 4 — Artifact Removal with ICA.
This chapter cuts the cleaned continuous recording into the trial-by-trial epochs that averaging and ERP analysis need — matching the MNE-Python track's Events and Epochs chapter.
The event structure¶
Every marker in a recording — a stimulus onset, a button press, a trigger pulse — lands in EEG.event, a list where each entry has at least a .type (a code or label) and a .latency (the sample it occurred at). Most import formats bring events in automatically from the file's trigger channel; Edit → Event/Import event info adds or imports them separately when they live in a separate log file instead.
Editing event codes¶
Raw trigger values are often numeric and unlabeled (e.g. 1, 2, 3). Edit → Event/Import event info → Edit event values lets you relabel these into meaningful condition names ("target", "standard", "response") before epoching, so the epochs you extract next are already organized by condition.
Extracting epochs¶
Tools → Extract epochs cuts a fixed time window (e.g. −200 ms to 800 ms) around every occurrence of one or more chosen event types, turning the continuous recording into a 3D array: channels × time × trials. Tools → Remove baseline then subtracts each epoch's own pre-stimulus mean, so amplitude differences later reflect the stimulus response rather than a pre-existing offset.
Rejecting bad epochs¶
Even a cleaned continuous recording can have a stray artifact overlapping one trial. Tools → Reject data epochs offers several automated criteria to flag suspect trials — extreme voltage values, a strong linear trend, improbable data (statistical outliers), or abnormal kurtosis — reviewed together before the flagged epochs are dropped from further analysis.