"They asked me to read a mind. I got a millivolt smear of a billion neurons shouting through a skull, and a solemn argument about which electrode to subtract from which."
An Overpromised AI Agent
Prerequisites
This section uses the measurement view of Chapter 2: every electrode reports a biased, mixed projection of the source you care about, never the source itself. It leans on the sampling, aliasing, and bandwidth vocabulary of Chapter 3, the power-spectral-density machinery of Chapter 7, and the amplitude and impedance anchors for biosignals from Chapter 28. No neuroscience background is assumed; the physiology you need is built here. All microvolt, hertz, and impedance figures are engineering anchors for sizing pipelines, not clinical diagnostic thresholds.
The Big Picture
Electroencephalography (EEG) is the cheapest, oldest, and fastest window into the working brain: a ring of electrodes on the scalp reading voltages that flicker in step with cortical activity, millisecond by millisecond. That temporal sharpness is why every non-invasive brain-computer interface in this chapter starts here. But an EEG channel is not a measurement of one place in the brain. It is a difference between two electrodes, each of which sums the smeared electrical field of millions of neurons filtered through cerebrospinal fluid, skull, and skin. Before you can classify an intention or decode a movement, you have to answer three deceptively basic questions: what physical quantity is on the wire, where are the electrodes and what are they measured against (the montage), and which rhythms in the signal carry information (the frequency bands). Get these three wrong and every model downstream inherits a substrate it can never repair. This section builds all three.
What is actually on the wire: postsynaptic potentials and volume conduction
An EEG electrode does not hear neurons fire. Action potentials are too brief and too spatially incoherent to sum at the scalp. What EEG measures is the slower, spatially aligned postsynaptic potentials of cortical pyramidal neurons, whose long apical dendrites are stacked in parallel, all pointing perpendicular to the cortical surface. When thousands of these dendrites are excited together, they act like a field of tiny aligned batteries, and their currents add into a measurable extracellular field. A single neuron contributes nothing detectable; only the synchronized activity of a patch of cortex roughly a few square centimeters across produces a scalp signal you can see.
That field then travels to the electrode by volume conduction: the head is a passive conductor, so current spreads and blurs through the tissue layers before reaching the scalp. Two consequences dominate everything that follows. First, the amplitude is tiny. Scalp EEG is on the order of 10 to 100 microvolts, roughly a thousand times smaller than the ECG of Chapter 29, which is exactly why electrode impedance and amplifier noise, introduced in Chapter 28, are make-or-break here. Second, the signal is spatially smeared: the skull is a poor conductor and acts as a spatial low-pass filter, so a compact cortical source appears at the scalp as a broad blob spanning several electrodes. EEG therefore trades away spatial resolution (centimeters, not millimeters) to buy temporal resolution (sub-millisecond). That trade is the defining property of the modality and the reason the invasive arrays of Section 31.5 exist at all.
Key Insight
There is no such thing as an absolute EEG voltage. A voltage is always a difference between two points, so every EEG channel is a pair: an active electrode minus a reference. Change the reference and every number changes, even though the brain did nothing. This is not a nuisance to be tolerated; it is the single most misunderstood fact in EEG. An alpha rhythm that looks huge against an earlobe reference can nearly vanish against an average reference, and a naive model trained on one referencing scheme can silently fail on data recorded with another. Referencing is a modeling choice with the same weight as a filter cutoff or a sample rate, and it must be recorded, matched across train and test, and treated as part of the sensor, not an afterthought.
The 10-20 system and the montage question
To make recordings comparable across people and labs, electrodes are placed by the international 10-20 system: positions are defined as fractions (10 percent and 20 percent) of the distances between skull landmarks (nasion to inion, and ear to ear), so the same label lands over the same brain region regardless of head size. Names encode region and hemisphere: F for frontal, C central, P parietal, O occipital, T temporal; odd numbers sit on the left, even on the right, and z marks the midline (Cz, Pz). Denser caps (the 10-10 and 10-5 extensions) interpolate more sites for 64, 128, or 256 channels. A consumer headset might expose just Fp1, Fp2, and a couple of others; a clinical or research cap covers the whole scalp.
A montage is the recipe that turns raw electrode potentials into the channels you analyze, and it is entirely a choice about the reference. Four families matter. A referential montage subtracts one shared electrode (an earlobe, the mastoid, or the vertex) from every other; it is simple but inherits any noise on that single reference. A bipolar montage subtracts adjacent electrodes in chains, which emphasizes local gradients and is the traditional reading montage for clinical epilepsy review. A common average reference (CAR) subtracts the mean of all electrodes from each, which is the default for most machine-learning pipelines because it is unbiased toward any one site, though it assumes good coverage and clean channels. A surface Laplacian subtracts a local neighborhood average, sharpening focal sources by undoing some of the volume-conduction blur. There is no universally correct montage; each is a spatial filter that trades sensitivity to focal versus distributed sources, and the right one depends on what you are trying to decode.
In Practice: the clinical alpha that vanished on the ward
A hospital neurology team builds a drowsiness monitor that keys on posterior alpha power, the 8 to 12 Hz rhythm that surges when a patient closes their eyes and relaxes. It validates beautifully on a public research dataset recorded with a common average reference. Deployed on the ward, where the bedside system uses a linked-earlobe reference and a sparse cap, the alpha feature reads roughly half its expected amplitude and the monitor misses obvious drowsy epochs. Nothing was wrong with the brains or the model math; the reference changed the projection of the same rhythm onto the channels, and a feature calibrated against one montage does not transfer to another. The fix is not a bigger network. It is to re-reference both datasets to a common scheme before training, treat the montage as a logged part of the sensor configuration, and, following the leakage-safe discipline of Chapter 5, never let a train and test set disagree on how a channel was defined.
Frequency bands: the rhythms that carry information
EEG is analyzed in frequency bands because cortical populations tend to synchronize at characteristic rates, and those rates map, imperfectly but usefully, onto brain states. By long convention the bands are delta (roughly 0.5 to 4 Hz, deep sleep and large slow waves), theta (4 to 8 Hz, drowsiness, memory, and mid-frontal effort), alpha (8 to 12 Hz, relaxed wakefulness, strongest over the occiput with eyes closed), beta (12 to 30 Hz, active concentration and motor control), and gamma (above 30 Hz, fast local processing, but faint and easily confused with muscle artifact at the scalp). These boundaries are conventions, not laws of physics; different sub-fields shift them by a hertz or two, so a band definition is a parameter you set and document, not a constant you inherit.
The workhorse feature is band power: the fraction of signal energy inside a band, computed from the power spectral density (PSD) of a short window. The PSD is the same object built in Chapter 7, and for a band \([f_1, f_2]\) the band power is simply the area under the PSD there,
$$ P_{[f_1,f_2]} = \int_{f_1}^{f_2} S(f)\, df, $$where \(S(f)\) is the one-sided PSD. Two practical wrinkles decide whether this feature is trustworthy. First, EEG spectra are broadly \(1/f\): power falls off steeply with frequency, so raw band powers are dominated by the slow bands and are usually compared as relative band power (each band divided by total power) or in decibels. Second, the sampling rules of Chapter 3 bite hard: line noise at 50 or 60 Hz sits right inside the gamma band, and any muscle tension adds broadband high-frequency power, so a gamma feature is only as honest as the artifact handling that precedes it, which is the whole subject of Section 31.2.
| Quantity | Typical value | Why it matters |
|---|---|---|
| Scalp amplitude | 10 to 100 µV | Sets amplifier gain and noise budget |
| Electrode impedance | < 5 to 10 kΩ (gel); higher for dry | Drives noise and artifact susceptibility |
| Sample rate | 250 to 1000 Hz | 256 Hz covers up to beta/low gamma cleanly |
| Delta / theta / alpha | 0.5-4 / 4-8 / 8-12 Hz | Sleep, drowsiness, relaxed wakefulness |
| Beta / gamma | 12-30 / >30 Hz | Motor control; fast processing (artifact-prone) |
| Spatial resolution | ≈ centimeters | Skull blur; why sources span many electrodes |
The program below synthesizes a short EEG-like epoch as a \(1/f\) background plus an injected alpha oscillation, re-references two channels to their common average, and computes relative band power with Welch's method. It makes the reference choice and the band-power feature concrete before we clean real recordings in the next section.
import numpy as np
from scipy import signal
fs = 256.0 # samples per second
t = np.arange(0, 4.0, 1 / fs) # a 4-second epoch
rng = np.random.default_rng(0)
# 1/f-ish background: cumulative sum of noise, plus an 10 Hz alpha burst
def channel(alpha_uv):
pink = np.cumsum(rng.standard_normal(t.size)) # brown/pink-ish drift
pink = 20 * (pink - pink.mean()) / pink.std()
alpha = alpha_uv * np.sin(2 * np.pi * 10 * t) # posterior alpha
return pink + alpha
Oz = channel(alpha_uv=15) # strong occipital alpha
Fz = channel(alpha_uv=2) # weak frontal alpha
car = 0.5 * (Oz + Fz) # common average reference
Oz_car = Oz - car # re-referenced channel
f, psd = signal.welch(Oz_car, fs=fs, nperseg=int(fs)) # PSD of the epoch
bands = {"theta": (4, 8), "alpha": (8, 12), "beta": (12, 30)}
total = np.trapz(psd, f)
for name, (lo, hi) in bands.items():
m = (f >= lo) & (f < hi)
rel = np.trapz(psd[m], f[m]) / total
print(f"{name:>5}: relative power = {100 * rel:5.1f} %")
Fz instead of the average) changes every number, which is the point of the Key Insight above.As Listing 31.1 shows, band power is a handful of lines once the reference and window are fixed, and the alpha injection dominates the relative spectrum exactly as posterior alpha does in a relaxed subject. The same PSD machinery, per channel, is the feature substrate under the classical motor-imagery and SSVEP decoders of Section 31.3, and it is what the EEG foundation models of Section 31.4 aim to replace with learned representations.
The Right Tool
Hand-building a full EEG front end (parsing an electrode montage, applying a reference transform, band-pass and notch filtering, epoching, and per-band power) is easily 150 to 200 lines of careful code, and the montage bookkeeping is where subtle bugs hide. The MNE-Python library reduces the reference-and-bandpower step to a few calls on a typed Raw object that already knows its channel names and positions:
import mne
raw = mne.io.read_raw_edf("subject.edf", preload=True) # channels + montage
raw.set_eeg_reference("average") # common average ref
raw.filter(1., 40.) # band-pass in place
psd = raw.compute_psd(fmin=1, fmax=40, method="welch") # per-channel PSD
alpha = psd.get_data(fmin=8, fmax=12).sum(axis=-1) # alpha band power
MNE-Python collapses roughly 180 lines of montage-aware front-end code into five, because the Raw object carries channel names, positions, and units so the reference and band-power operations are well-defined. It handles the bookkeeping; choosing the reference, the filter band, and the epoching to match your decoding task and your leakage-safe split remains your job.
Research Frontier
The frontier is moving past hand-defined bands entirely. Large self-supervised EEG models, LaBraM, EEGPT, BIOT, and CBraMod among them, are pre-trained on tens of thousands of hours of heterogeneous recordings and learn their own time-frequency features rather than consuming fixed delta-through-gamma band powers. A central design problem these models confront is precisely the material of this section: recordings differ in channel count, montage, and reference, so the models tokenize per-channel patches and encode electrode identity and position, letting a single network ingest a 4-channel consumer headset and a 128-channel research cap. The open question is whether learned features genuinely beat well-tuned classical band powers under honest, subject-independent evaluation, which is the standing benchmark tension developed in Section 31.4 and echoed for wearables in Chapter 20.
Exercise
Modify Listing 31.1 to compute the alpha relative power of the Oz channel under three references: no reference (raw Oz), the common average, and a bipolar Oz - Fz. Report the three alpha percentages. Then, in three or four sentences, explain why the numbers differ even though the underlying alpha source is identical, and state which reference you would choose for a drowsiness detector on a sparse two-channel headset and why. Finally, add 60 Hz line noise to both channels and describe what it does to the beta and (hypothetical) gamma bands.
Self-Check
1. EEG measures postsynaptic potentials of aligned pyramidal neurons, not action potentials, and only when a patch of cortex is synchronized. Why does this, together with volume conduction through the skull, give EEG excellent temporal but poor spatial resolution?
2. Why is there no absolute EEG voltage, and what practically goes wrong if a model is trained on common-average-referenced data and deployed on linked-earlobe data?
3. Raw EEG band powers are dominated by the slow bands because the spectrum is roughly \(1/f\). Name two things practitioners do about this, and explain why a gamma-band feature is especially hazardous at the scalp.
What's Next
In Section 31.2, we confront the fact that a raw scalp trace is mostly not brain: eye blinks, jaw and neck muscle, heartbeat, and electrode pops routinely dwarf the microvolt cortical signal. We build the artifact-removal toolkit, from independent component analysis to regression and modern automated pipelines, and turn the clean epochs into the spectral and connectivity features that the decoders of the rest of this chapter depend on.