Station 2 · Lesson 3

Events

Core12 minBefore this lesson: Importing raw files: EDF, BDF & BrainVisionPrint the card
Starts from: 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
MATLAB
[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;

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.
  • T1 and T2: 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

  1. Open S001R03.set, which now has channelThe signal recorded from one electrode, as shown in EEGLAB. locations.
  2. Open Plot then Channel data (scroll).
  3. The vertical lines are the events, with each event’s type written above it. Each type has its own color.
  4. Click Event types at the bottom of the window. A small legend shows each type with its color.
  5. Move with > and <. The events come about every 4 seconds: T1 or T2, then T0, then T1 or T2 again.

2. Read each event’s values

  1. Open Edit then Event values.
  2. The window shows one event at a time. Its fields include type, latency (sec) and duration (sec).
  3. The first event has type T2, latency [4.1937] and duration 4.1.
  4. Move to the next event with the > button. The second event is T0 at [8.2937] seconds.
  5. 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 write it as code?

The same steps in 16 lines of MATLAB
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 T0 at 0 seconds. The import gives it latency 0, 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:

FieldWhat it storesStored unitShown in Edit > Event values asExample (first event)
typeEvent nametexttextT2
latencyWhen the event happenedsamplesseconds672 (4.19 s)
durationHow long the event lastedsamplesseconds656 (4.1 s)
ureventThe event’s number in the original listnumbernot shown1

And what to expect in S001R03.edf:

CheckExpected
Event typesT0, T1, T2
Number of events29: 14 T0, 8 T1, 7 T2 (the first annotation, at 0 s, is removed)
Spacingabout 4.1 to 4.2 seconds between events
Last eventT1 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:

MATLAB
EEG = pop_adjustevents(EEG, 'addms', 20);   % move every event 20 ms later (use your own measured delay)

The matching menuA list of commands that opens from its name at the top of the window., 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
  1. The Events line in the main window shows 29.
  2. eeg_eventtypes(EEG) lists T0 14, T1 8 and T2 7.
  3. The first event in Edit then Event values is T2 at [4.1937] seconds, and the second is T0 at [8.2937] seconds.
  4. 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 latency as seconds. In EEG.event it is in samples. Convert it with (sample − 1) ÷ sampling rate.
  • Types appear as numbers (1, 2, 3) instead of T0, 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.

Where can I read more?

4 sources, official docs first

Written for EEGLAB 2026.1 · 2026-10-28

Need help?

Ask, share feedback, or report an error