Solving the spike sorting problem with Kilosort

Marius Pachitariu, Shashwat Sridhar, Carsen StringerbioRxiv 2023 · DOI

TL;DR

Kilosort4, the latest iteration of a popular spike-sorting framework, significantly improves neuron identification accuracy, especially in challenging conditions like probe drift and overlapping signals. This advancement is driven by novel graph-based clustering and a more robust simulation framework for benchmarking.

What Problem Does This Paper Address?

Neuroscientists need to precisely identify the firing times of individual neurons from electrical recordings. This "spike sorting" is crucial for understanding brain activity but is incredibly difficult due to:

  • Non-stationarity: The electrical signals from neurons can change shape over time due to factors like probe movement ("drift").
  • Signal Overlap: Neurons are densely packed, leading to overlapping electrical fields that make it hard to distinguish individual spikes.
  • Low-Amplitude Signals: Detecting faint signals from neurons far from the probe or with small spatial footprints is challenging.

Existing methods often require extensive manual curation, which is time-consuming and subjective. The authors aim to automate and improve this process, building upon their Kilosort framework.

Methods

The paper details the evolution of Kilosort, culminating in Kilosort4. Key algorithmic advancements include:

  • Template Deconvolution: A core component that uses learned "templates" (average spike waveforms) to detect and extract spike features, even when spikes overlap. Kilosort4 refines this with background correction.
  • Drift Correction: Introduced in Kilosort2.5 and inherited by Kilosort4, this crucial step accounts for probe movement by aligning the data.
  • Graph-Based Clustering (Kilosort4): A novel approach that constructs a graph of spike features and uses modularity optimization to group them. This is a significant departure from earlier Kilosort versions' scaled K-means.
  • Simulation Framework: A new, realistic simulation environment was developed to generate spike waveforms and noise based on real experimental data, incorporating various drift patterns. This allows for rigorous benchmarking.
  • Python/PyTorch Implementation: Kilosort4 is fully implemented in Python with PyTorch, enabling GPU acceleration and broader accessibility.

Datasets

  • IBL Dataset: Recordings from the International Brain Laboratory (IBL) were used to derive realistic drift patterns and waveform shapes for the simulation framework.
  • New Simulation Benchmark: The authors developed a novel simulation framework that generates non-stationary spike waveforms and realistic noise, incorporating various drift types (no drift, medium, high, fast, step drift) and aligned probe configurations. This benchmark is used to evaluate Kilosort4 and compare it against other algorithms.

Key Insights and Ideas

  • Drift is a Major Hurdle: The paper strongly emphasizes that non-stationarity, particularly probe drift, is a primary challenge in spike sorting, and effective correction is vital for high accuracy.
  • Graph-Based Clustering is Powerful: Kilosort4's new graph-based clustering approach significantly improves performance, especially in separating closely related units and handling clusters of varying sizes.
  • Realistic Simulation is Key: The developed simulation framework, grounded in real experimental data, provides a more accurate and challenging testbed for spike-sorting algorithms than previous synthetic datasets.
  • "Over-splitting" as a Strategy: Early Kilosort versions intentionally "over-split" clusters, making manual merging easier for users. Kilosort4's advanced clustering aims to reduce the need for manual intervention altogether.

Key Results

  • Kilosort4 Outperforms: Kilosort4 consistently achieved the highest accuracy across all simulated conditions, outperforming previous Kilosort versions and other state-of-the-art algorithms.
  • High Accuracy in Difficult Conditions: Kilosort4 excelled in identifying neurons with low amplitudes and small spatial extents, even under high drift conditions.
  • Robustness to Drift: Kilosort4 demonstrated strong performance across various drift scenarios, including fast and step drifts. The "step drift, aligned" condition showed that optimizing probe geometry can further enhance performance.
  • Efficiency: While not the primary focus, the paper notes that Kilosort4's Python/PyTorch implementation allows for efficient processing, with runtimes comparable to or better than previous versions.

Limitations and Future Work

  • Specialized Data: The authors note that Kilosort might require special consideration for data from tetrodes or single electrodes where explicit channel geometry is less defined. Kilosort2 with drift tracking might be a better alternative in such cases.
  • Cerebellar Neurons: Complex spikes from cerebellar neurons may not be well-matched by single templates, suggesting a need for specialized algorithms.
  • Chronic Recordings: While the step drift simulation is encouraging, explicit testing on chronic recordings over multiple days would be beneficial.
  • Future Development: The paper highlights the continued development of Kilosort, with the Python/PyTorch implementation expected to foster further improvements and community contributions. The new simulation framework also opens avenues for more rigorous benchmarking of future algorithms.

Summary updated

Abstract

Spike sorting is the computational process of extracting the firing times of single neurons from recordings of local electrical fields. This is an important but hard problem in neuroscience, complicated by the non-stationarity of the recordings and the dense overlap in electrical fields between nearby neurons. To solve the spike sorting problem, we have continuously developed over the past eight years a framework known as Kilosort. This paper describes the various algorithmic steps introduced in different versions of Kilosort. We also report the development of Kilosort4, a new version with substantially improved performance due to new clustering algorithms inspired by graph-based approaches. To test the performance of Kilosort, we developed a realistic simulation framework which uses densely sampled electrical fields from real experiments to generate non-stationary spike waveforms and realistic noise. We find that nearly all versions of Kilosort outperform other algorithms on a variety of simulated conditions, and Kilosort4 performs best in all cases, correctly identifying even neurons with low amplitudes and small spatial extents in high drift conditions.
BibTeX
@misc{pachitariu2023solving,
  author = {Marius Pachitariu and Shashwat Sridhar and Carsen Stringer},
  title = {{Solving the spike sorting problem with Kilosort}},
  year = {2023},
  doi = {10.1101/2023.01.07.523036},
  howpublished = {bioRxiv},
}
Figure