Definition
Spike sorting: Spike sorting is the process of detecting action potentials in extracellular recordings and assigning each spike to the individual neuron that produced it. It typically involves filtering, spike detection, feature extraction and clustering, and it turns raw electrode voltages into per-neuron spike trains that can be analyzed or used as computing outputs.
Also known as: spike classification, single-unit isolation, unit sorting
Spike sorting is the process of detecting action potentials in extracellular recordings and assigning each spike to the individual neuron that fired it. It usually involves filtering, spike detection, feature extraction and clustering, and it turns raw electrode voltages into per-neuron spike trains that scientists can analyze or that a biocomputer can use as outputs.
Key takeaways
- Extracellular electrodes, such as those on a microelectrode array, pick up spikes from several neurons at once; spike sorting separates them.
- The classic pipeline is filter, detect, extract features, cluster, then curate.
- Lewicki’s 1998 review in Network set out the core problem; modern tools such as Kilosort4 (2024) handle hundreds to thousands of channels.
- Dense electrodes, as on a high-density microelectrode array, improve sorting because each neuron appears on several sites.
- Errors such as merges, splits and missed overlapping spikes are unavoidable, so validation and quality metrics matter.
What is spike sorting?
When a neuron fires an action potential, it creates a brief voltage change in the fluid around it. An electrode within range records that change as a spike. In practice each electrode sits near several neurons, and each neuron’s spike has a slightly different shape and amplitude depending on its type, size and distance. Spike sorting exploits those differences to answer the question: which neuron fired which spike?
Lewicki described the problem in a 1998 review in Network: Computation in Neural Systems as “the detection and classification of neural action potentials”. The output is a set of spike trains, one per putative neuron, often called units. Spike sorting is a core step in electrophysiology whenever recordings are extracellular.
How does spike sorting work?
Most algorithms follow the same broad steps, though modern tools combine or reorder them.
- Filtering. The raw signal is band-pass filtered to remove slow field potentials and high-frequency noise, leaving the frequency range where spikes live.
- Detection. Candidate spikes are found where the signal crosses a threshold, often set as a multiple of the estimated noise level.
- Feature extraction. Each spike’s waveform is summarized by a few numbers, for example principal components or wavelet coefficients. Quiroga et al. reported in Neural Computation (2004) an unsupervised method combining wavelet features with superparamagnetic clustering.
- Clustering. Spikes with similar features are grouped, on the assumption that each group comes from one neuron.
- Curation and quality control. Clusters are checked, automatically or by hand, using metrics like refractory period violations (a single neuron cannot fire twice within a very short interval) and separation from other clusters.
Template matching for dense recordings
On arrays with many closely spaced channels, a neuron’s spike appears as a spatial pattern across neighboring electrodes. Template-matching sorters learn a template for each neuron across channels and then explain the recording as a sum of templates, which helps resolve spikes that overlap in time. Kilosort is the best-known example; Pachitariu et al. described its fourth version in Nature Methods (2024). These methods were developed in part for dense silicon probes like Neuropixels, reported by Jun et al. in Nature (2017).
Spike sorting approaches compared
| Approach | How it separates neurons | Strengths | Weaknesses | Typical use |
|---|---|---|---|---|
| Threshold only (no sorting) | Counts all threshold crossings per electrode | Fast, simple, real-time | Mixes neurons together | Closed-loop control, network activity |
| Feature-based clustering | Clusters waveform features on each channel | Works on sparse arrays, interpretable | Struggles with overlaps and drift | Tetrodes, passive MEAs |
| Template matching | Fits spatial templates across many channels | Handles overlaps, scales to dense arrays | Computationally heavy, needs tuning | HD-MEAs, Neuropixels |
| Ensemble or consensus | Compares outputs of several sorters | Highlights reliable units | More compute, more complexity | Validation, benchmarking |
Why does spike sorting matter for biocomputing?
In organoid intelligence and other wetware computing, the recorded activity is the computer’s output. How well you sort spikes shapes what you can read out:
- Decoding precision. Per-neuron spike trains allow finer neural encoding and decoding than electrode-level counts.
- Tracking learning. Following identified neurons over time shows how synaptic plasticity changes their responses during training, as discussed in how neurons learn in a dish.
- Connectivity. Precise spike timing between neurons can hint at functional connections and at mechanisms like spike-timing-dependent plasticity.
- Real-time trade-offs. Closed-loop stimulation may need decisions within milliseconds, so many systems use fast detection online and full sorting offline.
A worked example: sorting one electrode
Imagine an electrode on a cultured network that records 5,000 threshold crossings in ten minutes. Plotted together, the waveforms look like a smear. After feature extraction, a scatter plot of the first two principal components shows three dense clouds plus scattered points. The sorter assigns each cloud to a putative neuron: one with large, sharp spikes, one with smaller and wider spikes, and one that fires mostly during bursts. The scattered points, which might be noise or overlapping spikes, are labeled unassigned. A quality check finds almost no refractory violations in the first two clusters, so they are kept as single units, while the third is labeled multi-unit activity.
Spike sorting vs spike detection
The terms are sometimes used loosely. Spike detection only finds that a spike happened on a channel. Spike sorting goes further and attributes each spike to a neuron. Many studies of network bursts in cultures rely on detection alone, because bursts involve many neurons firing together and sorting adds little. Single-neuron questions require sorting.
What are the limitations of spike sorting?
- Merges and splits. Two similar neurons may be merged, or one neuron with changing amplitude may be split.
- Overlapping spikes. Near-simultaneous spikes from nearby neurons distort waveforms, especially during bursts.
- Drift. Tissue movement or changing cell health alters waveforms over long recordings, a particular concern in long-lived organoid experiments.
- No ground truth. In most recordings, nobody knows the true answer, so accuracy is estimated rather than measured.
- Sorter disagreement. Different algorithms can give different results on the same data. Buccino et al. described SpikeInterface in eLife (2020), a framework for running and comparing multiple sorters with a common interface.
Rey, Pedreira and Quian Quiroga reviewed these challenges and future directions in Brain Research Bulletin (2015).
How should spike sorting results be shared?
Reproducible biocomputing needs both the raw data and the sorting parameters. Storing recordings, sorted units and metadata in open formats such as Neurodata Without Borders lets others rerun or compare sorting. For the hardware side of the pipeline, see microelectrode arrays explained.
Recording which sorter, version and parameters produced each result, alongside the raw data, is part of the experiment ledger we are building at Organoid Programming.
Frequently asked questions
Why is spike sorting necessary?
An extracellular electrode usually picks up spikes from several nearby neurons, mixed with noise. Without sorting, you only know that something fired near that electrode. Spike sorting separates those spikes by their shape and spatial pattern so each can be attributed to a specific neuron, which is needed to study how individual cells fire, connect and change.
What is the difference between single-unit and multi-unit activity?
Single-unit activity is a spike train confidently attributed to one neuron after spike sorting. Multi-unit activity is the combined spiking of several neurons near an electrode that could not be separated reliably. Researchers often report both, and quality metrics such as refractory period violations help decide which clusters qualify as single units.
What is Kilosort?
Kilosort is a widely used open-source spike sorting software package designed for recordings from many channels, such as Neuropixels probes and high-density arrays. It uses template matching to model each neuron’s spike shape across channels and to resolve overlapping spikes. Its fourth major version was described by Pachitariu and colleagues in Nature Methods in 2024.
Can spike sorting run in real time?
Simplified forms can. Closed-loop experiments often need responses within milliseconds, so they may use fast threshold detection or pre-computed templates rather than full offline sorting. Full sorting with careful clustering and manual curation is usually done offline after the recording. Choosing the right trade-off between speed and accuracy depends on the experiment.
Is spike sorting accurate?
It is useful but imperfect. Errors include merging two neurons into one cluster, splitting one neuron into several, and missing spikes that overlap in time. Accuracy depends on electrode density, noise, neuron firing patterns and the algorithm used. Different sorters can produce different results on the same data, which is why comparison and validation tools exist.
Sources
- Lewicki (1998). A review of methods for spike sorting: the detection and classification of neural action potentials. Network: Computation in Neural Systems.
- Quiroga, Nadasdy & Ben-Shaul (2004). Unsupervised spike detection and sorting with wavelets and superparamagnetic clustering. Neural Computation.
- Rey, Pedreira & Quian Quiroga (2015). Past, present and future of spike sorting techniques. Brain Research Bulletin.
- Pachitariu et al. (2024). Spike sorting with Kilosort4. Nature Methods.
- Buccino et al. (2020). SpikeInterface, a unified framework for spike sorting. eLife.
- Jun et al. (2017). Fully integrated silicon probes for high-density recording of neural activity. Nature.

