Skip to content


Note: the best way to link to this page is as

Overview of OSort - A spike detection and sorting Matlab package

OSort is a Matlab implementation of a semi-automatic spike sorting algorithm that we and others have used extensively for the detection and sorting of extracellular microelectrode recordings in humans. Most algorithms in the literature are batch processing algorithms - that is, all data must be available before they can run. We have large amounts of data acquired from many channels in parallel. Manual sorting is thus not an option. Also, we would like to develop experiments that adapt themself to the neural response in realtime and we would like to deal with slowly drifting electrodes and/or changing noise sources. Thus we needed an algorithm that can sort spikes as they are recorded - spike by spike. Osort is such an algorithm. The clusters are built and adapted iteratively over the course of the recording. This page documents our implementation of our online spike sorting algorithm OSort. It can be used like any other spike sorting package to process data offline. In addition, it can also be used for online processing and closed-loop experimentation. Please see our package StimOMatic for this purpose.

Below you can find the implementation of our online spike sorting algorithm as well as various simulated and real datasets we used to evaluate the performance of our and other algorithms. The algorithm is documented and carefully evaluated in our published work (see below), where we also compare its performance against other commonly used spike sorting algorithms.

Together with the algorithm, we provide two datasets: 1) a benchmark dataset of simulated extracellular traces at different levels of detection and sorting difficulty, and 2) a actual real recording (human single wire) to illustrate the sorting process.

Our benchmark dataset has in the meantime been used by several other authors to compare and evaluate spike sorting algorithms. See, for example, this recent review article: Gibson et al. 2012, Spike Sorting: The First Step in Decoding the Brain, IEEE Signal Processing Magazine.


Please see the readme.txt file included in the distribution for how to install OSort and read it carefully. Currently, OSort can process Neuralynx Ncs files, text files and leadpoint binary files as-is. It also supports Blackrock data after a simple conversion to Mat files. Adding other data formats (continuous recordings) is easy and frequently done by users.

OSort requires Matlab and the following toolboxes: statistics, signal processing, and wavelets (only if wavelet spike detection is used). OSort is being used by users on all three major platforms - Linux, Windows, Mac OS X.

OSort comes in two version: 1) graphical user interface and 2) textmode interface (command line). The graphical user interface is useful to explore data and the features of OSort whereas the second allows using all features and automation. Most users end up using the textmode interface eventually.

Downloads - Current release

The latest version of OSort is v4.1. This version contains major improvements for new data formats, visualization tools (cluster quality metrics), and various bugfixes. Also it includes new example data.

[Download Source code v4.1]; [Download example data v4.1]; [Tutorial (for v2 but still useful)]

Downloads - Old releases

Previous release: v3.0
No longer available


Online detection and sorting of extracellularly recorded action potentials in human medial temporal lobe recordings, in vivo
U. Rutishauser, E. M. Schuman, A.N. Mamelak
Journal of Neuroscience Methods, 2006, 154:204-224, 2006 (pdf).

Please cite above paper if you use any part of this code or the example datasets provided.

For a general introduction to the problem of spike sorting, see the following review paper:
Lewicki, M. S. (1998). "A review of methods for spike sorting: the detection and classification of neural action potentials." Network 9(4): R53-78. (pubmed)

Authors and Contact Info

We welcome your feedback, suggestions, improvements etc. Please email urut (-at-) with any queries.

OSort was initially written by Ueli Rutishauser, in collaboration with E.M. Schuman and A.N. Mamelak (all Caltech). The GUI was initially written by Matthew McKinley (MIT). The code is actively maintained by members of the Rutishauser Laboratory.

Everything on this page is Copyright (c) 2004-2018 by the authors. This research has been funded by grants from the Gimbel Discovery Fund and the Howard Hughes Medical Institute (2005-2010), the Cedars-Sinai Medical Center (2012-present), and the NIH under R01MH110831 and U01NS103792.

Posted by ur | on