SeqPeelSort
SeqPeelSort: a spike sorting algorithm for single sensillum recordings - Published in JOSS (2018)
Science Score: 93.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 1 DOI reference(s) in JOSS metadata -
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
✓JOSS paper metadata
Published in Journal of Open Source Software
Repository
A spike sorting algorithm for single sensillum recordings
Basic Info
- Host: GitHub
- Owner: grg2rsr
- License: mit
- Language: Python
- Default Branch: master
- Size: 37.7 MB
Statistics
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
- Releases: 1
Metadata Files
README.md
SeqPeelSort
A spike sorting algorithm for single sensillum recordings
Author
Georg Raiser, University of Konstanz, Dept. Neurobiology, grg2rsr@gmail.com
Summary
SeqPeelSort is a spike sorting algorithm for single sensillum recordings (SSR).
Single sensillum recordings are a standard technique in insect neuroscience. In such electrophysiological recordings, a single electrode is inserted into a sensory sensillum, and the transepithelial potential is recorded. This technique is extensively (but not only) used in Drosophila olfaction studies (see for example Hallem et al. (2004) or Lin et al. (2015) and citations therein).
Since insect olfactory sensilla can house multiple sensory neurons, the action potentials of all those neurons are recorded with the single electrode simultaneously. The individual units usually display different spike shapes and amplitudes. Additionally, the spike amplitude of some units is substantially decreased when the unit exhibits a high firing rate.
As any spike sorting algorithm, SeqPeelSorts goal is to detect spikes and based on their waveform, assign them to a unit. Different to most recording situations for which current spike sorting algorithms are designed, the recording configuration of SSR leads to specific constrains: The number of electrodes is only one, the number of units is known and low, but their spike shapes are quite variable. SeqPeelSort is designed handle these specific constrains while being lightweight and simple.
Installation
Install Anaconda
Anaconda is a package managing software for python. Download and install Anaconda for your operating system. SeqPeelSort will use python 3, but it doesn't matter which Anaconda version you install (recommended is 3).
create a python environment
the env subfolder contains a conda environment file that you can use to create a environment with all required packages. Do do so, open a terminal and in the subfolder env type:
Linux/Mac:
shell
conda env create -f SeqPeelSort.yml -n SeqPeelSort
Windows:
shell
conda env create -f SeqPeelSort_win.yml -n SeqPeelSort
afterwards, activate the environment (linux/mac: source activate SeqPeelSort, windows: activate SeqPeelSort).
More on managing anaconda environments can be found in the official docs or this blog post
Install the latest neo version
Note: this is only required until neo==0.7 is available via pip.
in src/neo:
+ pip uninstall neo because elephant installs neo==0.6
+ python setup.py develop
Usage
Data format
SeqPeelSort is build around the python electrophysiology packages neo and elephant. As its data format, it uses the Nix format for electrophysiological data.
The input file is a .nix file containing a Block with one or more Segments (a detailed explanation of the terms can be found here). If the Block consists of several Segments, they are considered to be individual trials and sorting is restricted to those, which speeds up processing and limits consumed memory substantially.
An example conversion function for converting Spike2 .smr files to a .nix file can be found in examples/smr2nix.py. Additional converters can be written upon request, if the data format can be handled by neo.io. Contact me and provide an example recording.
Configuration file
This files specifies the settings and parameters used for the spike sorting. Description of the individual parameters can be found in the example configuration file: examples/example_config.ini.
Example usage
- Download an example recording in the
.smrformat into the subfolderexamples. - Convert the
.smrfile to a.nixfile. To do so, runpython smr2nix.py example.smr. The filesmr2nix.pycontains an example conversion function, that can serve as a template for own data converters. - Run SeqPeelSort on the
.nixfile:python SeqPeelSort.py ../examples/example_config.ini. Theinifile contains the path to the data. - The output is a
.nixfile namedexample_sorted.nixthat contains the sorted spike trains. Alternatively, the output can be written in the.csvformat, which generates a separate file for each unit/segment combination containing the time stamps of the sorted spikes. - The subfolder
plotscontains diagnostic plots of relevant computations of the algorithm (detailed below).
A more detailed usage is provided in the USAGE.md, along with a description of the settable parameters of the algorithm.
Algorithm details
SeqPeelSort is a template matching based spike sorter. Generally, a distribution of templates for each unit is generated, and the waveform of the best fitting template is subtracted from the recording in an iterative manner.
In detail, the following steps are applied:
- median absolute derivation based thresholding to detect all spikes
- sorting the detected spikes to units based on thresholding by user specified bounds
- estimating the decrease of spike amplitude at high firing rates for each unit
- calculation of time variable adaptive thresholds based on the estimated decrease
- resorting to units based on this adaptive thresholds
- extracting spike waveforms (templates) based on the detected spikes of step 5.
- performing a PCA on the templates from step 6., kicking outlier templates, and inverse PCA to generate simulated templates
Then, an iterative detecting and removing spikes ("peeling") loop starts with the unit of the largest amplitude:
- using the simulated templates for template matching - resulting in a distribution of scores for each time point
- reducing the distribution to a single value for each time point at a fixed percentile level
- thresholding this time varying score, resulting in a new spike detection
- based on these detected spike times and the best fitting template, a artificial voltage time series is generated and subtracted from the original recording.
the above steps above are then applied to the next smaller unit, using the "peeled" voltage for the next template matching step.
Community Guidelines for future development
Expanding IO options based on users needs
Currently, more IO options are needed, but those would be added on a user by user basis. If you are willing to write an conversion from a data format to the .nix, have a look at the smr2nix.py file as a template.
Multithreaded template matching
In order to increase performance, the template matching step could be taken to a multithreaded computation. If you are interested in developing this, drop me a line - I have a semaphore based approach for a previous of the algorithm than can probably be adopted with not much effort.
References
Hallem, E. A., Ho, M. G., & Carlson, J. R. (2004). The molecular basis of odor coding in the Drosophila antenna. Cell, 117(7), 965-979.
Lin, C. C., & Potter, C. J. (2015). Re-classification of Drosophila melanogaster trichoid and intermediate sensilla using fluorescence-guided single sensillum recording. PloS one, 10(10), e0139675.
Owner
- Name: Georg Raiser
- Login: grg2rsr
- Kind: user
- Location: Lisbon, Portugal
- Company: Champalimaud Research
- Repositories: 6
- Profile: https://github.com/grg2rsr
JOSS Publication
SeqPeelSort: a spike sorting algorithm for single sensillum recordings
Tags
Neuroscience Olfaction Electrophysiology Single sensillum recordingsGitHub Events
Total
Last Year
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 8
- Total pull requests: 0
- Average time to close issues: 24 days
- Average time to close pull requests: N/A
- Total issue authors: 2
- Total pull request authors: 0
- Average comments per issue: 0.5
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- grg2rsr (6)
- nirum (2)
