A neural spike is about 100 microvolts, riding on millivolts of mains hum and a drifting electrode offset. Five parts lift it out. Each one can also destroy it.
Follow one spike from the electrode to the number the decoder reads: the amplifier, the reference, the filter, the sampler and the converter.
Switch on the reference electrode and the high-pass filter, then drag the gain and the bits. Watch the spike appear, clip, or melt into steps. Then we build, piece by piece, every stage in that chain.
You need a feel for voltage (the push that drives a current) and a little algebra. We build the rest from zero.
Built from two primary sources, the Texas Instruments ADS1299 datasheet (SBAS499C) and the Intan RHD2000 datasheet (December 2023), with the physics from Nyquist, Johnson, Shannon and Bennett (full list in the Field Guide). The open course Neuromatch Computational Neuroscience covers the signal processing around it. Part of the series on brain-computer interfaces; it follows Recording Hardware.
Illustrative scene: three spikes (100, 100 and 60 microvolts) over a 40 ms window, 2 mV of 50 Hz hum, a 100 mV electrode offset with 20 mV of slow drift, 2.4 microvolts rms of amplifier noise (the Intan RHD2000 typical figure) plus the thermal noise of a 100 kilohm electrode over 7.5 kHz. The reference leaves 0.3% of the hum (about 50 dB of rejection, a toy value). The converter spans plus and minus 1 V after the gain.
Chapter 0
See why the number a decoder reads is the survivor of five hazards, and meet the voltage scales involved
Stand at the back of a stadium and try to hear one person whisper in the front row. The crowd roars. The loudspeakers hum. Someone keeps bumping the microphone. A neural recording is that job, done with wires and silicon.
The whisper is a spike, the brief electrical blip a nerve cell makes when it fires. A thin metal electrode near the cell sees the blip as a change of voltage (the push that drives a current, measured in volts). The change is about 100 microvolts (µV), and lasts about one millisecond. A microvolt is one millionth of a volt. A AA battery, at 1.5 V, is 15,000 times bigger. We use 100 µV as a round example in this lesson. Real spikes range from tens to a few hundred microvolts, depending on how close the electrode sits.
The roar is everything else the electrode feels. Your body and the room act as an antenna for the 50 or 60 Hz mains power: that adds a hum of a millivolt or more. The metal and the salty tissue form a tiny battery, and that adds a slow offset of tens or hundreds of millivolts. The resistance of the electrode and the first transistor add hiss of their own.
The signal then has to become a stream of numbers a computer can read. That trip is the job of the analog front end (AFE): the circuit that handles the voltage while it is still a smooth, continuous quantity (analog) and turns it into numbers (digital). It has five stages, and each stage has a way to ruin the spike.
Chapters 7 and 8 then put real chip numbers into the chain and let you set every stage at once. The hero at the top of this page already does a small version of that. Gain, bits, a reference and a filter are all on it, and you may have seen the spike vanish in two different ways.
The same front end design serves three kinds of recording. Spikes come from microelectrodes pushed into the brain: fast, a millisecond long, the 100 µV example above. The local field potential (LFP) is the slow swell that the same wire sees when thousands of nearby cells act together. EEG is the faint, slow rhythm that electrodes on the scalp pick up through the skull. Each one needs a different filter, a different sampling rate and a different noise floor. The recording map and recording hardware lessons show where each electrode sits. This lesson follows what happens to the voltage afterwards.
Why not just amplify everything and convert it? Because the signals live on wildly different scales. The ruler below puts them on one logarithmic axis, where each gridline is ten times bigger than the one before. Equal steps along the axis mean equal ratios, not equal differences. That is the only way a 0.2 µV step and a 0.4 V offset fit on one page.
The datasheet numbers come from the Intan RHD2000 chip, which converts with 16 bits. Its converter step, the smallest change it can tell apart, is 0.195 µV. Sixteen bits give 65,536 steps. Multiply, and the whole window the converter can see is about 12.8 mV wide, from about −6.4 mV to +6.4 mV. Now drag the electrode offset up and see where it lands.
Each bar reaches from the left edge to that voltage on a log axis. Drag the electrode offset and compare its bar with the spike and with the blue converter window.
From the Intan RHD2000 datasheet: step (LSB) 0.195 µV, typical input noise 2.4 µV rms, AC input range ±5.0 mV, allowed DC offset ±0.4 V. The 100 µV spike and the 2 mV of mains pickup are illustrative round numbers. The converter window is 65,536 steps × 0.195 µV = 12.8 mV, so ±6.39 mV.
At the default of 150 mV, the offset is 1,500 times a 100 µV spike. It is also 23 times the window's half width of 6.4 mV. Amplify that offset by any gain, and the converter sees only the offset. So the front end must remove the offset before the converter, and keep only the fast wiggle. Chapter 1 shows how.
Here is the arithmetic that drives the whole design. To cover a ±150 mV range with 0.195 µV steps, a converter would need 2 × 0.150 V ÷ 0.195 µV ≈ 1.54 million levels, which is 21 bits. Sixteen bits cannot do it. A designer has two options: pay for more bits (the EEG chip in Chapter 7 uses 24), or throw the offset away first (the spike chip does that). Both are good answers. Neither is free.
Here is where each part of the hero is explained:
Chapter 1
Learn why an amplifier must barely touch the electrode, and how it throws away the offset and keeps the wiggle
You want to know how full a thin test tube is. You dip in a big bucket to scoop a sample. The bucket drains the tube, and the level you measure is not the level you started with. Measuring a voltage has the same trap. A meter that draws current changes the thing it measures.
An electrode is a very weak source. It can deliver almost no current without its voltage sagging. So the first rule of the amplifier is simple: it must draw almost no current from the electrode. The measure of that is input impedance, the opposition the amplifier presents to the signal. Impedance is resistance that may change with frequency. It is measured in ohms (Ω); a kilohm (kΩ) is a thousand ohms and a megohm (MΩ) is a million.
The electrode has its own impedance, which we call Ze. The amplifier input has impedance Zin. Together they form a voltage divider: two impedances in a row, which share the source voltage in proportion to their sizes. The amplifier sees only the fraction that lands across Zin.
The catch is that Zin is not a fixed number. The first transistor has a tiny capacitance to ground. A capacitor is two plates close together; it lets fast changes through and blocks slow ones. Its impedance is 1 / (2π f C), which falls as the frequency f rises. The Intan RHD2000 datasheet lists Cin = 12 pF (picofarads) and gives Zin as 1,300 MΩ at 10 Hz and 13 MΩ at 1 kHz.
Check it. At 1 kHz: 1 / (2π × 1,000 × 12 × 10−12) = 13.3 MΩ. At 10 Hz it is 1.33 GΩ. The formula reproduces both datasheet rows, so the model is right.
Now put a 1 MΩ electrode in front. At 1 kHz the divider keeps 99.7% of the signal. At 10 kHz, Zin has dropped to 1.33 MΩ, and the amplifier keeps only about 80% (a loss of 2.0 dB). With a 10 MΩ electrode at 10 kHz it keeps about 13%. High impedance electrodes erase high frequencies first, and spikes live at high frequencies.
The curve shows what fraction of the electrode voltage the amplifier keeps at each frequency. Raise the electrode impedance or add wiring capacitance and watch the high end sag. Then switch on the band-pass.
The input capacitance of 12 pF is the Intan RHD2000 datasheet value; the electrode is treated as a plain resistor, and the extra wire capacitance is an illustrative knob. The band-pass uses the chip's shapes: a first-order high-pass at the lower cutoff and a third-order Butterworth low-pass at the upper cutoff.
Wires make it worse. Every centimetre of wire adds its own capacitance, in parallel with the amplifier's. That is why spike recorders put the first amplifier on a small headstage next to the electrode, and run only the amplified, digital signal down the long cable.
The electrode also carries a slow DC offset, the near-constant voltage from the electrode and tissue acting as a tiny battery. Chapter 0 showed it can be 100 mV or more. The amplifier keeps the fast wiggle and drops the slow offset with a high-pass filter: a filter that passes fast changes and blocks slow ones. The offset is slow, so it blocks it.
The RHD2000 builds this into the amplifier. Its datasheet gives the DC gain A0 as 0 V/V, which it calls complete DC rejection. The lower cutoff fL is a first-order filter that you can set from 0.1 Hz up to 500 Hz with on-chip registers. A first-order high-pass lets through a fraction (f / fL) / √(1 + (f / fL)²) of a signal at frequency f. With fL = 300 Hz, a 1 Hz drift keeps 0.3%. A 3 kHz spike component keeps 99.5%.
After the filter comes the gain. The RHD2000 amplifies by 192 (45.7 dB) in the midband. That is exactly why its converter step, which is 37.4 µV at the converter input, reads as 37.4 µV ÷ 192 = 0.195 µV when referred back to the electrode. Engineers quote noise and steps input-referred: divided by the gain, so they compare directly with the signal.
The RHD2132 takes 32 electrode voltages in. Each goes through its own amplifier. A fast multiplexer (a switch that visits each channel in turn) feeds all 32 into one 16-bit converter. The converter runs at up to 1.05 million samples per second, so each channel is read up to 30,000 times a second. What leaves the chip is a stream of 16-bit integers: shape [time, 32], one number per channel per tick. Every later lesson in this series starts from that array.
When an electrode goes bad, the failure shows as a symptom. Spikes on one channel look smaller and rounder than on its neighbours. The measurement is the electrode's impedance at 1 kHz, which the RHD2000 can test in place with a built-in impedance meter at programmable frequencies. The fix is a lower-impedance electrode, a shorter wire to the amplifier, or a headstage nearer the tissue.
Chapter 2
Compute the hiss that a resistor and an amplifier add, and see how bandwidth and electrode size set it
Turn a radio between stations and you hear a hiss. Nobody is broadcasting it. The hiss is the sound of electrons in the radio's own parts, jiggling because they are warm. Your recording chain has the same hiss, and it decides the smallest spike you can ever see.
Heat makes the charge carriers in any resistor move at random. At any instant, a few more sit at one end than the other. That makes a tiny, random voltage across the resistor, with no signal applied at all. This is thermal noise (also called Johnson noise or Johnson-Nyquist noise, after the two Bell Labs engineers who measured it and explained it in 1928). Its size has a clean formula.
Work it for a microelectrode of 1 MΩ, read through a 10 kHz window. First 4 k T = 4 × 1.38 × 10−23 × 300 = 1.66 × 10−20. Multiply by R: 1.66 × 10−14. Multiply by Δf: 1.66 × 10−10. The square root is 1.29 × 10−5 V, so 12.9 µV rms.
That is already a tenth of a 100 µV spike, from a resistor doing nothing. Two knobs move it. The noise grows with the square root of R, and with the square root of Δf. Quarter the bandwidth and the noise halves. Hold the electrode at 100 kΩ instead of 1 MΩ and it drops by a factor of 3.2.
The amplifier adds noise of its own. The Intan RHD2000 datasheet gives 2.4 µV rms, typical, and says it varies by less than 15% with the amplifier bandwidth. How do the two combine?
The two wiggles are independent. Sometimes they push the same way and sometimes opposite, so they do not add like lengths on a ruler. Their powers (the squares) add instead. The total is the square root of the sum of squares: √(12.9² + 2.4²) = √(166.4 + 5.8) = 13.1 µV rms. The big source swamps the small one. A better amplifier would barely help here. A better electrode would help a lot.
Now the 100 µV spike against 13.1 µV rms of noise: a ratio of 7.6, or 17.6 dB. That is a usable spike, but not a comfortable one. Move the sliders to see how fast it changes.
Pick a recording, or set the electrode impedance and the bandwidth yourself. The bars are on a log axis. Find which bar sets the total.
Thermal noise is computed live from the formula at 300 K, treating the electrode as a flat resistor (a real electrode is not, so read it as an estimate). The spike preset uses the Intan RHD2000 typical amplifier noise, 2.4 µV rms, and a 100 µV spike (illustrative). The EEG preset uses the ADS1299 figure for 250 samples per second at gain 24, 0.14 µV rms over a 65 Hz bandwidth, and a 20 µV rhythm (illustrative).
Flip to scalp EEG. A scalp electrode with paste is a few kilohms. Over a 65 Hz window its thermal noise is about 0.07 µV rms. That is smaller than the ADS1299's own 0.14 µV. So here the amplifier sets the floor, and the electrode barely matters. Two recordings, two different weakest links. This is why an engineer starts every design by asking which source is biggest.
Noise appears at many points in a chain: the electrode, the amplifier, the converter. To compare them with the signal, engineers divide each by the gain in front of it. This is input-referred noise: the noise expressed as if all of it entered at the electrode. A converter step of 37.4 µV behind a gain of 192 is 0.195 µV at the input. A big gain early in the chain therefore makes every later noise source small.
The datasheets state noise in two ways. Rms is the typical size. Peak-to-peak (pp) is the width of the fuzz you see on a screen. The ADS1299 datasheet says that, at lower data rates, peak-to-peak is about 6.6 times rms. For its 250 samples per second, gain 24 setting it lists 0.14 µV rms and 0.98 µV pp: a ratio of 7. Always check which one a quoted number is.
When the baseline of a recording looks fuzzy, here is the failure as a procedure. The symptom is a thick fuzz line. To measure, short the inputs together and record: the fuzz that remains is the amplifier's own noise, which is exactly how the ADS1299 datasheet measures it. Then connect the electrode and record again; the extra fuzz is the electrode's. To fix: lower the impedance (a larger or better-plated electrode), narrow the bandwidth to what the signal needs, or average many repeats.
Chapter 3
Compare monopolar, bipolar and common average montages, and see what each one removes and what each one leaks
How tall is a mountain? The question is incomplete until you say: tall above what? Sea level is the usual answer, and everyone agrees on it. A voltage has the same problem. A voltage is always a difference between two points. The point you measure against is the reference, the sea level of your recording.
Choosing it is not a detail. Your body and the wires act as an antenna for the 50 or 60 Hz mains in the walls. That makes the whole body swing up and down together, by hundreds of microvolts or more. A swing that every electrode shares is called common-mode interference. The brain signal is the part that differs from electrode to electrode, called the differential part. A good reference throws away the first and keeps the second.
The tool is the differential amplifier. It has two inputs and amplifies only the difference between them. Feed it the same hum on both and, ideally, nothing comes out. Its skill is the common-mode rejection ratio (CMRR): how many times smaller the common-mode signal comes out than a differential one of the same size. It is quoted in decibels, where 20 dB means a factor of ten.
The datasheets give the numbers. The Intan RHD2000 amplifier has a typical CMRR of 82 dB at 50 or 60 Hz, which is a factor of 1082/20 ≈ 12,600. The ADS1299 specifies −110 dB (the minimum over its channels, with −120 dB typical), a factor of about 316,000 or better. Work one: 2 mV of hum through the RHD2000 leaves 2 mV ÷ 12,600 = 0.16 µV. That is far below the amplifier's own 2.4 µV noise. On paper, hum is solved.
In practice it is not, and the datasheet says why. The rejection only works if the two inputs see the hum equally. Each electrode has its own impedance, and each forms its own divider with the amplifier input (Chapter 1). If the electrodes differ by 1%, then 1% of the hum arrives as differential signal. The Intan datasheet notes that its 16 and 32 channel chips differ in just this respect. The RHD2216 has balanced inputs and gives the best rejection when all electrodes have about the same impedance, as with surface recording. The RHD2132 shares one reference input among all channels, and suits cases where the reference impedance is very different from the recording electrodes, or where hum is mild, as with implanted devices.
With many electrodes you can build the reference in three ways. Each gives a different montage, the pattern of what is subtracted from what.
Each has a failure. Try them on eight channels. Two have a real spike, all share the hum, and a slow 10 Hz wave sits on every channel. Use the buttons to add the failures.
Choose how the eight channels are referenced. Then switch on the active reference or the blink, and raise the electrode mismatch to see what leaks.
Toy scene: 300 µV of 50 Hz hum common to every electrode, a 10 Hz wave of 20 µV on all eight channels (a broad field that the distant reference does not see), 100 µV spikes on channels 3 and 6 at 15 ms and 40 ms, and a 400 µV blink on channel 6. Each electrode keeps a random fraction of the hum, within the mismatch you set. Traces are clipped to their lane. Real CMRR comes from the datasheets: 82 dB for the RHD2000, −110 dB for the ADS1299.
Look at none first: the hum is larger than the lane, so every trace is clipped. Switch to monopolar and the hum all but vanishes, down to the mismatch. Now turn on Reference picks up a spike. A copy of the channel 3 spike, upside down, appears on every other channel. The reference is not silent, so its activity is subtracted from everyone. This ghost spike is the classic monopolar failure.
Switch to bipolar. Neighbouring electrodes share the hum and the 10 Hz wave, so both vanish. That is a gain for hum and a loss for the wave, a real brain signal. Bipolar suits sharp, local signals. It hides broad ones.
Switch to common average. The ghost goes away, and the broad wave too. Now turn on the blink. A 400 µV blink on channel 6 shows up as −50 µV on all the others, since it is one eighth of the average. With 64 channels the leak would shrink to −6 µV. CAR works best with many channels and no single wild one.
The ADS1299 adds a second tool. Its datasheet describes a patient bias drive: it takes the average of any set of electrodes and feeds a signal back into the body. This holds the body's common voltage steady, so the hum starts out smaller before the amplifier sees it. The older name for the idea is the driven right leg circuit.
Chapter 4
Watch a fast tone fold into a slow one, then stop it with a filter placed before the sampler
In old films a speeding wagon wheel sometimes seems to spin slowly backwards. The wheel is not slowing down. The camera takes 24 pictures a second, and the wheel has turned almost a full circle between two pictures. Each picture shows the spokes just short of where they started, so the eye sees a slow backward drift.
Your converter is that camera. It does not watch the voltage all the time. It takes a snapshot every 1 / fs seconds, where fs is the sampling rate, in samples per second (S/s, or Hz). Between snapshots it knows nothing. For a slow voltage that does not matter. For a fast one, it matters a great deal.
Take a pure tone of frequency f. Sample it at fs. If f is below half the sampling rate, the snapshots give a faithful picture of it. That half-rate, fs / 2, is the Nyquist frequency, after the engineer Harry Nyquist, who studied the limits of telegraph signalling in 1928. Claude Shannon proved the formal sampling theorem in 1949: a signal with no content above a frequency B is completely determined by samples taken at more than 2B per second.
If f is above fs / 2, the snapshots lie, and they lie in a precise way. The tone shows up at the alias frequency:
Three examples. A 9 kHz tone sampled at 12 kS/s has k = 1, so it appears at |9,000 − 12,000| = 3,000 Hz. A 60 Hz mains hum sampled at 50 S/s appears at |60 − 50| = 10 Hz, a slow drift that looks like a brain rhythm. A spike component at 7.5 kHz sampled at 10 kS/s appears at 2.5 kHz. After sampling, the data for a real 3 kHz tone and an aliased 9 kHz tone are identical. No software can tell them apart.
Top: the true tone and the snapshots. Bottom: where the tone sits on a frequency axis. Choose a sampling rate, drag the tone above the Nyquist line, and watch it fold back. Then switch on the filter.
The alias frequency is exact, from the formula above. The filter is a third-order Butterworth low-pass with its 3 dB point at fs / 4, the same shape as the Intan RHD2000 upper cutoff (gain 0.12, or −18 dB, at twice the cutoff). The tone has a unit height before the filter.
Try the hum example by hand: pick 250 S/s and drag the tone to about 190 Hz. It folds to 60 Hz at full size. With the filter on, set at 62.5 Hz, the tone arrives 29 dB down, at about 4%. At 12 kS/s, a 9 kHz tone folds to 3 kHz at full size without the filter, and at about 4% with it.
The cure has to act before the sampler, because afterwards the damage is permanent. The cure is an anti-alias filter: a low-pass filter that removes everything above the Nyquist frequency while it is still a smooth analog voltage.
A real filter is not a wall. The Intan RHD2000 uses a third-order Butterworth low-pass at its upper cutoff fH, which you can set from 100 Hz to 20 kHz. Its datasheet lists the gain: 0.89 (−1 dB) at 0.8 fH, 0.707 (−3 dB) at fH, 0.12 (−18 dB) at twice fH, and 0.001 (−60 dB) at ten times. The roll-off is −18 dB per octave, which is −60 dB per decade. In its own words, the amplifier bandwidth is set to "minimize aliasing by attenuating signals above the Nyquist rate".
So the sampling rate must sit well above twice the cutoff. With fH = 7.5 kHz and fs = 30 kS/s, the Nyquist frequency is 15 kHz, exactly twice fH. A tone there is already 18 dB down. A 20 kHz tone, which would fold to 10 kHz, is cut to 1 / √(1 + (20 / 7.5)6) = 5%, or −25.6 dB. That is the reason for the 4 to 1 ratio, and the reason spike recorders sample at 30 kS/s for a 7.5 kHz band.
A second design avoids a sharp analog filter. The ADS1299 uses a delta-sigma converter. Its modulator samples the input at fMOD = fCLK / 2, which is 1.024 MHz with the 2.048 MHz clock in its specifications. A digital third-order sinc filter then removes the high-frequency noise and keeps only the requested output rate, from 250 to 16,000 S/s. For 250 S/s that is 4,096 modulator samples averaged into each output.
The datasheet says these decimation filters "also provide antialias filtering" and that this "drastically reduces the complexity of the analog antialiasing filters". One catch remains. The passband repeats at every multiple of fMOD, so simple R-C filters at the input must still cut interference near 1.024 MHz. The Intan RHD2000, by contrast, uses a 16-bit successive-approximation converter, shares it among channels, and relies on the analog filter of the amplifier.
The failure is easy to spot once you know it. The symptom is a slow wave or a tone that should not exist. The measurement is to change the sampling rate: a real signal stays put, and an alias moves. The fix is a lower filter cutoff, or a higher sampling rate, but never a software filter after the fact.
Chapter 5
Pick a band and a sampling rate for each signal, and price the data that comes out
A courier company charges per parcel. Each snapshot from the converter is a parcel: a number that must be stored, sent and processed. The bill is the number of parcels per second times the size of each. So the sampling rate is not only a quality setting. It is a cost setting.
The right rate follows from the signal. First find the band the signal lives in: the range of frequencies that carries what you want. Then filter to that band (Chapter 4) and sample at three to four times the top of it. Anything faster just pays for parcels with nothing in them.
The Intan RHD2000 datasheet names the bands outright. Its amplifiers can be tuned for different types of signals, for example 0.1 to 100 Hz for EKG and 250 Hz to 7.5 kHz for neural action potentials. Spikes are fast and sharp, so they need the high band. A heartbeat, like the slow rhythms of the brain, is smooth and needs the low one.
The datasheet's own recordings show the rates. The heart signal (EKG) was cut at 100 Hz and sampled at 2 kS/s. A muscle signal (EMG) was cut at 1 kHz and sampled at 4 kS/s. Both sample at four times the top of the band or more. A mouse cortex recording with tetrodes was filtered from 1 Hz to 9 kHz and sampled at 30 kS/s. The datasheet then shows the same data filtered at 300 Hz in software. That removes the local field potentials (LFPs) and isolates the spikes. The LFP is the slow swell of voltage from many cells acting together. The cut at 300 Hz is a common convention; labs differ on the exact number.
For scalp EEG, the ADS1299 datasheet specifies its noise from 0.01 Hz to 70 Hz. At its lowest rate of 250 samples per second (SPS) the converter's own filter passes up to 65 Hz. EEG is slow, so 250 SPS is enough. The same datasheet allows up to 16,000 SPS, for faster signals.
Here is the key practical point. One wire can carry both the LFP and the spikes. So labs record wide, once, at the spike rate, and split the data in software. High-pass at 300 Hz gives the spikes. Low-pass below 300 Hz and then downsample (keep one sample in thirty) gives the LFP at 1 kS/s, a thirtieth of the data. The low-pass must come first, for the same reason as in Chapter 4: dropping samples is sampling again, and it aliases without a filter.
Here is the downsample in numbers. A 30 kS/s recording holds one sample every 33 µs. Keeping one sample in thirty leaves one every 1 ms, which is 1 kS/s, with a Nyquist frequency of 500 Hz. A 700 Hz tone would fold to 300 Hz, right on top of the LFP. So the low-pass must cut it first. At a third-order slope with a 300 Hz cutoff, that tone sits at 2.3 times the cutoff and falls by about 22 dB. The recording keeps its spikes at the full rate, and the LFP copy costs a thirtieth as much.
The data rate is three numbers multiplied. Channels × samples per second × bits per sample. Eight EEG channels at 250 SPS and 24 bits make 8 × 250 × 24 = 48,000 bits per second, or 48 kbit/s. Thirty-two spike channels at 30 kS/s and 16 bits make 32 × 30,000 × 16 = 15.4 Mbit/s. A thousand-channel array of the same kind makes 491.5 Mbit/s, which is 221 gigabytes in an hour.
Pick a signal. The teal bar is its band on a log frequency axis; the blue line is the Nyquist frequency. The lower plot shows the data rate that comes out. Drag channels and bits.
Bands: EEG 0.01 to 70 Hz is the ADS1299 noise specification band; spikes and LFP 1 Hz to 9 kHz and 30 kS/s come from the Intan RHD2000 datasheet recording (Figure 7); the 300 Hz LFP limit and the 1 kS/s LFP rate are common conventions, not standards. The dashed line is the datasheet's 16.8 Mbit/s at full speed. The data rates are computed live as channels × rate × bits and ignore headers and extra channels.
Compare the lines. EEG is cheap: 48 kbit/s fits through almost any radio. The 32-channel spike recorder sits just under the 16.8 Mbit/s that an RHD2000 pushes at full speed. A 1,024-channel version is 32 times that. It is why many implant designers detect spikes on the chip and send only the events, a step the spike detection lesson covers.
Bits cost power too. The Intan datasheet works one example: sending 16.8 Mbit/s down a 2 m cable of 100 pF per metre takes about 18 mW with ordinary CMOS signalling. Its low-voltage differential option takes at least 11.6 mW. For an implant that must stay cool, those milliwatts matter. Fewer bits per second is a design goal in its own right.
The failure here is quiet. The symptom is a link that drops data, or a battery that dies early. The measurement is channels × rate × bits against the link's real capacity. The fix is to cut the band to what the decoder needs, drop the rate, trim the bits, or compress on the implant.
Chapter 6
Turn a smooth voltage into steps, measure the error the steps add, and decide how many bits are enough
Measure a pencil with a ruler marked only in whole centimetres. You read 14 cm when the true length is 14.3 cm, or 13.8 cm, or 14.49 cm. You always round to the nearest mark, so you are off by up to half a centimetre. A converter does the same to voltage. The marks are its levels, and the rounding mistake is quantization error.
An ADC (analog-to-digital converter) with N bits has 2N levels. Sixteen bits give 65,536 levels. Spread them across the window the converter can see, and the gap between two neighbouring levels is the step, also called the least significant bit or LSB, written q here.
For the Intan RHD2000 the window is 65,536 × 0.195 µV = 12.8 mV, so q = 0.195 µV. For the ADS1299 at gain 24 with its 4.5 V reference, the full-scale input is ± VREF / gain = ±187.5 mV, a window of 375 mV, shared among 224 = 16.8 million levels. That makes q = 22.4 nV.
Each sample is off by some amount between −q / 2 and +q / 2. If the signal is busy enough, every amount in that range is equally likely. Call the error x. Its mean square is the average of x2 over the range:
So the rms quantization error is q / √12, which is 0.289 q. W. R. Bennett worked this out for communication systems in 1948. For the RHD2000, 0.195 µV / 3.46 = 0.056 µV rms. Compare it with the amplifier's own 2.4 µV rms. It is 43 times smaller. Adding the two in squares gives √(2.4² + 0.056²) = 2.4007 µV. The converter adds nothing you can measure.
A full-scale sine wave, a sine that just fills the window, has a neat result. Its rms is the half-window divided by √2. The ratio to q / √12 works out to SNR = 6.02 N + 1.76 dB. Each extra bit buys 6 dB. Sixteen bits give 98 dB. That is the ideal, and only for a signal that fills the window.
The window is the RHD2000 one, ±6.39 mV. Top: the signal (faint) and what the converter writes down (solid). Bottom: the rounding error. Lower the bits, or shrink the signal, and watch the steps appear.
Window and step from the Intan RHD2000 datasheet (16-bit, 0.195 µV); the signal is an illustrative sine, and the noise is Gaussian at the datasheet's typical 2.4 µV rms. The error is measured live over 240 points and compared with q / √12. The 6.02 N + 1.76 dB rule is the textbook result for a full-scale sine.
Set 8 bits and 100 µV. The step is 49.9 µV, so the sine is only four steps tall from peak to peak and the error is a jagged sawtooth. Raise to 12 bits and the step is 3.1 µV. Now add the amplifier noise. The converter's 0.9 µV of rounding error adds to 2.4 µV only in squares, so the total rises by 7%, to 2.56 µV. At 14 bits it is invisible. This is the rule: quantization error should be well below the analog noise in front of it, and no further.
Real converters have noise of their own. The datasheet reports the effective number of bits (ENOB): the number of bits that an ideal converter would need to have the same noise. The ADS1299 is a 24-bit converter, yet at 250 SPS and gain 24 its table lists an ENOB of 19.85, and 18.54 noise-free bits (bits that do not flicker). At 16 kSPS, the same gain gives an ENOB of 16.28. Faster output means more noise bandwidth and fewer effective bits. Each of the 24 bits is not an independent gift.
Why use 24 bits at all? Look back at Chapter 0. The ADS1299 does not discard the electrode offset up front. It keeps a window of ±187.5 mV at gain 24 and relies on very fine steps to still resolve microvolts. The RHD2000 takes the other route: it rejects DC in the amplifier, gives the converter only 12.8 mV to cover, and spends just 16 bits. Two designs, two answers to the same offset problem.
Signal size matters too. A signal that fills only a tenth of the window wastes more than three bits. A signal that exceeds the window is clipped, and clipping is not noise but loss: the peaks are gone. Gain is the knob that places the signal in the window. The failure has three parts. The symptom is flat-topped or staircase traces. The measurement is the count of distinct codes in a quiet stretch, or a histogram of the codes. The fix is more gain, until the noise spans a few steps, or more bits.
A last curiosity: a little analog noise helps. When the noise is about one step wide, the rounding error stops looking like a staircase and blurs into the noise, which is harmless. The noise here is a friend. See also the quantization noise lesson for the full treatment of dither and noise shaping.
Chapter 7
Read the datasheets of an EEG chip and a spike chip, and see how each design answers the same five hazards
Two engineers face the same five hazards. One builds a chip for scalp EEG, where signals are a few tens of microvolts and slow. The other builds a chip for spikes, where signals are fast and the electrodes sit inside tissue. Their datasheets look nothing alike, and each one is a set of answers to Chapters 1 to 6.
The two chips here are the Texas Instruments ADS1299 (EEG and other biopotentials) and the Intan RHD2132 (neural recording with 32 channels). Every number below is from the datasheet named in the hero, read for this lesson.
| Question | ADS1299 (TI) | RHD2132 (Intan) |
|---|---|---|
| Built for | EEG and biopotentials; 8 channels (4 and 6 channel versions exist) | Spikes, LFP, EKG, EMG; 32 channels (the RHD2164 has 64) |
| Converter | 24-bit delta-sigma, one per channel, simultaneous | 16-bit successive-approximation, shared by a multiplexer |
| Sampling rate | 250 to 16,000 SPS | up to 30 kS/s per channel (1.05 MS/s in all) |
| Gain | 1, 2, 4, 6, 8, 12 or 24, chosen by you | 192 V/V (45.7 dB) in the passband |
| Input noise | 1 µV peak-to-peak in 70 Hz; 0.14 µV rms at 250 SPS, gain 24 | 2.4 µV rms typical |
| Converter step | 22.4 nV at gain 24 (± VREF / gain = ±187.5 mV) | 0.195 µV (window ±6.39 mV) |
| Common-mode rejection | −110 dB specified, −120 dB typical, at 50 and 60 Hz | 82 dB typical, 50 and 60 Hz |
| What it does with DC | Keeps it: large window, very fine steps | Rejects it: DC gain 0, inputs may sit ±0.4 V off ground |
| Anti-aliasing | Oversample at 1.024 MHz, then a digital sinc3 filter; a simple R-C filter outside | Analog third-order Butterworth, fH from 100 Hz to 20 kHz on chip |
| Reference | SRB pins for a common reference; patient bias drive that feeds back the average | One common reference input shared by all 32 amplifiers |
| Input impedance | 1,000 MΩ DC (no lead-off test), 20 pF | 1,300 MΩ at 10 Hz, 13 MΩ at 1 kHz, 12 pF |
| Supply | analog 4.75 to 5.25 V | 3.3 V (3.2 to 3.6 V) |
Read down the rows as design choices. The EEG chip is calm: signals are slow, so a heavy oversampled converter with a digital filter is cheap and quiet, and a patient bias drive and a very high CMRR handle the hum. The spike chip is crowded: 32 channels in a 4.8 mm × 4.1 mm die, so it shares one converter and spends its effort on small area and low power. Its CMRR is lower. The datasheet itself says the shared reference suits cases where hum is mild, as with implants.
Two rows deserve a closer look. The first is the converter. A delta-sigma converter samples very fast and averages, as Chapter 4 showed with its 4,096 to 1 ratio. That trade buys 24 bits at 250 SPS and fewer effective bits at 16 kSPS, which the table below shows. A successive-approximation converter makes one careful comparison per bit, 16 in all, and can run at a million samples a second. A multiplexer needs that speed. So the choice follows the job: slow and fine for EEG, fast and shared for spikes.
The second row is who samples when. The ADS1299 has one converter per channel, and all of them sample at the same instant. The RHD2132 has one converter for 32 channels and visits them in turn, with at least 950 ns per conversion at full speed. Channel 32 is therefore read about 29 µs after channel 1, inside one 33 µs frame. For a spike that lasts a millisecond, that skew is small. For a comparison of the phase of a fast rhythm across channels, it can matter, and simultaneous sampling avoids it at the price of a converter for every channel.
Count the trade a third way, by what each chip leaves for you to choose. With the ADS1299 you pick the gain and the data rate, and the datasheet gives the noise for every pair. With the RHD2132 the gain is fixed, and you pick only the band, with two filter corners set by registers or by off-chip resistors. The first gives you more knobs on one slow signal. The second gives you fewer knobs on many fast channels. Neither is better. Each fits the job its maker had in mind.
Check a datasheet claim by recomputing it. Intan says a gain of 192 gives a step of 0.195 µV, and lists the converter's own step as 37.4 µV. Dividing 37.4 by 192 gives 0.195, so the numbers agree. For the ADS1299, a full scale of ±187.5 mV spread over 224 levels gives 22.4 nV. When a number you compute does not match the datasheet, you have usually missed a condition.
The ADS1299 datasheet gives a full noise table: input-referred noise for every gain and every data rate. The device below puts that table in your hands. Pick a gain, then slide the data rate. The dashed line is the RHD2132's typical 2.4 µV rms.
Each bar is the ADS1299 input-referred noise at one data rate, from the datasheet. The bar for your data rate is lit. Change the gain to see the whole table move.
Noise (µV rms), −3 dB bandwidth and ENOB are copied from ADS1299 datasheet Tables 1 to 4 (5 V analog supply, 4.5 V reference, inputs shorted, internal reference, normal mode); gains 4 and 6 are in the datasheet and left out here. The noise density is the rms value divided by the square root of the bandwidth, which assumes the noise is flat, so it is only a rough guide.
Look at gain 24 at 250 SPS: 0.14 µV rms, over a 65 Hz bandwidth. Now go to 16,000 SPS: 1.66 µV rms, over 4,193 Hz. The bandwidth grew 65 times; the noise grew 12 times, a little more than the square-root rule predicts. Then move to gain 1 at 250 SPS: 1.08 µV rms. A high gain in front lowers the input-referred noise, just as Chapter 2 said, because later noise sources count for less.
A last point about how to read a datasheet. A headline number such as "1 µV peak-to-peak" always comes with a condition, here a 70 Hz bandwidth. Compare chips only at the same bandwidth and the same electrode impedance, or the comparison means nothing. The 2.4 µV rms of the RHD2000 and the 0.14 µV rms of the ADS1299 are not rivals. They belong to bandwidths a hundred times apart.
Chapter 8
Set every stage at once, find the weakest link, and learn the failure each setting causes
You have met every stage alone. A real design sets them all at once, and a good setting for one stage can wreck another. Gain helps the converter and hurts the headroom. A wide band helps the spike shape and hurts the noise. This chapter is the whole chain in one device, with a method for reading it.
Work from the electrode to the number, and ask one question at each stage. Write the answer as a size in microvolts, referred to the electrode, so every answer compares with the signal.
Then compare the signal with the biggest bar. That bar is the weakest link. Fix it, and the next one becomes the weakest. Stop when the chain is limited by the electrode and the amplifier, the parts you cannot change by turning a knob.
Take the spike preset below. The converter window is ±1 V after the gain (a round number). At the Intan gain of 192 that is ±5.2 mV at the electrode, close to the datasheet's ±5.0 mV AC range. With 16 bits, q = 2 V ÷ 65,536 ÷ 192 = 0.159 µV, and its rounding error is 0.046 µV rms, far under the 2.4 µV amplifier noise. A 1 MΩ electrode over 7.5 kHz gives 11.1 µV rms of its own. Ignoring leftover hum, the total is 11.4 µV rms, and a 100 µV spike is 8.8 times that. The electrode is the weakest link, as it should be.
Choose a source. Everything starts well tuned. Break it on purpose: raise the gain, lower the sampling rate, cut the bits, switch off the reference. Read which bar rises and which failure appears.
Toy model, with datasheet numbers where they exist: amplifier noise 2.4 µV rms (RHD2000 typical) for spikes and 0.14 µV rms (ADS1299, 250 SPS, gain 24) for EEG; thermal noise at 300 K; 2 mV of 50 Hz hum; the reference leaves 0.3% of the hum for spikes and 0.03% for EEG (toy values); a 100 mV offset with drift if the high-pass is off (300 Hz for spikes, 0.5 Hz for EEG); a converter window of ±1 V after the gain; a third-order Butterworth anti-alias filter at the upper cutoff. The alias test uses the tone at fs − fc, which folds onto the top of the band.
Set the gain from the largest peak you expect, not from the smallest signal you want. Add the signal peak, the leftover hum and three times the noise. For the spike preset that is about 100 µV + 6 µV + 34 µV = 140 µV. At a gain of 192 that peak uses 27 mV of the ±1 V window, only 2.7%. This is deliberate headroom, because a real electrode throws swings much larger than the spike.
Now raise the gain to 3,000. The spike peak uses 42% of the window, which looks ideal. But switch off the reference and the 2 mV of hum becomes 6 V, and the converter clips. A gain is only as large as the interference behind it allows. Fix the interference first, and then spend what is left of the window on gain.
Clipping. Set the spike gain to 1,000 with the high-pass off. The trace flatlines. The symptom is flat-topped or railed samples. The measurement is the fraction of samples at the extreme codes, which the read-out gives. The fix is to remove the offset first (Chapter 1), then lower the gain until the largest expected peak sits at about half of full scale.
Aliasing. Drop the sampling rate to 8 kS/s with the cutoff at 7.5 kHz. The device flags it: a tone at fs − fc is barely attenuated, and it folds onto your spikes. The symptom is a ghost tone that moves when you change the rate. The fix is a lower cutoff or a higher rate (Chapter 4).
Coarse rounding. Set 8 bits at a gain of 10. The rounding bar jumps past the amplifier bar and the output turns into stairs. The measurement is q / √12 against the analog noise. The fix is more gain, so the noise spans several steps, or more bits (Chapter 6).
Now switch to EEG. The ADS1299 route changes every answer. The electrode is 5 kΩ, so its thermal noise is small; the amplifier is the floor. The band is 65 Hz, so the 50 Hz hum is inside it, and the reference matters more than the filter. Turn the reference off and watch the hum bar jump to the top. Both chains use the same six questions. Only the answers differ.
Chapter 9
Keep the numbers, the checklist, the core code and the sources on one page
You can now follow a spike from the electrode to the number. Five stages stand between the brain and the decoder, and each can ruin the signal. This page keeps what you need to design, check or debug the chain.
An electrode and an amplifier input form a voltage divider, so the amplifier needs a very high input impedance, and the high-pass filter throws the slow offset away. The electrode's resistance and the amplifier add noise in squares, and the noise grows with the square root of the bandwidth. A reference cancels the hum every electrode shares; monopolar, bipolar and common average each leak in their own way. The sampler folds every tone above half the sampling rate onto a false one, so an anti-alias filter must come first. The converter rounds to steps whose error is q / √12, which only matters if it is not well below the analog noise. The rate you choose sets the price of the data.
| What | Number | Source and why it matters |
|---|---|---|
| RHD2000 converter | 16 bits, step 0.195 µV, gain 192 (45.7 dB), up to 30 kS/s per channel | Intan datasheet. The step sets the finest change it can see. |
| RHD2000 noise and rejection | 2.4 µV rms typical; CMRR 82 dB at 50 and 60 Hz | Intan datasheet. Sets the floor and the hum left over. |
| RHD2000 input | 1,300 MΩ at 10 Hz, 13 MΩ at 1 kHz, 12 pF; AC range ±5 mV, DC offset ±0.4 V | Intan datasheet. The divider loses the high end of a weak electrode. |
| RHD2000 filters | High-pass 0.1 to 500 Hz; low-pass 100 Hz to 20 kHz; 3rd-order Butterworth, −18 dB at 2 fH | Intan datasheet. Places the band; sets how fast aliasing is cut. |
| ADS1299 converter | 24 bits, 250 to 16,000 SPS, gains 1 to 24, full scale ±VREF / gain | TI datasheet. Fine steps instead of rejecting DC. |
| ADS1299 noise | 1 µV pp in 70 Hz; 0.14 µV rms at 250 SPS and gain 24 (ENOB 19.85); 1.66 µV rms at 16 kSPS | TI datasheet tables. Noise follows bandwidth. |
| ADS1299 rejection | CMRR −110 dB specified, −120 dB typical; patient bias drive; modulator at 1.024 MHz | TI datasheet. Hum and aliasing handled mostly in digits. |
| Thermal noise | √(4 k T R Δf) = 12.9 µV rms for 1 MΩ over 10 kHz at 300 K | Johnson and Nyquist, 1928. Quarter the bandwidth and it halves. |
| Aliasing | falias = |f − k fs|; Nyquist frequency fs / 2 | Nyquist 1928, Shannon 1949. Filter first. |
| Quantization | error = q / √12; 6.02 N + 1.76 dB for a full-scale sine | Bennett 1948. Keep it far under the analog noise. |
| Data rate | 8 EEG channels: 48 kbit/s. 32 spike channels: 15.4 Mbit/s. 1,024 channels: 491.5 Mbit/s | Computed: channels × rate × bits. Sets the radio and the power. |
These six functions are the whole lesson. Run it and the six printed numbers match the ones in the chapters.
pythonimport numpy as np K, T = 1.380649e-23, 300.0 # Boltzmann constant, kelvin def thermal_vrms(R, bw): # Ch 2: Johnson noise of the electrode return np.sqrt(4 * K * T * R * bw) def alias(f, fs): # Ch 4: where a tone lands after sampling return abs(f - round(f / fs) * fs) def butter3(f, fh): # Ch 4: 3rd-order Butterworth low-pass gain return 1 / np.sqrt(1 + (f / fh) ** 6) def divider(R, f, c=12e-12): # Ch 1: share of the signal the amplifier keeps x = 1 / (2 * np.pi * f * c) return x / np.hypot(R, x) def lsb(window_v, bits): # Ch 6: one converter step return window_v / 2 ** bits def total_noise(R, bw, amp, q): # independent noise adds in squares return np.sqrt(thermal_vrms(R, bw) ** 2 + amp ** 2 + (q / np.sqrt(12)) ** 2) def data_rate(channels, fs, bits): # Ch 5: bits per second return channels * fs * bits q = lsb(65536 * 0.195e-6, 16) # Intan RHD2000 window, 16 bits print(thermal_vrms(1e6, 1e4) * 1e6) # 12.9 (uV rms, 1 MOhm over 10 kHz) print(total_noise(1e6, 1e4, 2.4e-6, q) * 1e6) # 13.1 (uV rms, with the amplifier) print(alias(9000, 12000)) # 3000 (Hz) print(butter3(20e3, 7.5e3)) # 0.053 (gain at 20 kHz) print(divider(1e6, 1e4)) # 0.798 (kept at 10 kHz) print(data_rate(32, 30000, 16) / 1e6) # 15.36 (Mbit/s)
Every implant and every EEG headset has this chain, in different clothes. Implant teams compress the choices into a custom chip: a company white paper (Musk and Neuralink, J Med Internet Res 2019, doi 10.2196/16194) describes a custom chip with thousands of channels. This lesson does not use its figures, and treats them as company claims. Non-invasive companies such as Sabi describe custom chips and a "brain foundation model" for EEG; that is also a company claim, and the datasheet physics above is what such a chip must still obey. Whatever the model downstream, it can only learn from what the front end let through. A decoder cannot recover a spike the filter removed, a tone the sampler folded, or a rhythm the reference cancelled.
The spike size, the mains pickup, the offset, the electrode impedances and the 300 Hz LFP limit are illustrative or conventional values and are labelled so where they appear. The Intan and TI numbers are from the datasheets as listed.
Now press Teach and explain, from memory, how a 100 µV spike survives the chain: what each stage does to it and which number would tell you it failed. Then go back to the chain at the top, break it three different ways, and name each failure.