Station 3 · Lesson 7
Re-referencing
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
[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;Your browser's back button takes you to the exact place you were, so open anything you like.
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?


Drag the line to compare.
What does this show?
The simulation needs JavaScript. Here is a still image of the same idea.
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.
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.
Why do I need this step?
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-referencing computes the data as if they had been recorded with another reference. The two most common choices:
- Average reference: 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 ICA.
- Linked mastoids: the mean of two electrodes behind the ears. Common in ERP 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.
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.
- First make sure the channel count is complete: Channels per frame is 32 in D1.
- Open Tools then Re-reference the data. A window titled pop_reref - average reference or re-reference data appears.
- 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. - Keep Compute average reference checked; it is the default.
- Leave Huber average ref. with threshold unchecked. The official tutorial says it should not be used before ICA.
- Next to Exclude channel indices (EMG, EOG), press … and choose
EOG1andEOG2. The field fills with their names. - Leave Add old ref. channel back to the data empty, because the mastoid channel is not in D1.
- Press OK. The command window prints
Re-referencing data. - Name the new dataset
D1 mainand leave Overwrite it in memory (set=yes; unset=create a new dataset) unchecked. - Save it with File then Save current dataset as. This is the “main dataset” that the ICA lessons start from.
- Compare the two datasets with Plot then Channel data (scroll): all scalp channels changed, and
EOG1andEOG2stayed the same.
How do I do it in EEGLAB?
Start with the main dataset after interpolation loaded, as in the Starting point. In D1 this is D1 badch from the bad channels lesson, because there was nothing to interpolate.
- First make sure the channel count is complete: Channels per frame is 32 in D1.
- Open Tools then Re-reference the data. A window titled pop_reref - average reference or re-reference data appears.
- 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. - Keep Compute average reference checked; it is the default.
- Leave Huber average ref. with threshold unchecked. The official tutorial says it should not be used before ICA.
- Next to Exclude channel indices (EMG, EOG), press … and choose
EOG1andEOG2. The field fills with their names. - Leave Add old ref. channel back to the data empty, because the mastoid channel is not in D1.
- Press OK. The command window prints
Re-referencing data. - Name the new dataset
D1 mainand leave Overwrite it in memory (set=yes; unset=create a new dataset) unchecked. - Save it with File then Save current dataset as. This is the “main dataset” that the ICA lessons start from.
- Compare the two datasets with Plot then Channel data (scroll): all scalp channels changed, and
EOG1andEOG2stayed the same.
How do I write it as code?
The same steps in 18 lines of 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.
How do I write it as code?
% 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
| Setting | Value | Why |
|---|---|---|
| Reference for the ICA path and source analysis | Average reference | The official tutorial recommends it for source analysis, and ICA on our path runs on it. |
| Reference for comparing with earlier ERP studies | The same reference as those studies, often linked mastoids | The reference changes the shape and size of the ERP, so a comparison needs the same reference. |
| Excluded channels | EOG, heart (ECG)The heart's electrical beat that can appear in EEG as regular spikes., and EMG channels | They are not scalp channels, so they do not belong in the scalp average. |
| Adding the old reference channel back | Only if its location is defined in the channel editor | Not in D1, as the official tutorial says. |
| Huber | Not before ICA | Official tutorial: it breaks the linearity ICA needs, and it belongs after ICA. |
Which value should I choose?
| Setting | Value | Why |
|---|---|---|
| Reference for the ICA path and source analysis | Average reference | The official tutorial recommends it for source analysis, and ICA on our path runs on it. |
| Reference for comparing with earlier ERP studies | The same reference as those studies, often linked mastoids | The reference changes the shape and size of the ERP, so a comparison needs the same reference. |
| Excluded channels | EOG, ECG, and EMG channels | They are not scalp channels, so they do not belong in the scalp average. |
| Adding the old reference channel back | Only if its location is defined in the channel editor | Not in D1, as the official tutorial says. |
| Huber | Not before ICA | Official tutorial: it breaks the linearity ICA needs, and it belongs after ICA. |
How do I check it worked?
4 quick checks
- Main window: the Reference line shows
average, and Channels per frame is still 32. - The script check:
EEG.refisaverage, and the sum over scalp channels is a very small number close to zero. - The eye channels did not change: in the scroll view,
EOG1andEOG2look as they did before re-referencing. - The scalp channels changed:
Oz, for example, looks clearly different from its shape with the mastoid reference.
How do I check it worked?
- Main window: the Reference line shows
average, and Channels per frame is still 32. - The script check:
EEG.refisaverage, and the sum over scalp channels is a very small number close to zero. - The eye channels did not change: in the scroll view,
EOG1andEOG2look as they did before re-referencing. - 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.
What mistakes do people make?
- 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.
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.UndoHow 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.How do I write it in my paper?
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
- EEGLAB TutorialDocumentation5. Preprocess data > b. Re-referencing
- EEGLAB TutorialDocumentationConcepts guide: Re-referencing
- Luck, Applied Event-Related Potential Data Analysis (1st edition)Chapter 5: Referencing and Other Channel Operations
- What is the best EEG reference?VideoFull video · 18:21
Written for EEGLAB 2026.1 · 2026-10-27
Going further
- EEGLAB Tutorial: https://eeglab.org/tutorials/05_Preprocess/rereferencing.html (5. Preprocess data > b. Re-referencing)
- EEGLAB Tutorial: https://eeglab.org/tutorials/ConceptsGuide/rereferencing_background.html (Concepts guide: Re-referencing)
- Luck, Applied Event-Related Potential Data Analysis (1st edition): https://socialsci.libretexts.org/Bookshelves/Psychology/Biological_Psychology/Applied_Event-Related_Potential_Data_Analysis_(Luck) (Chapter 5: Referencing and Other Channel Operations)
- What is the best EEG reference?: https://www.youtube.com/watch?v=ioIETUX4G4k (Full video)
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".