Python toolkit for analysis, visualization, and comparison of spike sorting output
Project description
Alpha Development Version 0.3.7
SpikeToolkit
SpikeToolkit is a module that was designed to make running, curating, evaluating, and comparing popular spike sorting algorithms as simple as possible.
Its tools and functions are built using spikeextractors objects, allowing for straightforward, standardized analysis and sorting.
Getting Started
To get started with SpikeToolkit, you can install it with pip:
pip install spiketoolkit
You can also install SpikeToolkit locally by cloning the repo into your code base. If you install SpikeToolkit locally, you need to run the setup.py file.
git clone https://github.com/SpikeInterface/spiketoolkit.git
cd spiketoolkit
python setup.py install
Documentation
The documentation page can be found here: https://spiketoolkit.readthedocs.io/en/latest/
Basic usage
Run spike sorting algorithms
To run spike sorting algorithm, a RecordingExtractor
object needs to be instantiated using the spikeextractors
package
Each spike sorting algorithm must be installed separately. If one of the sorters you are trying to use is not installed, an error message detailing the installation procedure is thrown. Below is a list of sorters that we have made compatible with SpikeInterface:
Although we have implemented many popular sorting algorithms, this is not an exhaustive list. Implementing new spike sorting algorithms in SpikeToolkit, however, is straightforward so we expect this list to grow in future versions.
SpikeToolkit is designed to make the spike sorting procedure painless and easy. In the following example, 4 spike sorters (Mountainsort, Spyking Circus, Kilosort and Tridesclous) are run with default parameters on the same Open Ephys recordings.
import spikeextractors as se
import spiketoolkit as st
# load recording using spikeextractors (e.g. Open Ephys recording)
recording = se.OpenEphysRecordingExtractor('path-to-open-ephys-folder')
# run spike sorters (with default parameters)
sorting_MS = st.sorters.run_mountainsort4(recording)
sorting_SC = st.sorters.run_spykingcircus(recording)
sorting_KS = st.sorters.run_kilosort(recording')
sorting_TDC = st.sorters.run_tridesclous(recording)
The ability to run each sorter generically is a consequence of the object-oriented approach to spike sorting that SpikeToolkit implements behind the scenes. To run each sorter in an object-oriented way (so parameters are easily exposed), one can run a sorter like this,
ms4 = st.sorters.Mountainsort4Sorter(recording=recording)
ms4.run()
sorting_MS = ms4.get_result()
where the parameters can be easily be viewed before running with,
print(ms4.params)
which returns,
{'detect_sign': -1,
'adjacency_radius': -1,
'freq_min': 300,
'freq_max': 6000,
'filter': False,
'curation': True,
'whiten': True,
'clip_size': 50,
'detect_threshold': 3,
'detect_interval': 10,
'noise_overlap_threshold': 0.15}
For another example on running sorters, please see this example from the examples repo. In it, we show how to run several spike sorters on a toy dataset.
Curating spike sorting outputs
Manual curation of spike sorting outputs is recommended for all algorithms. This includes visually inspecting the spike waveforms, correlograms, and clusters of each unit found in the recording.
With SpikeToolit you can export any sorting output to the phy template-gui, manually curate the data, and re-import the curated sorting output:
# esport Mountainsort output to Phy template-gui
st.postprocessing.export_to_phy(recording, sorting_MS)
# curate the data running: phy template-gui path-to-exported-params.py
# reimport curated sorting output
sorting_MS_curated = se.PhySortingExtractors('path-to-created-phy-folder')
Compare sorting outputs
SpikeToolkit is designed to make spike sorting comparison and evaluation easy and straightforward. Using the sorting_MS
, sorting_SC
, and sorting_SC
output from the previous section, one can run pairwise comparisons:
comparison_MS_SC = st.comparison.compare_two_sorters(sorting_MS, sorting_SC)
The compare_two_sorters
function finds best matching units based on the fraction of matched spikes. Units that are not matched to any other unit are assigned to -1.
Alternatively, one can run a multi-sorting comparison that finds units in agreement amongst multiple spike sorters:
multi_comparison = st.comparison.compare_multiple_sorters([sorting_MS, sorting_SC, sorting_KS])
# extract units shared among all 3 spike sorting outputs
agreement_sorting = multi_comparison.get_agreement_sorting(minimum_match=3)
Interactive Example
To experiment with RecordingExtractors, SortingExtractors, and their associated tools, in a pre-installed environment, we have provided a Collaborative environment. If you click on the link and then click on "Open in Collab", you can run the notebook and try out the features of and tools for SpikeInterface.
Run test
pytest
Authors
Alessio Paolo Buccino - Center for Inegrative Neurolasticity (CINPLA), Department of Biosciences, Physics, and Informatics, University of Oslo, Oslo, Norway
Cole Hurwitz - The Institute for Adaptive and Neural Computation (ANC), University of Edinburgh, Edinburgh, Scotland
Jeremy Magland - Center for Computational Biology (CCB), Flatiron Institute, New York, United States
Matthias Hennig - The Institute for Adaptive and Neural Computation (ANC), University of Edinburgh, Edinburgh, Scotland
Samuel Garcia - Centre de Recherche en Neuroscience de Lyon (CRNL), Lyon, France
For any correspondence, contact Alessio Buccino at alessiop.buccino@gmail.com
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file spiketoolkit-0.3.4.tar.gz
.
File metadata
- Download URL: spiketoolkit-0.3.4.tar.gz
- Upload date:
- Size: 59.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 809fa54643388a850454daee7754aaceae088649c7a21208932a879f346cf65c |
|
MD5 | 6b37731f58518a58ee964b7cf61d2441 |
|
BLAKE2b-256 | c77e3379165bb839fd0f53862cb83e1b8fab1919979fb75b07c32b886a74ee3f |