Station 2 · Lesson 3
Events
S001R03.set (D2) · Already applied: Importing raw files: EDF, BDF & BrainVision, Channel locationsDownload the data (opens in a new tab)Script to reach this state
[ALLEEG, EEG, CURRENTSET, ALLCOM] = eeglab;
% Folder where you keep the course data (change it)
dataFolder = 'C:\Users\me\Documents\eeg-course';
EEG = pop_loadset('filename', 'S001R03.set', 'filepath', dataFolder);
[ALLEEG, EEG, CURRENTSET] = pop_newset(ALLEEG, EEG, 0, 'setname', 'S001R03', 'gui', 'off');
eeglab redraw;Your browser's back button takes you to the exact place you were, so open anything you like.
The idea in brief
An eventA marker in the recording that flags a moment of interest, such as a stimulus. is a marker in the recording that says “something happened here”: a stimulus appeared, the participantThe person whose data were recorded in the study. pressed a button, or a task started. Each event has a type (its name) and a latency (when it happened).
Before and after
Image coming soon.
The Channel data (scroll) window for S001R03 after channel locations: a few channels with their names on the left, and colored vertical event lines with their names above them (T2, then T0, then T1, then T0), about 4 seconds apart. The Event types button at the bottom is marked with an arrow. Real screenshot from EEGLAB 2026.1 (source: eeglab-ui).
Your next questions, each answered in its own section:
Why do I need this step?
The reasons in detail, and the terms you need
Almost every later analysis depends on events. Epoching cuts the data around them, and ERPs are averaged over them. If the events are missing, have the wrong names, or sit at the wrong time, every result after them is wrong, even if the signalValues that change over time, such as the voltage recorded on a channel. is clean.
So right after import, check three things: are the event types the ones you expect, is their number right, and is their timing right.
In S001R03.edf the events come from the EDF+ annotations. The datasetOne EEG data file loaded in EEGLAB together with its information. page defines three codes:
T0: rest.T1andT2: the start of two different movements, real or imagined. Which movement each code means depends on the task of the run. The dataset page explains it.
Why do I need this step?
Almost every later analysis depends on events. Epoching cuts the data around them, and ERPs are averaged over them. If the events are missing, have the wrong names, or sit at the wrong time, every result after them is wrong, even if the signal is clean.
So right after import, check three things: are the event types the ones you expect, is their number right, and is their timing right.
In S001R03.edf the events come from the EDF+ annotations. The dataset page defines three codes:
T0: rest.T1andT2: the start of two different movements, real or imagined. Which movement each code means depends on the task of the run. The dataset page explains it.
How do I do it in EEGLAB?
10 steps in the menus
1. See the events on the signal
- Open
S001R03.set, which now has channelThe signal recorded from one electrode, as shown in EEGLAB. locations. - Open Plot then Channel data (scroll).
- The vertical lines are the events, with each event’s type written above it. Each type has its own color.
- Click Event types at the bottom of the window. A small legend shows each type with its color.
- Move with
>and<. The events come about every 4 seconds:T1orT2, thenT0, thenT1orT2again.
2. Read each event’s values
- Open Edit then Event values.
- The window shows one event at a time. Its fields include
type, latency (sec) and duration (sec). - The first event has type
T2, latency[4.1937]and duration4.1. - Move to the next event with the
>button. The second event isT0at[8.2937]seconds. - Close the window with Cancel so you do not change anything.
This window shows latency and duration in seconds. Inside EEG.event they are stored in samples. The scriptA MATLAB file of commands that runs processing steps in order. below shows the difference.
How do I do it in EEGLAB?
1. See the events on the signal
- Open
S001R03.set, which now has channel locations. - Open Plot then Channel data (scroll).
- The vertical lines are the events, with each event’s type written above it. Each type has its own color.
- Click Event types at the bottom of the window. A small legend shows each type with its color.
- Move with
>and<. The events come about every 4 seconds:T1orT2, thenT0, thenT1orT2again.
2. Read each event’s values
- Open Edit then Event values.
- The window shows one event at a time. Its fields include
type, latency (sec) and duration (sec). - The first event has type
T2, latency[4.1937]and duration4.1. - Move to the next event with the
>button. The second event isT0at[8.2937]seconds. - Close the window with Cancel so you do not change anything.
This window shows latency and duration in seconds. Inside EEG.event they are stored in samples. The script below shows the difference.
How do I write it as code?
The same steps in 16 lines of MATLAB
% Start EEGLAB and load the file from the previous lesson
[ALLEEG, EEG, CURRENTSET, ALLCOM] = eeglab;
dataFolder = 'C:\Users\me\Documents\eeg-course'; % change it
EEG = pop_loadset('filename', 'S001R03.set', 'filepath', dataFolder);
% Event types and how many of each
eeg_eventtypes(EEG) % T0 14, T1 8, T2 7
numel(EEG.event) % 29
% Type and latency of the first four events (latency in samples)
{EEG.event(1:4).type} % 'T2' 'T0' 'T1' 'T0'
[EEG.event(1:4).latency] % 672 1328 2000 2656
% The same latencies in seconds: (sample - 1) / sampling rate
([EEG.event(1:4).latency] - 1) / EEG.srate % 4.1937 8.2937 12.4938 16.5938
% Duration is also stored in samples
[EEG.event(1:2).duration] / EEG.srate % 4.1 4.2
% Scroll through the data with its events
pop_eegplot(EEG, 1, 1, 1);- Why subtract 1? In EEGLAB the first sampleA single value of the signal at one point in time. is number 1 and sits at time zero. With a sampling rateThe number of samples recorded per second on each channel. of 160 Hz, one second is 160 samples.
- Why 4.19 and not 4.2? The file puts the first event at 4.2 seconds, and the import makes it sample 4.2 × 160 = 672. After subtracting 1, that is 4.19375 seconds, which the window shows as
[4.1937]. The difference is one sample (about 6 ms) and does not matter in this course. - Why 29 events and not 30? The file has 30 annotations, and the first is
T0at 0 seconds. The import gives it latency0, before the first sample, so EEGLAB removes it and prints in the Command Window:eeg_checkset warning: 1/30 events had out-of-bounds latencies and were removed.
How do I write it as code?
% Start EEGLAB and load the file from the previous lesson
[ALLEEG, EEG, CURRENTSET, ALLCOM] = eeglab;
dataFolder = 'C:\Users\me\Documents\eeg-course'; % change it
EEG = pop_loadset('filename', 'S001R03.set', 'filepath', dataFolder);
% Event types and how many of each
eeg_eventtypes(EEG) % T0 14, T1 8, T2 7
numel(EEG.event) % 29
% Type and latency of the first four events (latency in samples)
{EEG.event(1:4).type} % 'T2' 'T0' 'T1' 'T0'
[EEG.event(1:4).latency] % 672 1328 2000 2656
% The same latencies in seconds: (sample - 1) / sampling rate
([EEG.event(1:4).latency] - 1) / EEG.srate % 4.1937 8.2937 12.4938 16.5938
% Duration is also stored in samples
[EEG.event(1:2).duration] / EEG.srate % 4.1 4.2
% Scroll through the data with its events
pop_eegplot(EEG, 1, 1, 1);- Why subtract 1? In EEGLAB the first sample is number 1 and sits at time zero. With a sampling rate of 160 Hz, one second is 160 samples.
- Why 4.19 and not 4.2? The file puts the first event at 4.2 seconds, and the import makes it sample 4.2 × 160 = 672. After subtracting 1, that is 4.19375 seconds, which the window shows as
[4.1937]. The difference is one sample (about 6 ms) and does not matter in this course. - Why 29 events and not 30? The file has 30 annotations, and the first is
T0at 0 seconds. The import gives it latency0, before the first sample, so EEGLAB removes it and prints in the Command Window:eeg_checkset warning: 1/30 events had out-of-bounds latencies and were removed.
Which value should I choose?
Suitable values for your analysis goal
There is no value to choose here. What matters is knowing what to expect. These are the event fields in this file:
| Field | What it stores | Stored unit | Shown in Edit > Event values as | Example (first event) |
|---|---|---|---|---|
type | Event name | text | text | T2 |
latency | When the event happened | samples | seconds | 672 (4.19 s) |
duration | How long the event lasted | samples | seconds | 656 (4.1 s) |
urevent | The event’s number in the original list | number | not shown | 1 |
And what to expect in S001R03.edf:
| Check | Expected |
|---|---|
| Event types | T0, T1, T2 |
| Number of events | 29: 14 T0, 8 T1, 7 T2 (the first annotation, at 0 s, is removed) |
| Spacing | about 4.1 to 4.2 seconds between events |
| Last event | T1 at about 120.4 seconds, before the end of the recording at 125 seconds |
If events are missing or late. In other files the events may not come with the signal. Import them with File then Import event info: from a text file or MATLAB array, from the trigger channel (From data channel), or from Presentation and E-Prime files. If all events are late by a fixed amount, such as the delay before the stimulus appears on the screen, shift them in a script by the delay you measured on your setup:
EEG = pop_adjustevents(EEG, 'addms', 20); % move every event 20 ms later (use your own measured delay)The matching , Edit then Adjust event latencies, is hidden by default in 2026.1. To show it, tick the checkbox that starts with If set, show all menu items from previous EEGLAB versions. in File then Preferences and restart EEGLAB. This changes how every menu looks compared with the lesson images, so untick it when you are done.
Which value should I choose?
There is no value to choose here. What matters is knowing what to expect. These are the event fields in this file:
| Field | What it stores | Stored unit | Shown in Edit > Event values as | Example (first event) |
|---|---|---|---|---|
type | Event name | text | text | T2 |
latency | When the event happened | samples | seconds | 672 (4.19 s) |
duration | How long the event lasted | samples | seconds | 656 (4.1 s) |
urevent | The event’s number in the original list | number | not shown | 1 |
And what to expect in S001R03.edf:
| Check | Expected |
|---|---|
| Event types | T0, T1, T2 |
| Number of events | 29: 14 T0, 8 T1, 7 T2 (the first annotation, at 0 s, is removed) |
| Spacing | about 4.1 to 4.2 seconds between events |
| Last event | T1 at about 120.4 seconds, before the end of the recording at 125 seconds |
If events are missing or late. In other files the events may not come with the signal. Import them with File then Import event info: from a text file or MATLAB array, from the trigger channel (From data channel), or from Presentation and E-Prime files. If all events are late by a fixed amount, such as the delay before the stimulus appears on the screen, shift them in a script by the delay you measured on your setup:
EEG = pop_adjustevents(EEG, 'addms', 20); % move every event 20 ms later (use your own measured delay)The matching menu, Edit then Adjust event latencies, is hidden by default in 2026.1. To show it, tick the checkbox that starts with If set, show all menu items from previous EEGLAB versions. in File then Preferences and restart EEGLAB. This changes how every menu looks compared with the lesson images, so untick it when you are done.
How do I check it worked?
4 quick checks
- The Events line in the main window shows
29. eeg_eventtypes(EEG)listsT014,T18 andT27.- The first event in Edit then Event values is
T2at[4.1937]seconds, and the second isT0at[8.2937]seconds. - The scrolling window shows event lines about every 4 seconds.
This lesson does not change the data, so there is nothing to save.
From the next station we work on eeglab_data.set, which ships with EEGLAB, because it is small and matches the documentation. The same steps apply to your own file.
How do I check it worked?
- The Events line in the main window shows
29. eeg_eventtypes(EEG)listsT014,T18 andT27.- The first event in Edit then Event values is
T2at[4.1937]seconds, and the second isT0at[8.2937]seconds. - The scrolling window shows event lines about every 4 seconds.
This lesson does not change the data, so there is nothing to save.
From the next station we work on eeglab_data.set, which ships with EEGLAB, because it is small and matches the documentation. The same steps apply to your own file.
What mistakes do people make?
5 mistakes and how to avoid them
- Reading
latencyas seconds. InEEG.eventit is in samples. Convert it with (sample − 1) ÷ sampling rate. - Types appear as numbers (
1,2,3) instead ofT0,T1,T2. The annotation names were not read. Import again with Import EDF+ annotations (try also mexSLOAD below) ticked, as in the import lesson. - No events at all. The Events line in the main window shows
none. The annotations were not imported. Import again and check the same field. - Assuming T1 always means the same movement. In this dataset its meaning depends on the run’s task. Read the dataset page for each file you use.
- Changing an event by mistake in Edit > Event values. Any value you type changes the event. Close with Cancel unless you mean to edit it.
What mistakes do people make?
- Reading
latencyas seconds. InEEG.eventit is in samples. Convert it with (sample − 1) ÷ sampling rate. - Types appear as numbers (
1,2,3) instead ofT0,T1,T2. The annotation names were not read. Import again with Import EDF+ annotations (try also mexSLOAD below) ticked, as in the import lesson. - No events at all. The Events line in the main window shows
none. The annotations were not imported. Import again and check the same field. - Assuming T1 always means the same movement. In this dataset its meaning depends on the run’s task. Read the dataset page for each file you use.
- Changing an event by mistake in Edit > Event values. Any value you type changes the event. Close with Cancel unless you mean to edit it.
Your browser doesn't allow saving progress. All lessons are open, but completion marks won't be saved.
Done. Your progress is saved in this browser.UndoWhere can I read more?
4 sources, official docs first
- EEGLAB TutorialDocumentationb. Events: Plotting events; Recognized event fields
- EEGLAB TutorialDocumentationb. Event Processing
- EEGLAB preprocessing #2: Events and channel locationsVideoFull video · 11:40
- EEG Motor Movement/Imagery Dataset (PhysioNet)Experimental Protocol
Written for EEGLAB 2026.1 · 2026-10-28
Going further
- EEGLAB Tutorial: https://eeglab.org/tutorials/04_Import/Importing_Event_Epoch_Info.html (b. Events: Plotting events; Recognized event fields)
- EEGLAB Tutorial: https://eeglab.org/tutorials/11_Scripting/Event_Processing_command_line.html (b. Event Processing)
- EEGLAB preprocessing #2: Events and channel locations: https://www.youtube.com/watch?v=2CPmmPG5Beo (Full video)
- EEG Motor Movement/Imagery Dataset (PhysioNet): https://physionet.org/content/eegmmidb/1.0.0/ (Experimental Protocol)
Need help?
Ask, share feedback, or report an error
- Report a scientific error · Needs a GitHub account. Don't have one? Use "Share your thoughts".