Station 4 · Lesson 2
How much data ICA needs
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
[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;Your browser's back button takes you to the exact place you were, so open anything you like.
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
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.
Why do I need this step?
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 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.
- Read Channels per frame: 32 in D1.
- 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.
- Read Sampling rate (Hz): 128 in D1.
- 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.
- 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 do it in EEGLAB?
There is no menu for this check. You read three numbers from the main EEGLAB window and do the arithmetic yourself. Start with the main dataset D1 main loaded, as in the Starting point.
- Read Channels per frame: 32 in D1.
- 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.
- Read Sampling rate (Hz): 128 in D1.
- Work out the number of components: the data rank, as in the Running ICA lesson. In D1 it is 32 − 0 interpolated − 1 for the average reference = 31.
- 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
% 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);
endIn 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.
How do I write it as code?
% 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);
endIn D1 the script 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 reference 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.
| Components | Weights (N²) | Data points (k = 30) | Minutes at 250 Hz | Minutes at 128 Hz |
|---|---|---|---|---|
| 32 | 1024 | 30720 | 2.0 | 4.0 |
| 64 | 4096 | 122880 | 8.2 | 16.0 |
| 128 | 16384 | 491520 | 32.8 | 64.0 |
| 256 | 65536 | 1966080 | 131.1 | 256.0 |
When to reduce the rank with 'pca':
| Case | What to do | Why |
|---|---|---|
| Average reference or interpolated channels | Components = channels − interpolated − 1 | The data rank is lower, as in the Running ICA lesson. |
| The recording is too short for all components | Reduce the number with 'pca', for example 'pca', 20 | Fewer components need fewer data points. |
| Enough data and full rank | Do not reduce | Official tutorial: PCAA method that reduces data to fewer dimensions. slightly corrupts the data, so the full-rank data are better whenever possible. |
Which value should I choose?
The table gives the shortest recording for k = 30. Treat it as a minimum, because k should grow with the number of channels.
| Components | Weights (N²) | Data points (k = 30) | Minutes at 250 Hz | Minutes at 128 Hz |
|---|---|---|---|---|
| 32 | 1024 | 30720 | 2.0 | 4.0 |
| 64 | 4096 | 122880 | 8.2 | 16.0 |
| 128 | 16384 | 491520 | 32.8 | 64.0 |
| 256 | 65536 | 1966080 | 131.1 | 256.0 |
When to reduce the rank with 'pca':
| Case | What to do | Why |
|---|---|---|
| Average reference or interpolated channels | Components = channels − interpolated − 1 | The data rank is lower, as in the Running ICA lesson. |
| The recording is too short for all components | Reduce the number with 'pca', for example 'pca', 20 | Fewer components need fewer data points. |
| Enough data and full rank | Do not reduce | Official tutorial: PCA slightly corrupts the data, so the full-rank data are better whenever possible. |
How do I check it worked?
3 quick checks
- 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.
- Points per weight: in D1 it is about 31.7 for 31 components.
- The decision is written down: enough data, or a lower number of components with
'pca'and its reason.
How do I check it worked?
- You know your numbers: channels, data points per channel, sampling rate, and the expected number of components.
- Points per weight: in D1 it is about 31.7 for 31 components.
- 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.
What mistakes do people make?
- 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 epoch 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 electrode 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.
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.
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.How do I write it in my paper?
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
- EEGLAB Concepts guideDocumentationHow many data points do I need to run an ICA?
- EEGLAB TutorialDocumentationIssues with data rank deficiencies
- Makoto's preprocessing pipeline§13.1 What is the minimum length of data to perform ICA?; §12 Adjust data rank for ICA
Written for EEGLAB 2026.1 · 2026-10-28
Going further
- EEGLAB Concepts guide: https://eeglab.org/tutorials/ConceptsGuide/ICA_background.html (How many data points do I need to run an ICA?)
- EEGLAB Tutorial: https://eeglab.org/tutorials/06_RejectArtifacts/RunICA.html (Issues with data rank deficiencies)
- Makoto's preprocessing pipeline: https://eeglab.ucsd.edu/wiki/Makoto%27s_preprocessing_pipeline (§13.1 What is the minimum length of data to perform ICA?; §12 Adjust data rank for ICA)
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".