Channel locations and bad channels
Assign and verify montages, detect bad channels with objective criteria, interpolate, and decide how many bads is too many.
Prerequisites: L2.1 · Loading data and BIDS
3 claims on this page are unverified. TODO(confirm) marks a specific statement the author has not yet checked against a
primary source. Everything else on this page has been reviewed. Treat a marked claim as
provisional and go to the cited source rather than quoting the sentence.
Objectives
- Assign and verify montages
- Detect bad channels with objective criteria (flat, high variance, low neighbour correlation, RANSAC)
- Interpolate bad channels
- Decide how many bads is too many
Why this matters
One dead electrode is not a small problem: it joins the average reference, it enters every ICA decomposition, and it propagates into every neighbouring channel the moment you interpolate. Deciding which channels are bad is the first irreversible judgment in a pipeline, and the only defensible way to make it is with criteria you wrote down before you looked. This lesson gives you those criteria, the interpolation that follows, and the rule for when a recording has too many bads to rescue.
Concepts
Verify the montage before you trust any spatial criterion
Every bad-channel criterion except “flat” is spatial: it asks whether a channel resembles its neighbours. That question is meaningless if the positions are wrong. So the montage check comes first (L2.1):
- every EEG channel has a position (
raw.set_montage(..., on_missing='raise')passes); - plotting the sensors shows a head-shaped layout with the nose where you expect it, not a mirrored or rotated one;
- no two channels share a position, and no channel sits outside the head outline;
- the montage you attached is the montage the recording used — a 10-20 template on a 10-5 cap will attach positions to the names it recognises and leave the rest blank.
Template versus digitized positions. A template (standard_1020, standard_1005) places electrodes at idealised positions on an average head. Digitized positions are measured per subject with an electromagnetic or optical digitizer, and are what ds-lemon ships for a large subset of its subjects. For sensor-level work, a template is usually good enough and its error is shared across subjects; for interpolation of a cap that was placed unusually, and for anything in source space (L5.4), the difference matters.
What makes a channel bad
“Bad” means the signal on this electrode is not a usable measurement of brain activity at this position. There are a handful of recognisable ways for that to happen, and each has an objective measure. These are the criteria implemented by PREP (Bigdely-Shamlo et al., 2015) and its Python port, and they are what the widget shows you:
| Criterion | Measure | Typical failure it catches |
|---|---|---|
| Flat / dead | Fraction of the window with near-zero variance | Disconnected lead, saturated amplifier channel |
| Deviation | Robust z-score of the channel’s amplitude (SD) against all channels | Loose electrode, huge drift, movement on one lead |
| Low neighbour correlation | Maximum correlation with other channels in short windows | An electrode recording something the rest of the head is not |
| RANSAC predictability | Correlation between the channel and its own value predicted from random subsets of the other channels via interpolation | Subtle failures the correlation criterion misses |
| High-frequency noise ratio | Power above the signal band relative to power inside it | Poor contact, EMG-dominated lead |
| Dropout | Fraction of the window with brief flat intervals | Intermittent contact |
Two properties of this list are worth internalising. First, the thresholds are conventions, not constants — a neighbour-correlation cutoff and a robust-deviation cutoff are choices that PREP and its port supply as defaults and that you may change with a reason. TODO(confirm): the exact default threshold values of the pyprep implementation you run, which the notebook prints. Second, the criteria disagree, and that is informative: a channel flagged by one criterion in one window is a different kind of problem from a channel flagged by four criteria throughout.
Bad is a property of a window, not of a recording
An electrode that fails for ninety seconds of a ten-minute recording is not the same object as an electrode that was never connected. Detection therefore runs in short windows (the widget uses 30-second segments), and you decide how to aggregate: a channel bad in every window is bad; a channel bad in 5% of windows is usually better handled as a bad segment (L2.5) than as a bad channel. Recording the fraction of windows in which each channel was flagged, rather than a single boolean, is what lets you make that decision — and it is a row in the QC report of L2.8.
Interpolation: what it does and what it cannot do
Spherical-spline interpolation reconstructs the signal at a bad electrode’s position as a weighted sum of the good channels, using a smooth function fitted over the sphere. In MNE it is raw.interpolate_bads(), and the weights depend only on the electrode geometry, which is why the montage check came first.
What it gives you: a full channel set, so that montage-dependent code, topographic plots and group averaging over a common set of channels all work; and a channel whose values are physically plausible given its neighbours.
What it does not give you: new information. The interpolated channel is a deterministic function of the others. Three consequences follow:
- It cannot recover a local effect that only that electrode would have seen. Interpolating a channel over a focal generator smooths the focus away.
- It is only as good as the spatial sampling around the gap. A bad channel in the middle of a dense cap interpolates well; a bad channel at the edge of the montage, or one surrounded by other bad channels, does not. Contiguous clusters of bad channels are the case where interpolation quietly fails.
- It reduces the rank of the data by one per interpolated channel, because the reconstructed channel is a linear combination of the rest.
Rank, and why it is the thread that connects this lesson to ICA
The rank of your data is the number of linearly independent channels it actually contains. You start with as many as you have electrodes, and then:
- every interpolated channel costs one (it is a linear combination of the others);
- an average reference costs one more (after subtracting the mean, the channels sum to zero);
- a reference channel reconstructed as all zeros costs one;
- any other linear operation applied to the channel set costs whatever it removes.
Nothing in the array’s shape records this. A 64-channel recording with 3 interpolated channels and an average reference has 64 rows and rank 60. ICA (L2.6) estimates as many components as you tell it to, and asking for 64 components from rank-60 data produces degenerate, duplicated components and convergence failures — the pitfall pf-interpolation-rank below. The fix is simply to carry the number with the data and pass it (n_components or rank in MNE) rather than let a default guess.
How many bads is too many
There is no universal number, and inventing one here would be dishonest. What is defensible is a rule with three parts, fixed before you look at your effect:
- A fraction. State the proportion of channels you are willing to interpolate — as a fraction of the montage, not a count, so that it means the same thing on a 30-channel and a 128-channel cap. Whatever value you pick, justify it and apply it to every subject.
- A spatial clause. Interpolating scattered channels is different from interpolating a contiguous patch. A rule that counts channels but not their arrangement will pass a recording where an entire quadrant was reconstructed from its neighbours.
- A region-of-interest clause. A channel you are going to measure at (Pz for a P3, PO7/PO8 for an N2pc) is not interchangeable with a channel you are not. Interpolating the measurement channel itself needs a stated decision, not a default.
The same rule then produces a subject-exclusion criterion, which belongs in the pre-registration alongside the trial-rejection criteria of L2.5 — and not in a decision made after the group analysis was run.
Write the bad-channel rule down before you run it on the first subject, and log every flagged channel with the criterion that flagged it. When a reviewer asks why subject 12 has four interpolated channels, “the criteria are in the config and the QC report lists which one fired” is an answer. “It looked noisy” is not.
Bridging: the failure that looks like success
If electrolyte gel spreads between two neighbouring electrodes, they become electrically connected and record nearly the same signal. Nothing about a bridged pair looks bad: the traces are clean, the variance is normal, and the neighbour correlation is higher than average — so a criterion that flags low correlation will never fire. Interpolation “works” because the pair supports itself. The detection is the opposite test (near-unity correlation between neighbours, and a near-zero variance of their difference), and the fix is at the cap, before recording. That is pf-bridged-electrodes below.
The data behind this lesson
- The widget serves five 30-second segments with their per-channel metrics precomputed, from
ds-eegbci(64 channels, 160 Hz, no hardware filters) andds-dortmund(64 channels, CC0). At least one segment contains a genuinely bad channel, and one contains a planted flat channel: that segment is a labelled synthetic derivative (synthetic: truein its sidecar, withderived_fromand amodificationslist, per §4.5) and the widget says so. - The reference flags the drill grades against are algorithmic (
label_source: algorithmic, produced by a documented detector) until the author reviews them. TODO(confirm): promote the flags tolabel_source: expertafter author review; until then, read a disagreement as a disagreement with a detector, not with a person.
Explore
Work each segment twice. First pass: look only at the traces, mark the channels you would exclude, and write down why. Second pass: open the metric panels and compare. Then ask, for each disagreement, whether the metric caught something your eye could not (high-frequency noise, brief dropouts) or whether you caught something the metric cannot see (a channel that is clean but wrong).
Practice
Channel locations and bad channels: pyprep NoisyChannels against a stated manual rule, interpolation, and what it costs the average reference and the rank nb-2-2-bad-channels
Downloads from ds-erpcore.
The notebook runs pyprep’s NoisyChannels on the same recordings, compares its flags with manual ones, interpolates, and shows what the interpolation does to an average reference — including the rank arithmetic you will need in L2.6. Its final cell prints the flagged channels per criterion, the resulting rank, and the fraction of the montage interpolated.
Exercises
Exercise ex-2-2-flag-bads-drill
Drill (widget-graded)Flag the bad channels in all five segments and reach at least 80% agreement with the reference flags. Agreement is scored per channel, so a false alarm costs the same as a miss.
Graded by the w-bad-channel-detective above: complete a session there and the score is recorded here. Pass mark 80%.
No session recorded yet.
Pitfalls
ICA after interpolation without rank adjustment
- Symptom
- Duplicated or degenerate components; ICA fails to converge.
- Cause
ICA is a change of basis. It can only find as many independent components as the data has independent dimensions — its rank. A recording’s rank is not its channel count if anything linear has been done to it:
- Detect
- Compute the rank explicitly and compare it with the channel count (mne.computerank(inst, rank=‘info’), or the arithmetic above done by hand). A gap you cannot account for is the finding. - Look at the singular values of the channel covariance: a sharp drop to near-zero after k values means the true rank is k. - Inspect the decomposition for near-duplicate pairs (high absolute correlation betwee…
- Fix
- Carry the rank through the pipeline as a number, updated at every linear step, and log it (L2.8). Start at the channel count and subtract: one per interpolated channel, one for an average reference, one per projector. - Pass it explicitly: ICA(ncomponents=rank, …), or MNE’s rank argument, rather than relying on a default derived from the channel count. - Prefer to detect bad channels, re-refe…
Electrode bridging
- Symptom
- Two neighbouring channels are near-identical; interpolation "works".
- Cause
Conductive gel spreads between two neighbouring electrodes and connects them electrically, so both record the same potential. It is most common with dense caps (short distances), with too much gel, with sweating, and with long recordings in which gel migrates. Because bridged channels are not noisy, the usual bad-channel detectors, which look for variance, amplitude or spectral outliers, do not s…
- Detect
- Compute the electrical distance between every pair of channels (the variance of their difference signal over the recording); bridged pairs stand out as near-zero values in an otherwise broad distribution. MNE provides mne.preprocessing.computebridgedelectrodes for this check (TODO(confirm) the citation for the electrical-distance method the author wants listed in the reading list). - Look at a…
- Fix
- At acquisition: use less gel, check impedances for suspiciously low neighbouring pairs, and re-prepare bridged sites before recording. - Offline: mark bridged channels as bad before computing an average reference, interpolating, or running ICA; if both channels of a pair are bridged to each other, keep one and interpolate the other only from unbridged neighbours, or drop the pair. - Keep the br…
In other tools
In other toolsEEGLAB · FieldTrip — names only
The equivalents of what this lesson does, for a reader who works in another toolbox. Function names only: their own documentation is the place to learn how to call them.
EEGLAB
pop_clean_rawdataclean_rawdata pluginpop_rejchanEEGLABpop_interpEEGLAB
FieldTrip
ft_channelrepairFieldTrip
Names checked 2026-09-18 against EEGLAB 2026.0.0 (plugins at the versions in EEGLAB’s own plugin list) and FieldTrip 20251218.
Reading
- Bigdely-Shamlo et al. (2015). PREP. unverified