The math track
Linear algebra, then signals and systems, then probability and Bayesian estimation, then control, then enough electromagnetism to reason about dipoles in conductors. In that order, each attached to the phase that needs it.
On this pageAlongside the phases
The math this field uses is not exotic, but it has to be there when the phase needs it. Linear algebra is everything (every montageMontage The particular arrangement of which electrodes are subtracted from which, such as referential, bipolar, or average reference. Related: Reference electrodeReference electrode The electrode every other channel is measured against; there is no neutral spot on the head, so the choice shapes every trace. , Common average referenceCommon average reference Re-referencing every channel to the mean of all channels, which approximates a neutral reference when electrodes cover the head well. , Surface LaplacianSurface Laplacian Subtracting the average of neighbouring electrodes from each electrode, which sharpens spatial detail and suppresses distant sources. . Glossary entry, filterFilter An operation that passes some frequencies and attenuates others; every filter also delays or distorts the timing of what it passes. Related: High-pass filterHigh-pass filter Removes slow drifts and DC offsets, passing everything above a cutoff; set it too high and you erase slow brain activity. , Low-pass filterLow-pass filter Removes fast content above a cutoff; the anti-alias filter is one, and so is the smoothing you apply to a noisy trace. , Notch filterNotch filter A very narrow filter that removes one frequency, usually 60 Hz mains hum; it also rings and distorts nearby content, so fix the hum at the source first. , Phase distortionPhase distortion Different frequencies being delayed by different amounts, which smears and shifts waveforms such as an ERP peak. . Glossary entry, classifierClassifier An algorithm that assigns each trial a label, such as left hand or right hand, after being trained on labelled examples. Related: Linear discriminant analysis (LDA)Linear discriminant analysis (LDA) A simple, robust classifier that draws a straight boundary between classes; the workhorse of EEG decoding for two decades. , Support vector machine (SVM)Support vector machine (SVM) A classifier that finds the boundary with the widest margin between classes; strong on small datasets. , Cross-validationCross-validation Testing a model on data it never saw during training, repeatedly, so the reported accuracy means something. . Glossary entry, and decoderDecoder The algorithm that maps neural signals to intended actions, such as a classifier or a Kalman filter. Related: ClassifierClassifier An algorithm that assigns each trial a label, such as left hand or right hand, after being trained on labelled examples. , Kalman filterKalman filter An estimator that blends a prediction from a motion model with a noisy measurement, weighting each by how much it trusts it; the decoder behind most intracortical cursor control. , Brain-computer interface (BCI)Brain-computer interface (BCI) A system that turns measured brain activity into control of something outside the body, from a cursor to a wheelchair to a speech synthesizer. . Glossary entry is a matrix). Signals and systems is Phase 2. Probability and Bayesian estimationBayesian estimation Updating a belief about a hidden quantity by combining what you expected with what you measured, in proportion to their reliabilities. Related: Kalman filterKalman filter An estimator that blends a prediction from a motion model with a noisy measurement, weighting each by how much it trusts it; the decoder behind most intracortical cursor control. . Glossary entry is Phase 3. Control theory is the driven-right-leg loop and every closed-loop device. Electromagnetism is Phase 4’s head model. Here is the order, what each is for, and where to learn it fast.
Linear algebra, first and most
Vectors as signals; matrices as transformations; the dot product as correlation; projection as filtering; eigenvectors and the singular value decomposition as the axes along which data vary. Covariance matrices, which are where Phase 3’s classifiersClassifier An algorithm that assigns each trial a label, such as left hand or right hand, after being trained on labelled examples. Related: Linear discriminant analysis (LDA)Linear discriminant analysis (LDA) A simple, robust classifier that draws a straight boundary between classes; the workhorse of EEG decoding for two decades. , Support vector machine (SVM)Support vector machine (SVM) A classifier that finds the boundary with the widest margin between classes; strong on small datasets. , Cross-validationCross-validation Testing a model on data it never saw during training, repeatedly, so the reported accuracy means something. . Glossary entry live. The pseudoinverse, which is the minimum-norm solution of Phase 4.
A decoderDecoder The algorithm that maps neural signals to intended actions, such as a classifier or a Kalman filter. Related: ClassifierClassifier An algorithm that assigns each trial a label, such as left hand or right hand, after being trained on labelled examples. , Kalman filterKalman filter An estimator that blends a prediction from a motion model with a noisy measurement, weighting each by how much it trusts it; the decoder behind most intracortical cursor control. , Brain-computer interface (BCI)Brain-computer interface (BCI) A system that turns measured brain activity into control of something outside the body, from a cursor to a wheelchair to a speech synthesizer. . Glossary entry output is usually a dot product of weights and data:
Here is one number out, holds the weights, and holds the measurements.
Learn it from Gilbert Strang’s MIT lectures (free, and the textbook is good) or from 3Blue1Brown’s Essence of Linear Algebra for the geometric intuition first. Take the university’s course as early as the prerequisites allow. Every week of this site after Phase 2 uses it.
Signals and systems, with Phase 2
Convolution, the Fourier transform, sampling, the Laplace and z transforms, filtersFilter An operation that passes some frequencies and attenuates others; every filter also delays or distorts the timing of what it passes. Related: High-pass filterHigh-pass filter Removes slow drifts and DC offsets, passing everything above a cutoff; set it too high and you erase slow brain activity. , Low-pass filterLow-pass filter Removes fast content above a cutoff; the anti-alias filter is one, and so is the smoothing you apply to a noisy trace. , Notch filterNotch filter A very narrow filter that removes one frequency, usually 60 Hz mains hum; it also rings and distorts nearby content, so fix the hum at the source first. , Phase distortionPhase distortion Different frequencies being delayed by different amounts, which smears and shifts waveforms such as an ERP peak. . Glossary entry as systems, frequency response. Oppenheim’s Signals and Systems is the standard text; the MIT OpenCourseWare lectures are free. Everything in the filters and conversion explainers is this course applied. Take it the semester you build the ADS1299ADS1299 Texas Instruments' 8-channel, 24-bit biopotential front-end chip used in OpenBCI and many research amplifiers. Related: Delta-sigma ADCDelta-sigma ADC A converter that samples very fast with a crude 1-bit decision and averages, achieving 24-bit resolution at modest rates; what the ADS1299 uses. , OpenBCIOpenBCI The open-source EEG hardware company whose Cyton (ADS1299) and Ganglion boards are the default hobby and research-lite amplifiers. . Glossary entry board and the two will teach each other.
Convolution says each output sample is a sum of scaled echoes of the input through the filterFilter An operation that passes some frequencies and attenuates others; every filter also delays or distorts the timing of what it passes. Related: High-pass filterHigh-pass filter Removes slow drifts and DC offsets, passing everything above a cutoff; set it too high and you erase slow brain activity. , Low-pass filterLow-pass filter Removes fast content above a cutoff; the anti-alias filter is one, and so is the smoothing you apply to a noisy trace. , Notch filterNotch filter A very narrow filter that removes one frequency, usually 60 Hz mains hum; it also rings and distorts nearby content, so fix the hum at the source first. , Phase distortionPhase distortion Different frequencies being delayed by different amounts, which smears and shifts waveforms such as an ERP peak. . Glossary entry:
Here is the signal, is the filterFilter An operation that passes some frequencies and attenuates others; every filter also delays or distorts the timing of what it passes. Related: High-pass filterHigh-pass filter Removes slow drifts and DC offsets, passing everything above a cutoff; set it too high and you erase slow brain activity. , Low-pass filterLow-pass filter Removes fast content above a cutoff; the anti-alias filter is one, and so is the smoothing you apply to a noisy trace. , Notch filterNotch filter A very narrow filter that removes one frequency, usually 60 Hz mains hum; it also rings and distorts nearby content, so fix the hum at the source first. , Phase distortionPhase distortion Different frequencies being delayed by different amounts, which smears and shifts waveforms such as an ERP peak. . Glossary entry’s impulse response, and and count samples.
Probability and estimation, with Phase 3
Random variables, distributions, expectation and variance, Bayes’ rule, maximum likelihood, the Gaussian and why it appears everywhere, the binomial (your chance bound), hypothesis tests and their limits, and linear regression as estimation. Then Bayesian estimationBayesian estimation Updating a belief about a hidden quantity by combining what you expected with what you measured, in proportion to their reliabilities. Related: Kalman filterKalman filter An estimator that blends a prediction from a motion model with a noisy measurement, weighting each by how much it trusts it; the decoder behind most intracortical cursor control. . Glossary entry as belief updating, which makes the Kalman filterKalman filter An estimator that blends a prediction from a motion model with a noisy measurement, weighting each by how much it trusts it; the decoder behind most intracortical cursor control. Related: DecoderDecoder The algorithm that maps neural signals to intended actions, such as a classifier or a Kalman filter. , Bayesian estimationBayesian estimation Updating a belief about a hidden quantity by combining what you expected with what you measured, in proportion to their reliabilities. . Glossary entry obvious. A university statistics course for engineers covers the first half; Kalman comes from a controls or estimation course or from reading the Phase 3 explainer’s equations with a linear algebra background.
Bayes’ rule turns a likelihood into a belief about the world:
Here is the thing estimated (a movement direction, a stimulus), is the measurement, is how likely the measurement is under each candidate, and is what was believed before.
Control, alongside
Feedback, stability, gainGain How many times an amplifier multiplies its input; 1000× turns 50 microvolts into 50 millivolts, enough for an ADC to see. Related: Instrumentation amplifierInstrumentation amplifier A precision differential amplifier with very high input impedance and high CMRR, built from three op-amps and sold as a single chip such as the INA128 or AD8232. . Glossary entry and phase margin. The driven-right-leg circuitDriven-right-leg circuit A third electrode fed with an inverted copy of the common-mode signal, so the body's hum is actively cancelled instead of merely rejected. Related: Common-mode signalCommon-mode signal A voltage that appears equally on both inputs of a differential amplifier, such as 60 Hz hum picked up by the whole body. , Ground electrodeGround electrode The electrode that ties the body to the amplifier's zero and, in a good design, is driven to cancel common-mode hum. . Glossary entry is a feedback loop that can oscillate; the Kalman filterKalman filter An estimator that blends a prediction from a motion model with a noisy measurement, weighting each by how much it trusts it; the decoder behind most intracortical cursor control. Related: DecoderDecoder The algorithm that maps neural signals to intended actions, such as a classifier or a Kalman filter. , Bayesian estimationBayesian estimation Updating a belief about a hidden quantity by combining what you expected with what you measured, in proportion to their reliabilities. . Glossary entry’s cousin is the controller; closed-loop stimulation is a control problem; and co-adaptive BCIsBrain-computer interface (BCI) A system that turns measured brain activity into control of something outside the body, from a cursor to a wheelchair to a speech synthesizer. Related: DecoderDecoder The algorithm that maps neural signals to intended actions, such as a classifier or a Kalman filter. , Closed loopClosed loop A system in which the output feeds back to influence the input, such as a user adjusting their brain activity while watching the cursor it controls. . Glossary entry are two controllers learning each other. One controls course, taken in the second or third year, reframes half of this site.
Closing a loop with forward gainGain How many times an amplifier multiplies its input; 1000× turns 50 microvolts into 50 millivolts, enough for an ADC to see. Related: Instrumentation amplifierInstrumentation amplifier A precision differential amplifier with very high input impedance and high CMRR, built from three op-amps and sold as a single chip such as the INA128 or AD8232. . Glossary entry and feedback gainGain How many times an amplifier multiplies its input; 1000× turns 50 microvolts into 50 millivolts, enough for an ADC to see. Related: Instrumentation amplifierInstrumentation amplifier A precision differential amplifier with very high input impedance and high CMRR, built from three op-amps and sold as a single chip such as the INA128 or AD8232. . Glossary entry gives the closed-loop map from command to output:
When the denominator goes small, small disturbances grow: that is instability, and the driven-right-leg loop is analyzed exactly this way.
Electromagnetism, for Phase 4
Enough to reason about a current dipoleCurrent dipole The simplest model of a patch of active cortex: a tiny current source and sink close together, with a strength and a direction. Related: Volume conductionVolume conduction The spreading of currents from a source through the conductive tissues of the head, which is why one source shows up on many electrodes and why scalp EEG is blurry. , Forward problemForward problem Given a source in the head, compute the voltages on the scalp; it has a unique answer. . Glossary entry in a conducting medium: Ohm’s law in its field form, the quasi-static approximation (why EEGElectroencephalography (EEG) Recording the brain's electrical activity from electrodes on the scalp, a few tens of microvolts of blurred, summed cortical activity. Related: Electrocorticography (ECoG)Electrocorticography (ECoG) Recording from electrodes placed on the surface of the brain under the skull, usually during epilepsy surgery evaluation; cleaner and sharper than EEG. , Magnetoencephalography (MEG)Magnetoencephalography (MEG) Recording the tiny magnetic fields produced by cortical currents with superconducting sensors in a shielded room; less blurred by the skull than EEG, and far more expensive. , Volume conductionVolume conduction The spreading of currents from a source through the conductive tissues of the head, which is why one source shows up on many electrodes and why scalp EEG is blurry. , Microvolt (µV)Microvolt (µV) One millionth of a volt. Scalp EEG is tens of microvolts; a AA battery is 1.5 million of them. . Glossary entry has no wave propagation), Poisson’s equation for the potential, boundary conditions at interfaces of different conductivity. The physics department’s second electromagnetism course has it; Nunez and Srinivasan’s Electric Fields of the Brain applies it. This is also the background for understanding why MEGMagnetoencephalography (MEG) Recording the tiny magnetic fields produced by cortical currents with superconducting sensors in a shielded room; less blurred by the skull than EEG, and far more expensive. Related: Electroencephalography (EEG)Electroencephalography (EEG) Recording the brain's electrical activity from electrodes on the scalp, a few tens of microvolts of blurred, summed cortical activity. . Glossary entry sees what EEGElectroencephalography (EEG) Recording the brain's electrical activity from electrodes on the scalp, a few tens of microvolts of blurred, summed cortical activity. Related: Electrocorticography (ECoG)Electrocorticography (ECoG) Recording from electrodes placed on the surface of the brain under the skull, usually during epilepsy surgery evaluation; cleaner and sharper than EEG. , Magnetoencephalography (MEG)Magnetoencephalography (MEG) Recording the tiny magnetic fields produced by cortical currents with superconducting sensors in a shielded room; less blurred by the skull than EEG, and far more expensive. , Volume conductionVolume conduction The spreading of currents from a source through the conductive tissues of the head, which is why one source shows up on many electrodes and why scalp EEG is blurry. , Microvolt (µV)Microvolt (µV) One millionth of a volt. Scalp EEG is tens of microvolts; a AA battery is 1.5 million of them. . Glossary entry cannot.
The potential in the head obeys Poisson’s equation for a conductive medium:
Here is the electric potential, is the conductivity (different in brain, skull, and scalp), and is the source current density from neural activity.
Differential equations, throughout
Hodgkin–HuxleyHodgkin–Huxley model The 1952 set of four differential equations for the squid axon that reproduces the action potential from voltage-dependent sodium and potassium channels. Related: Action potentialAction potential The brief, all-or-nothing voltage spike a neuron fires, about a millisecond long and about 100 millivolts tall across its membrane. , Leaky integrate-and-fire neuronLeaky integrate-and-fire neuron The simplest useful neuron model: a leaky capacitor that fires and resets when it reaches a threshold. . Glossary entry, the cable equation, the leaky integrator, the Kalman prediction step: all differential equations, mostly first and second order, some nonlinear. The engineering differential equations course plus the habit of integrating things numerically in Python (which Phase 4 forces) is enough.
The leaky integrator of Phase 4 fits on one line:
Here is the membrane voltage, is the membrane time constant, is the resting voltage, and is the input current times the membrane resistance.
Numerical methods, as needed
Forward Euler and when it fails (stiff systems, big steps), Runge-Kutta, linear solvers and conditioning, optimization as gradient descent. Picked up in the projects; a numerical methods course makes it systematic.