Station 9 · Lesson 4

Automated pipelines: when to use them

Optional15 minBefore this lesson: Batch processingPrint 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;
eeglabRoot = fileparts(which('eeglab'));
EEG = pop_loadset('eeglab_data.set', fullfile(eeglabRoot, 'sample_data'));

% Show the dataset in the main EEGLAB window
[ALLEEG, EEG, CURRENTSET] = pop_newset(ALLEEG, EEG, 0, 'setname', 'D1 raw', 'gui', 'off');
eeglab redraw;

The idea in brief

In stations 3 to 5 you built a preprocessingCleaning and preparing the data before analysis. pipelineThe fixed sequence of processing steps from raw data to results. by hand: filteringApplying a filter to the data., line noiseInterference from the mains supply at 60 Hz in Saudi Arabia or 50 Hz elsewhere., bad channels, referenceThe point against which each channel's voltage is measured., ICAA method that separates the recording into independent sources, some brain and some artifact., then epochA short time segment cut out around an event.. Every lab repeats these steps, so several groups have packaged them into ready-made pipelines that run on all participants without your intervention.

Before and after

Two spectra side by side, 1 to 64 Hz. Left, raw data: an alpha peak at 10 Hz and a sharp peak at 60 Hz. Right, after PREP: the 60 Hz peak is still there but smaller, and the alpha peak keeps its shape.
Left: raw. Right: after PREP (PrepPipeline 0.57.0)Data: 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

These pipelines save a lot of time, especially with large datasets. But each one makes dozens of decisions for you: which channelThe signal recorded from one electrode, as shown in EEGLAB. is bad, which component is an eye, which segment to delete. If you do not know these decisions, you cannot defend them in your paper or notice when they go wrong.

A ready-made pipeline saves time, but it does not excuse you from understanding every step in it.

That is why this lesson comes after you built the pipeline yourself. In it you compare the six common pipelines, then run one of them (PREP) on D1 and check its output the same way you would check any pipeline.

Six pipelines in one table

All of them are separate tools, not bundled with EEGLAB. Versions are as they were when this lesson was written.

PipelineDesigned forWhat it does in briefHow you run it
PREP (PrepPipeline 0.57.0)Any EEGA recording of the brain's electrical activity from electrodes on the scalp., especially large datasetsThe early stage only: line noiseAny part of the recording that does not carry the information we want. reduction, a robust average referenceA reference equal to the mean of all scalp channels., bad channelA channel that is flat or noisy for most of the recording. detection and interpolation. It does not run ICA.EEGLAB plugin: Tools then Run PREP pipeline
HAPPE (v4)Infant and child data, and recordings with few channelsA full pipeline up to clean epochs, with a quality table for each fileMATLAB scripts that use EEGLAB, run from the HAPPE folder
MADE (v1.0)Infant and child dataA full pipeline with automatic detection of bad channels and artifact componentsOne MATLAB script that you edit and run
RELAX (2.0.1)Adult data, for ERPs and oscillationsCleans eye and muscle artifacts with several methods together (MWF, wICA and ICLabel)EEGLAB plugin, needs other plugins its guide lists
BeMoBIL (2.0.0)EEG during movement (mobile EEG) with motion dataImport, cleaning, AMICA and analysis with all parameters in one config fileEEGLAB plugin and scripts
AutomagicLarge datasets for users who do not want to programRuns several steps (including PREP), then rates the quality of each fileIts own GUI from the Automagic menu in EEGLAB

Whatever pipeline you choose, check three things in its output before you continue:

  1. The channels: how many channels were removed or interpolated, and which ones? Compare them with what you see in Plot then Channel data (scroll).
  2. The spectrum: compare the spectrum before and after. The line peak should become clearly smaller, and the rest of the spectrum should not collapse.
  3. The report: read the pipeline’s report for each participant. A participant with too many removed channels or components needs a look, or exclusion.

How do I do it in EEGLAB?

10 steps in the menus

First: install PREP

  1. Open File then Manage EEGLAB extensions, search for PrepPipeline and install it (the latest release when this lesson was written is 0.57.0). Restart eeglab, and the item Run PREP pipeline appears in the Tools menu.

Second: look at the data before

  1. Start from D1 raw, as in “Starting point”. These are the data as downloaded, without filtering.
  2. Open Plot then Channel spectra and maps and keep the defaults. Note the sharp peak at 60 Hz, as in the line noise lesson.

Third: run PREP

  1. Open Tools then Run PREP pipeline. The PREP pipeline control panel window opens with six buttons, one for each stage.
  2. Click Reference. In Reference channels, Evaluation channels and Re-referenced channels, type [1 3:5 7:32], that is, all channels except EOG1 (channel 2) and EOG2 (channel 6). Click Ok.
  3. Click Line noise and check that Line frequencies removed shows 60. PREP computes it from the sampling rate: multiples of 60 below Nyquist, which is 64 Hz in D1. Click Ok.
  4. Click Ok in the control panel. PREP prints each stage in the command window and takes about a minute on D1. When it finishes, it writes a summary file (.html) and a detailed report (.pdf) in your working folder, and asks you to name the new dataset. Name it D1 prep.

Fourth: check the output

  1. Open the .html summary file in a browser. Look for the list of interpolated channels and the list of channels still noisy after the reference.
  2. Open Plot then Channel spectra and maps again on D1 prep. The 60 Hz peak is smaller but still there, clearly so in a few channels. PREP’s line noise step reduces the peak; it does not remove it completely. If the remaining peak matters for your analysis, add the band-stop filter from the line noise lesson after PREP.
  3. Compare with your result in the bad channels lesson: there clean_rawdata did not remove any channel from D1. If PREP interpolated a channel, open Plot then Channel data (scroll) and look at it yourself before you accept the decision.

How do I write it as code?

The same steps in 35 lines of MATLAB

Continues from “Starting point”. PREP’s own function prepPipeline is the clearest way to call it from a script, as in the example that ships with the plugin. The script does not write the report; it prints the results directly.

MATLAB
% PREP is not bundled with EEGLAB: install it from the extension manager
plugin_askinstall('PrepPipeline', 'prepPipeline', true);

% Keep a copy of the raw data to compare spectra
EEG_raw = EEG;

% Scalp channels only; EOG is cleaned of line noise but not referenced
eegChans = find(~ismember({EEG.chanlocs.labels}, {'EOG1', 'EOG2'}));

params = struct();
params.name = 'D1';
params.lineFrequencies = 60;
params.detrendChannels = 1:EEG.nbchan;
params.lineNoiseChannels = 1:EEG.nbchan;
params.referenceChannels = eegChans;
params.evaluationChannels = eegChans;
params.rereferencedChannels = eegChans;

% Line noise reduction, robust reference, bad channel interpolation
[EEG, params] = prepPipeline(EEG, params);
EEG.setname = 'D1 prep';

% What did PREP decide?
nd = EEG.etc.noiseDetection;
if ~strcmp(nd.errors.status, 'good')
    error('PREP stopped with status: %s', nd.errors.status);
end
fprintf('PREP version: %s\n', nd.version);
fprintf('Interpolated channels: %s\n', ...
    strjoin({EEG.chanlocs(nd.interpolatedChannelNumbers).labels}, ', '));
fprintf('Still noisy after reference: %s\n', ...
    strjoin({EEG.chanlocs(nd.stillNoisyChannelNumbers).labels}, ', '));

% Spectrum before and after
figure; pop_spectopo(EEG_raw, 1, [], 'EEG', 'freqrange', [1 64], 'freq', [10 60]);
figure; pop_spectopo(EEG, 1, [], 'EEG', 'freqrange', [1 64], 'freq', [10 60]);

% PREP leaves the data unfiltered: high-pass before ICA or epochs
EEG = pop_eegfiltnew(EEG, 'locutoff', 0.1);

EEG.filename = ''; EEG.filepath = ''; EEG.datfile = ''; EEG.saved = 'no';
[ALLEEG, EEG, CURRENTSET] = pop_newset(ALLEEG, EEG, 0, 'setname', 'D1 prep', 'gui', 'off');
eeglab redraw;

Which value should I choose?

Suitable values for your analysis goal
SettingValue in this lessonWhy
Reference and evaluation channelsScalp channels onlyEOG channels carry large blinks. If they enter the reference or the bad channel tests, they distort both.
Line frequencies60D1 was recorded with 60 Hz mains. For data recorded with 50 Hz mains, PREP’s default is wrong: set [50 100 150 200] up to below Nyquist.
Reference typerobust (the default)PREP finds bad channels, computes the average reference without them, and repeats until the result stabilises.
Interpolationpost-reference (the default)Bad channels are interpolated after the reference is computed and stay in the data, so the channel count does not change.
Keep filteredNo (the default)PREP high-passes a copy at 1 Hz for its tests only. The output stays unfiltered, so the filtering choice remains yours.

How do I check it worked?

4 quick checks
  • The command window prints PREP version: PrepPipeline0.57.0.
  • The list of interpolated channels is printed, even if empty. Compare it with what you found in the bad channels lesson.
  • The 60 Hz peak in D1 prep is clearly smaller than in the raw spectrum (about 11 dB above its neighbours instead of about 23 dB), and the alpha peak at 10 Hz keeps its shape.
  • The channel count of D1 prep is still 32.

What mistakes do people make?

6 mistakes and how to avoid them
  • Trusting the pipeline without opening its report. Every pipeline makes mistakes on some participants. Read the report for each participant, and look at the data of any participant with many removed channels.
  • Leaving the line frequency at its default for 50 Hz data. PREP computes multiples of 60 by default. In data recorded with 50 Hz mains, it works on the wrong frequency and leaves the real peak.
  • Expecting PREP to remove the line peak completely. In D1 the 60 Hz peak drops by about half in dB and stays visible. Look at the spectrum after PREP, and add a band-stop filter if you need the peak gone.
  • Assuming PREP filtered the data. The output of PREP is not high-passed. If you go straight to ICA or epochs, the slow drift is still there.
  • Changing pipelines between participants. Every participant in one study goes through the same pipeline with the same settings. If you change a setting, rerun everyone.
  • Applying a pipeline outside its population. HAPPE and MADE were designed for children, and BeMoBIL for movement. Their settings may not suit adult data recorded at rest, and the reverse.

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.

Line noise at 60 Hz was attenuated, and robust average referencing with bad channel detection and interpolation was performed, with the PREP pipeline (prepPipeline, PrepPipeline plugin [0.57.0], EEGLAB 2026.1), using the scalp channels as reference and evaluation channels; [n] channels were interpolated.

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