Station 1 · Lesson 3

The EEG structure

Core12 minBefore this lesson: The EEGLAB window & menusPrint the card
Starts from: eeglab_data.set (D1) · Nothing yet: the data as downloaded.Download the data (opens in a new tab)
Script to reach this state
MATLAB
[ALLEEG, EEG, CURRENTSET, ALLCOM] = eeglab;
sampleFolder = fullfile(fileparts(which('eeglab')), 'sample_data');
EEG = pop_loadset('filename', 'eeglab_data.set', 'filepath', sampleFolder);
[ALLEEG, EEG, CURRENTSET] = pop_newset(ALLEEG, EEG, 0, 'setname', 'Continuous EEG Data', 'gui', 'off');
eeglab redraw;

The idea in brief

Everything you see in the EEGLAB window is stored in a single MATLAB variable called EEG. This variable is a structA MATLAB variable that groups several named fields together.: a box of fields, each with a name.

The main window shows only a summary. Scripts read from EEG and write to it directly. Once you understand its main fields, you can check any step yourself.

Before and after

The EEG tree in eeglab_data.set: data is a 32 × 30504 matrix (channels in rows, samples in columns), srate is 128, chanlocs has 32 elements, event has 154 elements, and icaweights is empty until ICA is run.

Your next questions, each answered in its own section:

Why do I need this step?

The reasons in detail, and the terms you need

You will use the same dot syntax you used with the demo variable in the MATLAB basics lesson: EEG.srate means the srate field inside EEG.

How do I do it in EEGLAB?

7 steps in the menus

1. Open the fields in the Workspace

  1. Open the datasetOne EEG data file loaded in EEGLAB together with its information. as in the previous lesson.
  2. In the MATLAB Workspace panel, double-click EEG.
  3. The fields of EEG appear in a table. Double-click any field to open it, such as chanlocs or event.

2. Read the events from EEGLAB

  1. Open Edit then Event values.
  2. A window shows one eventA marker in the recording that flags a moment of interest, such as a stimulus. at a time: type, position and latency. (The urevent field is not shown in this window.)
  3. Notice that the latency field in this window is titled latency (sec): the window shows the latency in seconds, while EEG.event stores it in samples. The first event appears here at about 1.0001 seconds.
  4. Close the window with Cancel so you do not change anything.

3. Read the dataset information

Open Edit then Dataset info. Values such as the dataset name and sampling rateThe number of samples recorded per second on each channel. appear. Close it with Cancel.

How do I write it as code?

The same steps in 18 lines of MATLAB

Type these lines in the Command Window, one at a time, and compare the output with the comment:

MATLAB
% Basic information
EEG.setname            % 'Continuous EEG Data'
EEG.nbchan             % 32 channels
EEG.srate              % 128 samples per second
EEG.pnts               % 30504 samples per channel
(EEG.pnts - 1) / EEG.srate   % 238.3047 seconds (same as EEG.xmax)

% The signal: channels x samples
size(EEG.data)         % 32 30504
class(EEG.data)        % 'single'
EEG.data(1, 1:5)       % first 5 samples of channel 1 (microvolts)

% Channel names
{EEG.chanlocs(1:3).labels}   % 'FPz' 'EOG1' 'F3'

% First event: type and latency
EEG.event(1).type      % 'square'
EEG.event(1).latency   % 129.0087 (in samples)
(EEG.event(1).latency - 1) / EEG.srate   % 1.0001 (in seconds)

% Empty until ICA is computed
isempty(EEG.icaweights)   % 1 (true)
  • Why subtract 1? In MATLAB the first sampleA single value of the signal at one point in time. is number 1 and sits at time zero. So time in seconds = (sample number − 1) ÷ sampling rate.
  • EEG.data(1, 1:5): the first number selects the channelThe signal recorded from one electrode, as shown in EEGLAB. (row), and the second selects the samples (columns).

Which value should I choose?

Suitable values for your analysis goal

There is no value to choose here. These are the main fields you will come back to in every lesson:

FieldWhat it storesUnitValue in eeglab_data.set
EEG.nbchanNumber of channelschannels32
EEG.srateSampling rateHz128
EEG.pntsNumber of samples per channelsamples30504
EEG.trialsNumber of segments (1 = continuous data)segments1
EEG.xmin and EEG.xmaxTime of the first and the last sampleseconds0 and 238.3047 (last sample)
EEG.timesTime of each samplemillisecondsfrom 0 to 238304.6875
EEG.dataThe signalValues that change over time, such as the voltage recorded on a channel. itselfmicrovoltsa 32 × 30504 matrix
EEG.chanlocsName and position of each channel—32 elements
EEG.eventEvents: type and latencylatency in samples154 events (80 square and 74 rt)
EEG.icaweightsICAA method that separates the recording into independent sources, some brain and some artifact. weights—empty

How do I check it worked?

4 quick checks
  1. size(EEG.data) gives 32 30504.
  2. (EEG.pnts - 1) / EEG.srate gives 238.3047, the same as EEG.xmax and as Epoch end (sec) in the main window (shown rounded as 238.305).
  3. EEG.event(1).type gives 'square', and the converted latency gives about 1.0001 seconds, matching what you saw in Edit then Event values.
  4. numel(EEG.event) gives 154, matching the Events line in the main window.

What mistakes do people make?

5 mistakes and how to avoid them
  • Swapping the dimensions. In EEGLAB channels are rows and samples are columns. EEG.data(:, 1) is all channels at the first sample, not the whole first channel. The whole first channel is EEG.data(1, :).
  • Reading latency as seconds. In EEG.event the latency is in samples. Convert it with the formula above, and do not forget to subtract 1.
  • Forgetting that EEG.times is in milliseconds. While EEG.xmin and EEG.xmax are in seconds.
  • Editing EEG by hand and not telling EEGLAB. If you change a field yourself, run EEG = eeg_checkset(EEG);, then store it with [ALLEEG, EEG, CURRENTSET] = eeg_store(ALLEEG, EEG, CURRENTSET); and eeglab redraw. Otherwise the main window may show outdated values.
  • Mixing up channel and electrodeThe physical sensor placed on the scalp to pick up the signal.. EEG.chanlocs(5) is the fifth channel in the data, and its position is the position of the electrode that recorded it. The channel order in a file does not follow any order on the head.

Where can I read more?

2 sources, official docs first

Written for EEGLAB 2026.1 · 2026-10-28

Need help?

Ask, share feedback, or report an error