Spike sorting · Lobeworks/17
Spike sorting is the step that turns the voltage traces of an extracellular recording into the spike times of individual neurons, and it is what makes a probe's hundreds of channels into hundreds of cells: no electrode detects a neuron, each only measures a voltage, and the identity of the cell behind each spike is inf
Spike sorting. Spike sorting is the step that turns the voltage traces of an extracellular recording into the spike times of individual neurons, and it is what makes a probe's hundreds of channels into hundreds of cells: no electrode detects a neuron, each only measures a voltage, and the identity of the cell behind each spike is inferred afterwards.
It works because each neuron leaves a footprint. The extracellular potential of a spike falls fast with distance, so a cell close to a dense probe appears on several neighbouring sites at once, large on the nearest and smaller on the others, and its waveform across those sites (its template) differs from that of a cell a few tens of micrometres away. The software finds the spikes in each channel, groups them by their footprint, and assigns each group to one unit; on Neuropixels recordings the usual tool is Kilosort, which matches templates across all 384 channels at once.
Density is what makes it work. More channels do not by themselves mean more neurons; what matters is that the same neuron falls on several electrodes, the way several seismographs locate an earthquake, which is why sites are a few tens of micrometres apart.
A unit is a hypothesis. A cluster may hide two similar cells or split one cell whose spikes change shape during a burst, so sorted units are graded (single unit, multi-unit activity) and checked, for instance for spikes closer together than a refractory period allows, which one neuron cannot fire.
Drift moves the footprint. The brain shifts by micrometres against a rigid shank over minutes and hours, so modern sorters estimate the motion and correct it before matching templates.
The electrode measures voltage; the neuron is found by geometry.
Hardware supplies the same spike seen from several places, and the algorithm turns those places into one cell.
Questions: If electrodes only measure voltage, how does software know which neuron fired? By geometry: spike sorting. A neuron's extracellular potential falls fast with distance, so on a dense probe each spike appears on several neighbouring sites with different sizes, a footprint (template) that differs between cells tens of micrometres apart. Software such as Kilosort finds the spikes and groups them by footprint, one group per unit, the way several seismographs locate one earthquake. The electrode measures voltage; the neuron is found by geometry. How can you check that a sorted unit is really one neuron? Look for impossible intervals. One neuron cannot fire twice within its refractory period, about a millisecond or two, so a unit with many spikes closer than that is contaminated by another cell. Units are graded as single units or multi-unit activity, and drift of the brain against the shank, which moves every footprint, is corrected before sorting. What exactly comes out of a Neuropixels probe, and in what format is it stored? Digital samples, about 125 Mbit/s per probe. SpikeGLX writes them as flat binary files (.ap.bin for spikes, .lf.bin for the field) of 16-bit integers, channels interleaved sample by sample: 384 channels plus one synchronisation channel, 385 in all. A text .meta file beside them gives the gain, the rate and the site map needed to turn counts back into microvolts and positions. What does the computer hold before spike sorting, and where are the neurons in it? A matrix of voltages, V(t,c)V(t, c)V(t,c): one row per sample, every 33 µs, and one column per channel, filled with converter counts. There are no neurons in it yet, only traces; the probe never reports that a neuron fired. Spike sorting is what turns the matrix into spike trains, a list of firing times for each estimated unit (neuron 1 at 0.101 s, 0.237 s, 0.301 s, and so on).