Station 4 · Lesson 2

How much data ICA needs

Recommended10 minBefore this lesson: ICA, simply explainedPrint the card
Starts from: eeglab_data.set (D1) · Already applied: High-pass & low-pass filtering, Removing line noise (50/60 Hz), Bad channels, Channel interpolation, Re-referencingDownload 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

% Average reference, EOG channels excluded
eogIdx = find(ismember({EEG.chanlocs.labels}, {'EOG1', 'EOG2'}));
EEG = pop_reref(EEG, [], 'exclude', eogIdx);
EEG.filename = ''; EEG.filepath = ''; EEG.datfile = ''; EEG.saved = 'no';
[ALLEEG, EEG, CURRENTSET] = pop_newset(ALLEEG, EEG, 0, 'setname', 'D1 main', 'gui', 'off');
eeglab redraw;

The idea in brief

ICAA method that separates the recording into independent sources, some brain and some artifact. learns an unmixing matrix: one weight for every pair of channelThe signal recorded from one electrode, as shown in EEGLAB. and component. With 32 channels that is 32 × 32 = 1024 weights. Each weight has to be learned from the data, so ICA needs enough data points to learn them all.

Before and after

Curve of the shortest recording ICA needs against the number of components, at k = 30 and 250 Hz. Horizontal axis: 32, 64, 128 and 256 components; vertical axis: minutes of recording. Points: 32 components 2.0 min, 64 components 8.2 min, 128 components 32.8 min, 256 components 131.1 min. At 256 a dashed note: k = 30 may not be enough here (official guide).

Your next questions, each answered in its own section:

Why do I need this step?

The reasons in detail, and the terms you need

The official EEGLAB guide gives this rule: to find N stable components, you typically need more than k × N² data points per channel. N² is the number of weights, and k is a multiplier: how many data points each weight gets.

Two things matter most:

  • The number of components grows as a square. Doubling the channels from 32 to 64 needs four times the data, not twice.
  • k is not fixed. The official guide says k increases as the number of channels increases. Its example uses 32 channels and about 30 points per weight, and it says that even 30 points per weight does not appear to be enough for 256 components.

How do I do it in EEGLAB?

5 steps in the menus

There is no menuA list of commands that opens from its name at the top of the window. for this check. You read three numbers from the main EEGLAB window and do the arithmetic yourself. Start with the main datasetOne EEG data file loaded in EEGLAB together with its information. D1 main loaded, as in the Starting point.

  1. Read Channels per frame: 32 in D1.
  2. Read Frames per epoch: 30504 in D1. For continuous data this is the number of data points per channel. For epoched data, multiply it by Epochs.
  3. Read Sampling rate (Hz): 128 in D1.
  4. Work out the number of components: the data rankThe number of truly independent channels; it drops after interpolation or average reference., as in the Running ICA lesson. In D1 it is 32 − 0 interpolated − 1 for the average referenceA reference equal to the mean of all scalp channels. = 31.
  5. Divide: 30504 / 31² = 30504 / 961 ≈ 31.7 points per weight. This is close to the official example, which uses almost the same tutorial dataset (30800 points, 32 channels), so D1 has enough data for 31 components.

How do I write it as code?

The same steps in 12 lines of MATLAB
MATLAB
% How much data ICA has in the current dataset
nComp   = EEG.nbchan - numel(badChans) - 1;   % expected rank after average reference
nPoints = EEG.pnts * EEG.trials;
fprintf('Data points per channel: %d\n', nPoints);
fprintf('Recording length: %.2f min\n', nPoints / EEG.srate / 60);
fprintf('Points per weight, %d channels: %.1f\n', EEG.nbchan, nPoints / EEG.nbchan^2);
fprintf('Points per weight, %d components: %.1f\n', nComp, nPoints / nComp^2);

% Shortest recording that gives k = 30 points per weight at this sampling rate
k = 30;
for N = [32 64 128 256]
    fprintf('%3d components: at least %.1f min\n', N, k * N^2 / EEG.srate / 60);
end

In D1 the scriptA MATLAB file of commands that runs processing steps in order. prints 30504 points, 3.97 minutes, 29.8 points per weight for 32 channels, and 31.7 for 31 components. Then the shortest lengths at 128 Hz: 4.0, 16.0, 64.0, and 256.0 minutes.

Notice that D1 is just under 4 minutes, right at the limit for k = 30 with 32 channels. The average referenceThe point against which each channel's voltage is measured. lowers the components to 31, which brings it back above the limit.

Which value should I choose?

Suitable values for your analysis goal

The table gives the shortest recording for k = 30. Treat it as a minimum, because k should grow with the number of channels.

ComponentsWeights (N²)Data points (k = 30)Minutes at 250 HzMinutes at 128 Hz
321024307202.04.0
6440961228808.216.0
1281638449152032.864.0
256655361966080131.1256.0

When to reduce the rank with 'pca':

CaseWhat to doWhy
Average reference or interpolated channelsComponents = channels − interpolated − 1The data rank is lower, as in the Running ICA lesson.
The recording is too short for all componentsReduce the number with 'pca', for example 'pca', 20Fewer components need fewer data points.
Enough data and full rankDo not reduceOfficial tutorial: PCAA method that reduces data to fewer dimensions. slightly corrupts the data, so the full-rank data are better whenever possible.

How do I check it worked?

3 quick checks
  1. You know your numbers: channels, data points per channel, sampling rateThe number of samples recorded per second on each channel., and the expected number of components.
  2. Points per weight: in D1 it is about 31.7 for 31 components.
  3. The decision is written down: enough data, or a lower number of components with 'pca' and its reason.

What mistakes do people make?

5 mistakes and how to avoid them
  • Counting minutes and forgetting the sampling rate. The rule counts data points. The same 4 minutes give 30720 points at 128 Hz and 60000 points at 250 Hz.
  • Doubling the data for double the channels. The need grows with N², so 64 channels need four times the data of 32.
  • Running ICA on each epochA short time segment cut out around an event. or short block separately. Independence must be fully expressed in the data, which needs many data points, as the official FAQ explains. Decompose all the data together.
  • Mixing sessions from different days. The official guide advises running ICA separately on sessions recorded on different days, because the electrodeThe physical sensor placed on the scalp to pick up the signal. positions differ slightly.
  • Reducing with 'pca' only to save time. PCA slightly corrupts the data. Use it for a reason: a lower rank, or too little data.

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.

The ICA training data comprised [30504] samples per channel ([3.97] min at 128 Hz), giving [31.7] data points per unmixing weight for [31] components.

Where can I read more?

3 sources, official docs first

Written for EEGLAB 2026.1 · 2026-10-28

Need help?

Ask, share feedback, or report an error