A sibling to the PET scanner simulator. Describe a recording in a few lines, record it from dipole sources inside a layered head, contaminate it with the artifacts every lab knows, and then do what an analyst does: re-reference, filter, remove components, average and localize. Every view is computed from the same simulated data, and the simulator always knows the truth, so you can check every answer.
An EEG sample is the end of a chain of five physical steps. Synaptic currents in thousands of aligned pyramidal cells add up to a current dipole. The dipole drives volume currents through the brain, the cerebrospinal fluid, the skull and the scalp, so a potential appears everywhere on the head. Electrodes sample that potential at standard positions. A differential amplifier measures each electrode against a reference and rejects what they share. A digitizer samples the result in time and rounds it to whole steps. Each stage below is interactive; each one leaves a fingerprint you will meet again in the recording.
A fold of cortex. Pyramidal cells stand perpendicular to the cortical surface, so on the crown of a gyrus they point at the scalp and on the wall of a sulcus they lie along it. Positive current enters the apical dendrites at the synapses (a current sink in the extracellular space, so negative there), flows down inside the cell and leaves near the soma (a source). Seen from far away the loop is a current dipole.
Scalp map for the active patch, computed with the same head model the rest of the simulator uses. Synchronous cells add linearly, N of them making N times one cell's dipole; asynchronous cells add like a random walk, as the square root of N. That is why EEG sees synchrony, not activity. The numbers are order-of-magnitude estimates.
A coronal slice through the model head with a radial dipole under the vertex. The coloured band on the scalp is the potential the dipole produces there, computed exactly for the layered sphere. The skull is the layer that matters: it conducts tens of times worse than brain, so current spreads sideways in the CSF and scalp before it can cross it.
Positions are proportional, not absolute. The midline from nasion to inion is divided 10%, 20%, 20%, 20%, 20%, 10%, and the same rule runs from ear to ear, so every head gets the same anatomical coverage. Letters name the region (Fp frontopolar, F frontal, C central, T temporal, P parietal, O occipital); odd numbers are on the left, even on the right, and z marks the midline. The 10-10 extension fills in the 10% positions between them (AF, FC, CP, PO and the 1, 2, 5, 6 columns) for denser caps. M1 and M2 sit on the mastoid bones behind the ears and are a common reference.
The body picks up mains voltage capacitively, so every electrode carries the same large common-mode signal on top of a few microvolts of brain activity. The amplifier outputs the difference between its two inputs. Each electrode impedance and the amplifier's input impedance form a voltage divider; if the two electrodes have different impedances the common mode reaches the two inputs at slightly different sizes and part of it survives the subtraction. The ground electrode gives the amplifier a common point. It is not the reference.
The sampling theorem says a signal is captured only if it contains nothing above half the sampling rate, the Nyquist frequency. Anything faster is not lost, it folds back and masquerades as a slower signal. That is why every EEG amplifier low-pass filters before the digitizer: once a 60 Hz hum has aliased to 40 Hz no later filter can tell it from brain activity. Quantization rounds every sample to a step of range / 2bits.
Every EEG study can be written down as a handful of decisions: which cap and how many channels, which electrode is the online reference, how fast to sample, what the hardware filters do, what the participant does and when, and what is in the head. The program on the left is exactly that, in a small language. Change a line and press Build recording: the simulator records a new session and every other tab updates. The examples are a good place to start. The language is described under the editor.
A program is a few blocks in braces. Inside a block each statement is a keyword and its values. A number takes a unit
(Hz, ms, s, uV, mV, nAm, kOhm, cm,
deg, S/m, bpm, dB) or a %, and the unit says what the number is, so
blinks 0.2 Hz 150 uV and blinks 150 uV 0.2 Hz mean the same. In a run of numbers the last unit applies to all:
epoch -200 800 ms. Line breaks are only spacing, and # starts a comment.
| Statement | Meaning |
|---|---|
| recording { ... } | |
| cap 19 | 32 | 64 | Number of channels on a standard 10-20 / 10-10 cap. |
| reference Cz | Online reference electrode, the minus input of every channel. Any 10-10 name, or M1 / M2 for a mastoid. |
| ground AFz | Ground electrode (drawn on the cap; it does not enter the measurement). |
| rate 250 Hz | Sampling rate, 100 to 2000 Hz. |
| highpass 0.1 Hz | off | Hardware high-pass (first order, causal). off records DC. |
| lowpass 70 Hz | off | Hardware anti-alias low-pass (fourth-order Butterworth). Default 0.4 × rate. |
| bits 16 range 3.2 mV | Digitizer resolution and input range (±). Step = 2 × range / 2bits. |
| impedance 5 kOhm | Typical electrode impedance; each electrode varies around it. |
| mains 60 Hz | Line frequency, 50 or 60 Hz. |
| cmrr 100 dB input 100 MOhm | Amplifier common-mode rejection and input impedance. |
| background 8 uV | off | RMS of ongoing background EEG (random 1/f cortical dipoles). |
| seed 1 | Random seed. The same program and seed always produce the same recording. |
| head { ... } | |
| brain 0.33 S/m csf 1.79 S/m skull 0.0083 S/m scalp 0.33 S/m | Shell conductivities. homogeneous replaces the shells with one sphere of brain. |
| source dipole | pair | alpha | erp | spike name { ... } | |
| at Pz depth 3 cm | Place a dipole 3 cm under the scalp beneath an electrode. Or pos x y z cm (x right, y forward, z up). |
| orient radial | tangential | inward | 40 deg | Tilt from pointing straight out. Add toward C4 or dir 90 deg for the direction of the tangential part. |
| amp 20 nAm | Dipole moment. |
| signal sine | burst | pink 10 Hz | dipole: a steady sinusoid, a waxing and waning rhythm, or 1/f noise. |
| dipole A { at C3 ... } rhythm 20 Hz coupling 0.6 lag 15 ms | pair: two dipoles sharing a fraction of a common rhythm, the second lagging the first. |
| freq 10 Hz closed 100% open 20% erd 50% | alpha: bilateral occipital generators; amplitude with eyes closed and open, and the event-related desynchronization after each stimulus. |
| latency 300 ms width 100 ms peak 170 ms 40 ms -1 jitter 40 ms | erp: Gaussian peaks (width is full width at half maximum) after each stimulus, with trial-to-trial latency jitter. |
| condition target 1 | erp: gain for each condition; conditions not listed get no response. |
| rate 0.2 Hz width 70 ms wave 50% | spike: interictal spikes at random times, with an aftergoing slow wave. |
| timeline { ... } | |
| block closed | open 20 s | A rest block with the eyes closed or open. |
| trials 120 isi 1 s jitter 0.3 s { condition a 80% ... } | A run of stimuli, one every isi plus a random 0 to jitter, in random, alternate or sequence order. |
| artifacts { ... } | |
| blinks 0.2 Hz 150 uV | Eye blinks (eyes open only). |
| saccades 0.15 Hz 40 uV | Horizontal eye movements. |
| muscle 0.05 Hz 25 uV | Bursts of temporalis, frontalis or neck muscle activity. |
| cardiac 70 bpm 6 uV | ECG picked up from the heart's distant field. |
| line 50 mV | Common-mode mains voltage on the body. |
| drift 25 uV pops 0.02 Hz 200 uV | Slow electrode drift, and sudden electrode pops. |
| bad T8 80 kOhm | One electrode with a high impedance. |
| … off | Declare an artifact but start with it switched off. Every artifact can be toggled on the Recording tab. |
| analysis { ... } | |
| reference average | Starting re-reference: online, mastoids, average, Cz, bipolar, transverse, laplacian. |
| highpass 0.3 Hz lowpass 30 Hz notch 60 Hz order 4 phase zero | causal | Starting offline filters. |
| epoch -200 800 ms baseline -200 0 ms reject 100 uV ica 20 | Starting epoch window, baseline, rejection threshold and number of ICA components. |
The head is a conductor, so a dipole anywhere in the brain changes the potential everywhere on the scalp. What an electrode records is a weighted sum of all the sources, each weighted by how well it projects to that spot. The weights depend on the source's position, depth and orientation and on the conductivities of the tissues in between, and they form the mixing matrix, one column per source, one row per electrode. Closer is not the whole story: a tangential dipole directly under an electrode can leave it nearly silent while the electrodes on either side see opposite polarities. Move the sources here and watch the maps, the mixing matrix and the recording change together.
Direction of tilt is measured in the plane of the scalp above the source: 0° toward the nose, 90° toward the right ear.
The map is the source's column of the mixing matrix: the potential it would produce at each scalp point, per 10 nAm of moment. A radial source makes one pole over itself; a tangential source makes a positive and a negative pole on either side, with the zero line right above it.
The top trace is what the electrode records, with the current re-reference and no filtering. Below it, each signal's share, all on the same scale. They add up exactly to the top trace. Change the electrode and the same sources appear with different weights.
Each column is one generator's scalp pattern, scaled to its largest value, after the current re-reference. Hover for values. This is the matrix A in x = A s. ICA tries to recover it from the recording alone.
Traces are stacked from front to back and left to right, each with its own baseline. The montage, the choice of what each trace is measured against, changes how the same data look, and so does filtering, so the view can show the data either exactly as recorded (against the online reference, through the hardware filters only) or after the current processing. Switch the signals on and off on the right to learn each one's signature: where on the head it appears, how big, how fast and how often. Click in the traces to put a cursor there and see the scalp map at that instant.
A power spectrum asks how much of the signal's variance sits at each frequency. Background EEG falls off roughly as 1/f; rhythms stand out as peaks above it, alpha near 10 Hz over the back of the head with the eyes closed; line noise is a needle at 50 or 60 Hz; muscle lifts everything above 20 Hz. A spectrum averages over time, so a time-frequency map is used to see when power changes: alpha appearing as the eyes close, or dropping after a stimulus (event-related desynchronization). Coherence asks whether two channels share a rhythm with a consistent phase, and here volume conduction sets a trap: one source seen by two electrodes is perfectly coherent with itself.
Processed data. Power is integrated over the band from each channel's spectrum and interpolated between electrodes.
Seed map: coherence between channel A and every other channel at the frequency marked on the left. Click the spectrum to choose the frequency.
Magnitude-squared coherence counts any consistent phase relation, including the zero-lag one that volume conduction produces when a single source reaches both electrodes. The imaginary part of coherency keeps only the out-of-phase part, which a single source cannot produce instantaneously, at the cost of also missing true zero-lag coupling. Try the Two dipoles example with coupling 0, then with coupling 0.7 and a 15 ms lag.
Every processing step is a choice with a cost. Re-referencing never adds information, it changes which question each channel answers. Filters remove what you do not want and distort what you do, more so the steeper and closer to the signal they are, and a filter that does not shift latencies must look into the future. ICA can separate artifacts from brain activity only to the extent that they have different, fixed scalp patterns and independent time courses. The pipeline below runs in order; the Recording, Spectra and Averaging tabs all show its output.
The same instant, as recorded, under each reference. All maps share one colour scale except the Laplacian, which is in different units. Choosing a reference moves the zero; it does not change the differences between electrodes, except for the Laplacian, which is reference-free and sharpens local sources at the expense of deep and broad ones.
ICA assumes the recording is x = A s: a fixed mixture of signals that are statistically independent. It finds an unmixing matrix that makes the recovered signals as non-Gaussian as possible, then shows each component's scalp pattern (a column of A) and its time course. Mark components to remove and their back-projection is subtracted from the data. Here you can check each decision against the truth.
ICA has not been run on this recording.
Select a component to see its time course and spectrum.
An event-related potential is a few microvolts buried in tens of microvolts of everything else. If the response is the same on every trial and the rest is not time-locked to the stimulus, averaging N trials leaves the response untouched and shrinks the rest by a factor of √N. Signal-to-noise ratio grows as √N, so doubling it costs four times the trials. The assumptions are the catch: if the latency varies from trial to trial the average is smeared, smaller and wider than any single response; if artifacts are time-locked or huge they survive. Epochs are cut around each event, baseline corrected, screened for artifacts, and then averaged.
Noise is the RMS of the average in the baseline window (what you can measure) and the RMS of the average minus the true ERP over the whole epoch (what only a simulation can measure). Signal is the true ERP's largest absolute value after the baseline. On a log-log plot √N is a straight line of slope one half.
One row per epoch of the selected channel, colour for voltage. Rejected epochs are marked on the left. Sorting by the true latency jitter, which the simulator knows and an experimenter does not, shows how the average blurs a response that wanders in time.
The forward problem, from a known source to the scalp map, has exactly one answer, and physics supplies it. The inverse problem, from a scalp map back to the source, has infinitely many: Helmholtz showed in 1853 that infinitely many current distributions inside a conductor produce the same outside potentials. Every inverse method adds assumptions to pick one. The simplest assumes a single dipole and finds the one whose map best fits the data. Even then the answer is only as good as the data and the head model: noise, few electrodes, a deep source, a wrong skull conductivity or a second source all move it, sometimes by centimetres, and the fit can still look excellent.
Error landscape: the fraction of the data the best dipole at each grid position leaves unexplained, on the horizontal slice through the true source; the strongest colour marks the best fits. A small, sharp spot means a well-determined answer; a long shallow valley means many positions fit almost equally well.
The tabs follow the life of a recording. Start with the Signal chain to see where the voltage comes from. Use the Experiment tab to choose or write a session; everything else is computed from it. The Sources and Recording tabs show what the electrodes pick up and why; Spectra, Processing and ERP averaging are the analysis; Localization runs the problem backwards. The concept boxes at the top of each tab open and close, so a projected screen can stay uncluttered.
Built for NBL 425/625, Methods in Human Neuroimaging. See also the course's forward model, inverse solution and EEG versus MEG demos.