si_npx_brainstem: unit curation model for Neuropixels 2.0 brainstem recordings
A SpikeInterface curation model that labels each sorted unit as sua (single unit), mua (multi-unit) or noise, from the standard quality and template metrics SpikeInterface computes. It was trained on 15,742 curated units from mouse brainstem recordings with 4-shank Neuropixels 2.0 probes.
What it does, and what it does not
The model is the first step of a larger curation workflow (figure, blue box): it labels each unit, one at a time, from its metrics. The rest of that workflow is code in the project's repository, not part of this model, because it edits spike trains and needs the recording and a person:
- merging units that the sorter split, each merge tested against a refractory-violation ceiling;
- repairing "spike swaps", where after a sudden brain movement the sorter briefly gives one unit's spikes to a neighbour;
- removing misassigned spikes from near-single units;
- flags for ringing artefacts and non-somatic units;
- expert review pages, whose verdicts feed back into the next run.
Applying this model alone gives you a label per unit: no merges, no spike-level repairs, no review.
How to use it
import spikeinterface.full as si
from spikeinterface.curation import model_based_label_units
analyzer = si.load_sorting_analyzer("path/to/analyzer")
analyzer.compute(["noise_levels", "random_spikes", "waveforms", "templates", "spike_amplitudes",
"principal_components", "spike_locations", "quality_metrics", "template_metrics"])
labels = model_based_label_units(analyzer, repo_id="Tnesniv/si_npx_brainstem", trust_model=True)
# one row per unit: prediction (sua / mua / noise) and probability
The model uses 49 metrics: SpikeInterface's quality metrics (SNR, ISI and refractory violations, presence
ratio, amplitude cutoff and spread, drift, isolation distance, L-ratio, d-prime, nearest-neighbour hit and
miss rates, silhouette, synchrony, ...) and template metrics (peak and trough shapes, widths and ratios,
repolarization and recovery slopes, spatial spread, exponential decay, propagation velocities, baseline
flatness). model_info.json lists them with the parameters used; model_based_label_units warns if yours
differ.
Reproducing the full curation
The edits the workflow makes (merges, spike-swap repairs, removal of misassigned spikes, rejected units and
the final sua / mua labels) are also exported, for every shank group, in SpikeInterface's curation format
(a SequentialCuration). Applied with apply_curation(original_sorting, curation, censor_ms=None) to the
sorter's original output, they rebuild the curated sortings exactly (checked: 8,030 of 8,030 units identical).
Units that had to be split get new ids; an id map gives the curated product's id for each. One expert edit
that realigned spike times cannot be expressed in this format and is left out.
Training data
| Species | mouse (Mus musculus), 6 animals |
| Brain area | brainstem: intermediate and parvocellular reticular nuclei (IRt, PCRt) and neighbouring medullary nuclei; some sites in vestibular nuclei and cerebellum |
| Probe | IMEC Neuropixels 2.0, 4 shanks |
| Recordings | 35 probe recordings, 140 shank groups, during licking and chewing |
| Sorting | Kilosort 4.1.7 through the AIND ephys pipeline v1.3.0, one sorting per shank |
| Units | 15,742: 2,692 sua, 5,572 mua, 7,478 noise |
Where the labels come from. Each unit's label is the decision of the project's curation workflow (figure), version 3. That workflow labels units with a classifier first trained on a vision-model reference curation, then applies rules (for example a noise override for units whose interval histograms are irregular), and an expert reviewed the doubtful cases (ringing artefacts, low-SNR single units, merges, spike swaps) and fixed those labels. Most labels were therefore made by the workflow and only part of them were checked by a person. The model reproduces this project's curation; it is not independent ground truth.
Performance
Trained on 5 animals and tested on the 6th, for each animal in turn:
| Held-out animal | Units | Accuracy | Balanced accuracy |
|---|---|---|---|
| LO_02 | 960 | 0.873 | 0.838 |
| LO_03 | 478 | 0.847 | 0.776 |
| LO_04 | 1,718 | 0.878 | 0.883 |
| LO_05 | 1,512 | 0.844 | 0.792 |
| LO_06 | 2,534 | 0.835 | 0.827 |
| LO_07 | 8,540 | 0.862 | 0.829 |
| All, pooled | 15,742 | 0.858 | 0.840 |
Confusion, all held-out predictions pooled (rows: label, columns: prediction):
| sua | mua | noise | |
|---|---|---|---|
| sua | 2,104 | 573 | 15 |
| mua | 276 | 4,682 | 614 |
| noise | 91 | 666 | 6,721 |
Most errors are between neighbouring classes: about a fifth of single units are called mua (a conservative error), and mua and noise are confused at their border. Single units and noise are rarely confused (15 and 91 of 15,742).
These numbers are for a random forest with the same features but fixed settings; the published model is the
best of SpikeInterface's train_model search on all 6 animals (random forest, balanced accuracy 0.864 on
its internal 20% test split, model_accuracies.csv).
Limitations
- Trained on one probe type, one brain region, one sorter and one lab's curation. Not validated on other probes, regions or sorters; check it against your own curation before relying on it.
- The sua / mua border follows this project's criteria, which are conservative.
- Non-somatic (axonal) units are not modelled.
- The metrics must be computed the way
model_info.jsonlists; different parameters shift the inputs.
Files
best_model.skops: the trained scikit-learn pipeline (median imputation, standard scaling, random forest).model_info.json: metric names and parameters, label conversion, package versions (SpikeInterface 0.105.0, scikit-learn 1.7.2).training_data.csv,labels.csv: the training set (metrics per unit; labels as 0 = mua, 1 = noise, 2 = sua).model_accuracies.csv: thetrain_modelsearch results.metadata.json: species, brain areas, probes.
Authors
Vincent Prevosto, MIT, 2026.
