dralkh/seerai/neuropixels-analysis
Claude Code and agent skill by dralkh/seerai
- community
Checking that the SKILL.md file is still in the repository.
Analyze Neuropixels extracellular recordings end-to-end with SpikeInterface. Covers loading SpikeGLX/Open Ephys/NWB data, preprocessing, drift/motion correction, Kilosort4 (and CPU) spike sorting, quality metrics, and unit curation (threshold-based, model-based UnitRefine, and AI-assisted visual review). Use when working with Neuropixels 1.0/2.0 recordings, spike sorting, or extracellular electrophysiology analysis.
Install
npx vskill@latest install dralkh/seerai/neuropixels-analysisSKILL.md
The same SKILL.md was published earlier as k-dense-ai/scientific-agent-skills/neuropixels-analysis.
Neuropixels Data Analysis
Overview
Toolkit for analyzing Neuropixels high-density neural recordings using current best practices from SpikeInterface, the Allen Institute, and the International Brain Laboratory (IBL). It covers the full workflow from raw data to publication-ready curated units.
All examples use the real SpikeInterface API (spikeinterface.full as si) plus the companion curation module (spikeinterface.curation as sc). The skill ships runnable scripts in scripts/ and a copy-and-edit template in assets/ that implement this workflow directly on top of SpikeInterface — there is no separate package to install beyond the dependencies listed under Installation.
When to Use This Skill
This skill should be used when:
- Working with Neuropixels recordings (
.ap.bin,.lf.bin,.metafiles) - Loading data from SpikeGLX, Open Ephys, or NWB formats
- Preprocessing neural recordings (filtering, common reference, bad-channel detection)
- Detecting and correcting motion/drift
- Running spike sorting (Kilosort4, SpykingCircus2, Mountainsort5, Tridesclous2)
- Computing quality metrics (SNR, ISI violations, presence ratio, amplitude cutoff)
- Curating units (threshold-based, model-based, or AI-assisted)
- Creating visualizations and exporting to Phy or NWB
Supported Hardware & Formats
| Probe | Electrodes | Channels | Notes | |
|---|---|---|---|---|
| Neuropixels 1.0 | 960 | 384 | Use phase_shift for ADC correction | |
| Neuropixels 2.0 (single) | 1280 | 384 | Denser geometry | |
| Neuropixels 2.0 (4-shank) | 5120 | 384 | Multi-region recording |
| Format | Extension | Reader | |
|---|---|---|---|
| SpikeGLX | .ap.bin, .lf.bin, .meta | si.read_spikeglx() | |
| Open Ephys | .continuous, .oebin | si.read_openephys() | |
| NWB | .nwb | si.read_nwb() |
Quick Start
Import and configure parallel processing
Loading data
Full pipeline (bundled script)
The repository ships an end-to-end pipeline built on SpikeInterface:
It performs load → preprocess → drift check → optional motion correction → sorting → postprocessing → quality metrics → curation → export. Read the steps below to run them interactively or customize the pipeline.
Standard Analysis Workflow
1. Preprocessing
Recommended chain, following the SpikeInterface Neuropixels how-to (IBL-style destriping with channel removal + common reference):
Save the preprocessed recording (Kilosort needs a binary file, and it speeds up reuse):
2. Check and correct drift
Always inspect drift before sorting:
Apply correction if needed (presets: rigid_fast, kilosort_like, nonrigid_accurate, nonrigid_fast_and_accurate, dredge, dredge_fast):
3. Spike sorting
Note:run_sorteruses thefolder=argument. The olderoutput_folder=is deprecated.
4. Postprocessing
5. Curation by metric thresholds
For reusable, multi-threshold logic with allen / ibl / strict presets, use the bundled scripts/compute_metrics.py. See references/AUTOMATED_CURATION.md for details and the Bombcell / UnitMatch tools.
6. Model-based curation (UnitRefine)
SpikeInterface can apply pretrained machine-learning classifiers from Hugging Face via the spikeinterface.curation module. The UnitRefine models were trained on real Neuropixels data (V1, SC, ALM):
Each call returns a DataFrame with prediction and probability (confidence) per unit. trust_model=True (or an explicit trusted=[...] list) is required to load the .skops model — only load models from sources you trust. Models trained on other brain areas/datasets may not transfer; validate against a manually labelled subset.
7. AI-assisted curation (for uncertain units)
When running inside an agent such as Cursor or Claude Code, the agent can directly inspect waveform/correlogram plots and give an expert read — no API setup required. Generate plots and ask the agent to assess isolation quality.
For programmatic vision-model access, read API keys from the environment — never hardcode credentials in analysis scripts (they leak into version control and logs):
See references/AI_CURATION.md for the full pattern (rendering a unit summary image, building the prompt, and parsing the response).
8. Export results
Common Pitfalls and Best Practices
- Always check drift before spike sorting — drift > ~10 μm meaningfully degrades quality.
- Use `phase_shift` for Neuropixels 1.0 to correct ADC sampling offsets.
- Save the preprocessed recording with
rec.save(folder=...)to avoid recomputation (Kilosort also needs a binary file). - Use a GPU for Kilosort4 — it is far faster than CPU sorters.
- Review uncertain units — automated/model-based curation is a starting point, not a verdict.
- Combine approaches — thresholds for clear cases, model/AI for borderline units.
- Document thresholds and model repo IDs for reproducibility.
- Export to Phy for critical experiments — human oversight is valuable.
Key Parameters to Adjust
Preprocessing
freq_min: highpass cutoff (300–400 Hz typical)detect_bad_channels: returns(bad_channel_ids, channel_labels)
Motion Correction
preset:nonrigid_fast_and_accurate(balanced),nonrigid_accurate(severe drift),dredge(state of the art)
Spike Sorting (Kilosort4)
batch_size: samples per batch (60000 default)nblocks: drift blocks (increase for long, drifty recordings)Th_universal/Th_learned: detection thresholds (lower = more spikes)
Quality Metrics
snr: signal-to-noise cutoff (3–5 typical)isi_violations_ratio: refractory violations (0.01–0.5)presence_ratio: recording coverage (0.5–0.95)
Bundled Resources
scripts/explore_recording.py
Quick inspection of a recording (streams, channels, duration, bad channels):
scripts/preprocess_recording.py
Automated preprocessing:
scripts/run_sorting.py
Run spike sorting:
scripts/compute_metrics.py
Compute quality metrics and apply curation:
scripts/export_to_phy.py
Export to Phy for manual curation:
scripts/neuropixels_pipeline.py
Complete end-to-end pipeline (see Quick Start).
assets/analysis_template.py
Complete, editable analysis template. Copy and customize:
Detailed Reference Guides
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/neuropixels-analysis/SKILL.md
Popularity
- Repository stars
- 83
- Repository forks
- 5
- 7-day trend score
- 22
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/dralkh/seerai/neuropixels-analysis)