toolkit module includes tools to process SI objects throughout your analysis.
toolkit.preprocessing sub-module includes preprocessing steps to apply before spike sorting.
Preprocessors are lazy, meaning that no computation is performed until it is required (usually at the spike sorting
step). This enables one to build preprocessing chains to be applied in sequence to a
This is possible because each preprocessing step returns a new
RecordingExtractor that can be input to the next
step in the chain.
In this code example, we build a preprocessing chain with 2 steps:
common median reference (CMR)
import spikeinterface.toolkit as st # recording is a RecordingEctractor object recording_f = st.bandpass_filter(recording, freq_min=300, freq_max=6000) recording_cmr = st.common_reference(recording_f, operator="median")
After preprocessing, we can optionally save the processed recording with the efficient SI
recording_saved = recording_cmr.save(folder="preprocessed", n_jobs=8, total_memory="2G")
In this case, the
save() function will process in parallel our original recording with the bandpass filter and
CMR and save it to a binary file in the “preprocessed” folder. The
recording_saved is yet another
RecordignExtractor which maps directly to the newly created binary file, for very quick access.
After spike sorting, we can use the
toolkit.postprocessing sub-module to further post-process the spike sorting
output. Most of the post-processing functions require a
WaveformExtractor as input. Available postprocessing
compute principal component scores
compute template similarity
compute template waveform metrics
get amplitudes for each spikes
compute auto- and cross-correlogram
Quality metrics allows to quantitatively assess to goodness of a spike sorting output. The
toolkit.qualitymetrics sub-module includes functions to compute a large variety of available metrics
(‘sort’ - spike times based; ‘rec+sort’ - based on waveforms; ‘pc’ - based on PC scores):
firing rate (sort)
ISI violation ratio (sort)
For more information about quality metrics, check out this excellent documentation from the Allen Institute.