name: spikeinterface description: Unified extracellular electrophysiology workflows for spike sorting, preprocessing, postprocessing, metrics, curation, and visualization. Use when working with Recording/Sorting objects, building SortingAnalyzer pipelines, running sorters, comparing sortings to ground truth, and applying automated/manual curation in SpikeInterface. Keywords: generate_ground_truth_recording, NumpyRecording, load_extractor, create_sorting_analyzer, quality_metrics, run_sorter, compare_sorter_to_ground_truth, apply_curation, threshold_metrics_label_units, plot_traces.
SpikeInterface
SpikeInterface provides a modular API to move from raw extracellular recordings to sorted, analyzed, curated, and visualized units.
Version
Built against: spikeinterface==0.103.3
Python: 3.13.5
Runtime import/execution status in this build:
[UNVERIFIED: install denied in selected environment](seeassets/version.txt).
Environment Gate
Before any install command, confirm environment + permission and record in assets/version.txt:
environment: <env name/path>
python_executable: <path or `python`>
install_permission: yes|no
install_scope: none|current-env|named-env|new-env
package_manager: pip|conda|mamba|uv|other
coverage_profile: workflow|dictionary|hybrid
Current build metadata is already captured in assets/version.txt.
Installation
# Requires install_permission: yes
pip install spikeinterface
# Optional extras are task-dependent and not enforced in this skill build:
# [REQUIRES: sorter-specific external binaries/containers for some spikeinterface.sorters workflows]
# [REQUIRES: plotting backend dependencies for some spikeinterface.widgets backends]
Core I/O and Synthetic Data
import numpy as np
import spikeinterface as si
# tested against spikeinterface==0.103.3
# Build an in-memory recording and query traces
traces = np.random.normal(0, 5, size=(3000, 4)).astype("float32")
rec = si.NumpyRecording([traces], sampling_frequency=30000.0)
print(rec.get_num_channels(), rec.get_num_segments())
# Generate toy ground truth pair
recording, sorting = si.generate_ground_truth_recording(num_channels=4, num_units=6, durations=[2.0], seed=0)
print(recording.get_num_channels(), sorting.get_num_units())
See references/core-io-and-synthetic.md for signatures and pitfalls around NumpyRecording, binary I/O, load_extractor, and synthetic generators.
Preprocessing and Motion
import spikeinterface.preprocessing as spre
import spikeinterface as si
# tested against spikeinterface==0.103.3
recording, _ = si.generate_ground_truth_recording(num_channels=4, durations=[2.0], seed=0)
rec_bp = spre.bandpass_filter(recording, freq_min=300.0, freq_max=6000.0)
print(rec_bp.get_num_channels())
# [VERSION: changed in 0.103.x — unsigned data is not auto-cast; use unsigned_to_signed() explicitly]
See references/preprocessing-and-motion.md for preprocessing pipelines, motion correction entry points, and version-sensitive behavior.
SortingAnalyzer and Metrics
import spikeinterface as si
# tested against spikeinterface==0.103.3
recording, sorting = si.generate_ground_truth_recording(num_channels=4, num_units=8, durations=[3.0], seed=0)
analyzer = si.create_sorting_analyzer(sorting=sorting, recording=recording, format="memory", return_in_uV=True)
analyzer.compute("random_spikes", max_spikes_per_unit=200)
analyzer.compute("waveforms", ms_before=1.0, ms_after=2.0)
qm = analyzer.compute("quality_metrics", metric_names=["snr", "presence_ratio"]).get_data()
print(qm.shape)
# [VERSION: changed in 0.103.x — prefer return_in_uV over return_scaled]
See references/sorting-analyzer-and-metrics.md for extension dependencies, signature details, and metrics workflow patterns.
Running Sorters
import spikeinterface as si
import spikeinterface.sorters as ss
# tested against spikeinterface==0.103.3
recording, _ = si.generate_ground_truth_recording(num_channels=4, durations=[1.0], seed=0)
print("available", ss.available_sorters())
print("installed", ss.installed_sorters())
# [REQUIRES: sorter backends and optional external installations]
# sorting = ss.run_sorter("kilosort2_5", recording, folder="sorter_out", with_output=True)
See references/sorters-and-execution.md for local/container runner signatures and safe execution patterns.
Comparison, Curation, and Widgets
import spikeinterface as si
import spikeinterface.comparison as scmp
import spikeinterface.curation as scur
# tested against spikeinterface==0.103.3
recording, gt_sorting = si.generate_ground_truth_recording(num_channels=4, num_units=6, durations=[2.0], seed=0)
comp = scmp.compare_sorter_to_ground_truth(gt_sorting, gt_sorting, exhaustive_gt=True)
print(comp.count_well_detected_units(well_detected_score=0.8))
analyzer = si.create_sorting_analyzer(gt_sorting, recording, format="memory")
analyzer.compute("random_spikes", max_spikes_per_unit=200)
analyzer.compute("waveforms", ms_before=1.0, ms_after=2.0)
analyzer.compute("templates")
analyzer.compute("noise_levels")
metrics = analyzer.compute("quality_metrics", metric_names=["snr", "presence_ratio"]).get_data()
labels = scur.threshold_metrics_label_units(metrics, thresholds={"snr": (">=", 5)})
print(labels.columns)
See references/comparison-curation-widgets.md for comparison classes, curation model APIs, and widget function aliases.
Verification (Medium+)
python opensci-skill/scripts/verify-snippets.py --root spikeinterface --fail-fast
[UNVERIFIED: verify against installed runtime in an environment where spikeinterface and runtime deps are available].
API Dictionary (Dictionary/Hybrid)
assets/symbol-index.md- module-level dictionary navigationassets/symbol-index.jsonl- machine-readable symbol lookupassets/symbol-cards/- per-module symbol cards with signatures and source anchors
Quick Reference
| Function / Class | Purpose |
|---|---|
NumpyRecording(...) |
Create an in-memory Recording from NumPy arrays. |
generate_ground_truth_recording(...) |
Produce synthetic recording/sorting pairs for testing and tutorials. |
create_sorting_analyzer(...) |
Pair recording+sorting and orchestrate extension computations. |
run_sorter(...) |
Execute a sorter backend (local or container depending on config). |
compare_sorter_to_ground_truth(...) |
Score sorter output against reference sorting. |
threshold_metrics_label_units(...) |
Apply metric thresholds to produce curation labels. |
Module Map
| Submodule | Contents | Notes |
|---|---|---|
spikeinterface.core |
Base recording/sorting classes, I/O, synthetic generation, sorting analyzer | large API surface |
spikeinterface.preprocessing |
Filtering, scaling, bad-channel handling, motion correction, pipeline API | mixed eager export + deprecation __getattr__ |
spikeinterface.sorters |
Sorter registry and execution wrappers | external tool dependencies for many sorters |
spikeinterface.metrics |
Quality/template/spiketrain metrics via analyzer extensions | top-level star exports |
spikeinterface.comparison |
Pairwise and multi-sorter comparisons | agreement/confusion/performance tooling |
spikeinterface.curation |
Merge/split/threshold/model-based curation helpers | model workflows use pydantic/skops integrations |
spikeinterface.widgets |
Plotting widgets + plot_* aliases |
backend-dependent behavior |
Import style: mixed (eager star imports in several __init__.py, plus lazy/deprecation __getattr__ in extractors and preprocessing).
See assets/module-map.md for full submodule inventory.
References
references/core-io-and-synthetic.md- in-memory/binary I/O and synthetic data generation.references/preprocessing-and-motion.md- preprocessing wrappers, pipelines, and motion correction.references/sorting-analyzer-and-metrics.md- analyzer lifecycle, extension dependencies, metrics retrieval.references/sorters-and-execution.md- sorter registry, local/container execution, and result loading.references/comparison-curation-widgets.md- comparison classes, curation APIs, and plotting aliases.