Station 3 · Lesson 7

Re-referencing

Core15 minBefore this lesson: Channel interpolationPrint the card
Starts from: eeglab_data.set (D1) · Already applied: High-pass & low-pass filtering, Removing line noise (50/60 Hz), Bad channels, Channel interpolationDownload the data (opens in a new tab)
Script to reach this state
MATLAB
[ALLEEG, EEG, CURRENTSET, ALLCOM] = eeglab;
eeglabRoot = fileparts(which('eeglab'));
EEG = pop_loadset('eeglab_data.set', fullfile(eeglabRoot, 'sample_data'));
fullLocs = EEG.chanlocs;

% Main dataset: high-pass at 0.1 Hz, then 60 Hz line-noise removal
EEG = pop_eegfiltnew(EEG, 'locutoff', 0.1);
EEG = pop_eegfiltnew(EEG, 'locutoff', 58, 'hicutoff', 62, 'revfilt', 1);

% Bad channels you removed earlier, e.g. {'T7'}; leave empty if none
badChans = {};
if ~isempty(badChans)
    EEG = pop_select(EEG, 'rmchannel', badChans);
    EEG = pop_interp(EEG, fullLocs, 'spherical');
end
EEG.filename = ''; EEG.filepath = ''; EEG.datfile = ''; EEG.saved = 'no';
[ALLEEG, EEG, CURRENTSET] = pop_newset(ALLEEG, EEG, 0, 'setname', 'D1 interp', 'gui', 'off');
eeglab redraw;

The idea in brief

Voltage is not measured at a single point. Each channelThe signal recorded from one electrode, as shown in EEGLAB. measures the difference between its electrodeThe physical sensor placed on the scalp to pick up the signal. and another electrode called the referenceThe point against which each channel's voltage is measured.. So the reference shapes every channel.

Before and after

The simulation needs JavaScript. Here is a still image of the same idea.

This is a simulation. The pipeline setting in this lesson is average reference

What does this show?
Show
Five seconds of FPz, Cz, Pz, Oz and EOG1 with the original (mastoid) reference, scale 180 µV.
Before: original referenceData: EEGLAB sample data (eeglab_data.set)
The same channels and seconds after the average reference, same scale: the scalp channels changed shape, while EOG1 did not because it was excluded.
After: average referenceData: EEGLAB sample data (eeglab_data.set)

Your next questions, each answered in its own section:

Why do I need this step?

The reasons in detail, and the terms you need

If you change the reference, all channels change together. A channel close to the old reference looks small, and after the change it may grow a lot. There is no “true” channel without a reference.

re-referencingChanging the reference after recording by expressing voltages relative to a new one. computes the data as if they had been recorded with another reference. The two most common choices:

  • average referenceA reference equal to the mean of all scalp channels.: the mean of all scalp channels at each moment. The official tutorial recommends it for source analysis, and it is the reference on our path before ICAA method that separates the recording into independent sources, some brain and some artifact..
  • linked mastoidsA reference equal to the mean of the two electrodes behind the ears.: the mean of two electrodes behind the ears. Common in ERPThe brain's average response to a given event across many trials. studies, such as Luck’s book.
About D1

it was recorded with a mastoid reference, as the official tutorial says, and the reference channel is not in the data. So you do not add it, and you cannot try linked mastoids on D1. Try it in the simulation below.

How do I do it in EEGLAB?

11 steps in the menus

Start with the main datasetOne EEG data file loaded in EEGLAB together with its information. after interpolationEstimating a removed channel's signal from the channels around it. loaded, as in the Starting point. In D1 this is D1 badch from the bad channels lesson, because there was nothing to interpolate.

  1. First make sure the channel count is complete: Channels per frame is 32 in D1.
  2. Open Tools then Re-reference the data. A window titled pop_reref - average reference or re-reference data appears.
  3. The first line, Current data reference state is:, shows the current reference. In D1 it may show unknown, because the file does not store the reference name for each channel.
  4. Keep Compute average reference checked; it is the default.
  5. Leave Huber average ref. with threshold unchecked. The official tutorial says it should not be used before ICA.
  6. Next to Exclude channel indices (EMG, EOG), press … and choose EOG1 and EOG2. The field fills with their names.
  7. Leave Add old ref. channel back to the data empty, because the mastoid channel is not in D1.
  8. Press OK. The command window prints Re-referencing data.
  9. Name the new dataset D1 main and leave Overwrite it in memory (set=yes; unset=create a new dataset) unchecked.
  10. Save it with File then Save current dataset as. This is the “main dataset” that the ICA lessons start from.
  11. Compare the two datasets with Plot then Channel data (scroll): all scalp channels changed, and EOG1 and EOG2 stayed the same.

How do I write it as code?

The same steps in 18 lines of MATLAB
MATLAB
% Keep a copy to compare before and after
EEG_before = EEG;

% Average reference, EOG channels excluded
eogIdx = find(ismember({EEG.chanlocs.labels}, {'EOG1', 'EOG2'}));
EEG = pop_reref(EEG, [], 'exclude', eogIdx);
EEG.setname = 'D1 main';

% Check: scalp channels now sum to (almost) zero at every time point
scalpIdx = setdiff(1:EEG.nbchan, eogIdx);
fprintf('Reference: %s\n', EEG.ref);
fprintf('Largest sum over scalp channels: %g uV\n', max(abs(sum(EEG.data(scalpIdx, :), 1))));

% Channel Oz over 5 seconds, before and after
oz = find(strcmp({EEG.chanlocs.labels}, 'Oz'));
t = 1:5*EEG.srate;
figure;
plot(t / EEG.srate, EEG_before.data(oz, t), t / EEG.srate, EEG.data(oz, t));
legend('Original reference (mastoid)', 'Average reference');
xlabel('Time (s)'); ylabel('Amplitude (uV)');

EEG = pop_saveset(EEG, 'filename', 'D1_main.set', 'filepath', pwd);

This is the same pop_reref line as in the Starting point scripts of the ICA lessons. The number the check prints is very small but not exactly zero, because the data are stored in single precision.

Which value should I choose?

Suitable values for your analysis goal
SettingValueWhy
Reference for the ICA path and source analysisAverage referenceThe official tutorial recommends it for source analysis, and ICA on our path runs on it.
Reference for comparing with earlier ERP studiesThe same reference as those studies, often linked mastoidsThe reference changes the shape and size of the ERP, so a comparison needs the same reference.
Excluded channelsEOG, heart (ECG)The heart's electrical beat that can appear in EEG as regular spikes., and EMG channelsThey are not scalp channels, so they do not belong in the scalp average.
Adding the old reference channel backOnly if its location is defined in the channel editorNot in D1, as the official tutorial says.
HuberNot before ICAOfficial tutorial: it breaks the linearity ICA needs, and it belongs after ICA.

How do I check it worked?

4 quick checks
  1. Main window: the Reference line shows average, and Channels per frame is still 32.
  2. The script check: EEG.ref is average, and the sum over scalp channels is a very small number close to zero.
  3. The eye channels did not change: in the scroll view, EOG1 and EOG2 look as they did before re-referencing.
  4. The scalp channels changed: Oz, for example, looks clearly different from its shape with the mastoid reference.

What mistakes do people make?

5 mistakes and how to avoid them
  • Including EOG or ECG channels in the average reference. These are non-brain channels, and their large signal enters every channel through the average. Exclude them in Exclude channel indices (EMG, EOG).
  • Forgetting that the average reference reduces the data rank by one. After an average reference the scalp channels sum to zero, so any one of them equals minus the sum of the others. That is why in D1 the data rank becomes 31, not 32, and ICA gives 31 components.
  • Re-referencing before interpolation. An average over missing channels leans toward the side with more channels. Interpolate first.
  • Changing the reference after ICA. The weights are tied to the reference ICA was computed on. Re-reference before ICA and leave it afterward. EEGLAB warns you if you change it.
  • Adding a reference channel that does not exist. In D1 the mastoid channel is not in the data. Do not fill Add old ref. channel back to the data unless you defined it in the channel editor.

How do I write it in my paper?

A Methods template: edit the data, settings and versions to match what you ran

A template: edit the data, settings and versions to match what you ran.

Data were re-referenced to the average of all scalp channels (pop_reref, EEGLAB 2026.1); EOG channels were excluded from the reference.

Where can I read more?

4 sources, official docs first

Written for EEGLAB 2026.1 · 2026-10-27

Need help?

Ask, share feedback, or report an error