Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Neuropixels neural recording analysis. Load SpikeGLX/OpenEphys data, preprocess, motion correction, Kilosort4 spike sorting, quality metrics, Allen/IBL curation, AI-assisted visual analysis, for Neuropixels 1.0/2.0 extracellular electrophysiology. Use when working with neural recordings, spike sorting, extracellular electrophysiology, or when the user mentions Neuropixels, SpikeGLX, Open Ephys, Kilosort, quality metrics, or unit curation.
.claude/skills/neuropixels-analysis/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-21 | ✗→✓ | ▲ Improved | — | — |
| case-22 | ✗→✓ | ▲ Improved | — | — |
| case-10 | ✗→✓ | ▲ Improved | — | — |
| case-09 | ✗→✓ | ▲ Improved | — | — |
| case-08 | ✗→✓ | ▲ Improved | — | — |
Comprehensive toolkit for analyzing Neuropixels high-density neural recordings using current best practices from SpikeInterface, Allen Institute, and International Brain Laboratory (IBL). Supports the full workflow from raw data to publication-ready curated units.
This skill should be used when:
| Probe | Electrodes | Channels | Notes | |-------|-----------|----------|-------| | Neuropixels 1.0 | 960 | 384 | Requires phase_shift 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() |
pythonimport spikeinterface.full as si import neuropixels_analysis as npa # Configure parallel processing job_kwargs = dict(n_jobs=-1, chunk_duration='1s', progress_bar=True)
python# SpikeGLX (most common) recording = si.read_spikeglx('/path/to/data', stream_id='imec0.ap') # Open Ephys (common for many labs) recording = si.read_openephys('/path/to/Record_Node_101/') # Check available streams streams, ids = si.get_neo_streams('spikeglx', '/path/to/data') print(streams) # ['imec0.ap', 'imec0.lf', 'nidq'] # For testing with subset of data recording = recording.frame_slice(0, int(60 * recording.get_sampling_frequency()))
python# Run full analysis pipeline results = npa.run_pipeline( recording, output_dir='output/', sorter='kilosort4', curation_method='allen', ) # Access results sorting = results['sorting'] metrics = results['metrics'] labels = results['labels']
python# Recommended preprocessing chain rec = si.highpass_filter(recording, freq_min=400) rec = si.phase_shift(rec) # Required for Neuropixels 1.0 bad_ids, _ = si.detect_bad_channels(rec) rec = rec.remove_channels(bad_ids) rec = si.common_reference(rec, operator='median') # Or use our wrapper rec = npa.preprocess(recording)
python# Check for drift (always do this!) motion_info = npa.estimate_motion(rec, preset='kilosort_like') npa.plot_drift(rec, motion_info, output='drift_map.png') # Apply correction if needed if motion_info['motion'].max() > 10: # microns rec = npa.correct_motion(rec, preset='nonrigid_accurate')
python# Kilosort4 (recommended, requires GPU) sorting = si.run_sorter('kilosort4', rec, folder='ks4_output') # CPU alternatives sorting = si.run_sorter('tridesclous2', rec, folder='tdc2_output') sorting = si.run_sorter('spykingcircus2', rec, folder='sc2_output') sorting = si.run_sorter('mountainsort5', rec, folder='ms5_output') # Check available sorters print(si.installed_sorters())
python# Create analyzer and compute all extensions analyzer = si.create_sorting_analyzer(sorting, rec, sparse=True) analyzer.compute('random_spikes', max_spikes_per_unit=500) analyzer.compute('waveforms', ms_before=1.0, ms_after=2.0) analyzer.compute('templates', operators=['average', 'std']) analyzer.compute('spike_amplitudes') analyzer.compute('correlograms', window_ms=50.0, bin_ms=1.0) analyzer.compute('unit_locations', method='monopolar_triangulation') analyzer.compute('quality_metrics') metrics = analyzer.get_extension('quality_metrics').get_data()
python# Allen Institute criteria (conservative) good_units = metrics.query(""" presence_ratio > 0.9 and isi_violations_ratio < 0.5 and amplitude_cutoff < 0.1 """).index.tolist() # Or use automated curation labels = npa.curate(metrics, method='allen') # 'allen', 'ibl', 'strict'
When using this skill with Claude Code, Claude can directly analyze waveform plots and provide expert curation decisions. For programmatic API access:
pythonfrom anthropic import Anthropic # Setup API client client = Anthropic() # Analyze uncertain units visually uncertain = metrics.query('snr > 3 and snr < 8').index.tolist() for unit_id in uncertain: result = npa.analyze_unit_visually(analyzer, unit_id, api_client=client) print(f"Unit {unit_id}: {result['classification']}") print(f" Reasoning: {result['reasoning'][:100]}...")
Claude Code Integration: When running within Claude Code, ask Claude to examine waveform/correlogram plots directly - no API setup required.
python# Generate comprehensive HTML report with visualizations report_dir = npa.generate_analysis_report(results, 'output/') # Opens report.html with summary stats, figures, and unit table # Print formatted summary to console npa.print_analysis_summary(results)
python# Export to Phy for manual review si.export_to_phy(analyzer, output_folder='phy_export/', compute_pc_features=True, compute_amplitudes=True) # Export to NWB from spikeinterface.exporters import export_to_nwb export_to_nwb(rec, sorting, 'output.nwb') # Save quality metrics metrics.to_csv('quality_metrics.csv')
rec.save(folder='preprocessed/')freq_min: Highpass cutoff (300-400 Hz typical)detect_threshold: Bad channel detection sensitivitypreset: 'kilosort_like' (fast) or 'nonrigid_accurate' (better for severe drift)batch_size: Samples per batch (30000 default)nblocks: Number of drift blocks (increase for long recordings)Th_learned: Detection threshold (lower = more spikes)snr_threshold: Signal-to-noise cutoff (3-5 typical)isi_violations_ratio: Refractory violations (0.01-0.5)presence_ratio: Recording coverage (0.5-0.95)Automated preprocessing script:
bashpython scripts/preprocess_recording.py /path/to/data --output preprocessed/
Run spike sorting:
bashpython scripts/run_sorting.py preprocessed/ --sorter kilosort4 --output sorting/
Compute quality metrics and apply curation:
bashpython scripts/compute_metrics.py sorting/ preprocessed/ --output metrics/ --curation allen
Export to Phy for manual curation:
bashpython scripts/export_to_phy.py metrics/analyzer --output phy_export/
Complete analysis template. Copy and customize:
bashcp assets/analysis_template.py my_analysis.py # Edit parameters and run python my_analysis.py
Detailed step-by-step workflow with explanations for each stage.
Quick function reference organized by module.
Comprehensive visualization guide for publication-quality figures.
| Topic | Reference | |-------|-----------| | Full workflow | reference/standard_workflow.md | | API reference | reference/api_reference.md | | Plotting guide | reference/plotting_guide.md | | Preprocessing | PREPROCESSING.md | | Spike sorting | SPIKE_SORTING.md | | Motion correction | MOTION_CORRECTION.md | | Quality metrics | QUALITY_METRICS.md | | Automated curation | AUTOMATED_CURATION.md | | AI-assisted curation | AI_CURATION.md | | Waveform analysis | ANALYSIS.md |
bash# Core packages pip install spikeinterface[full] probeinterface neo # Spike sorters pip install kilosort # Kilosort4 (GPU required) pip install spykingcircus # SpykingCircus2 (CPU) pip install mountainsort5 # Mountainsort5 (CPU) # Our toolkit pip install neuropixels-analysis # Optional: AI curation pip install anthropic # Optional: IBL tools pip install ibl-neuropixel ibllib
project/
├── raw_data/
│ └── recording_g0/
│ └── recording_g0_imec0/
│ ├── recording_g0_t0.imec0.ap.bin
│ └── recording_g0_t0.imec0.ap.meta
├── preprocessed/ # Saved preprocessed recording
├── motion/ # Motion estimation results
├── sorting_output/ # Spike sorter output
├── analyzer/ # SortingAnalyzer (waveforms, metrics)
├── phy_export/ # For manual curation
├── ai_curation/ # AI analysis reports
└── results/
├── quality_metrics.csv
├── curation_labels.json
└── output.nwb| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-12 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-13 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-15 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-18 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-21 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-22 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-07 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-10 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-09 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-08 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-01 | pass→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-06 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-17 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-03 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-04 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-02 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-20 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-16 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-19 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-14 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-05 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-11 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted, and 19 counted toward the lift figure. The other 3 produced results that are not comparable between the two arms, so they are excluded from the headline rather than averaged into it. The headline lift of +45 percentage points is the difference between those two pass rates over the 19 comparable cases.
The per-case answers from this run were removed by the retention sweep, so the case table below shows the verdicts without the text either arm produced. The counts above were recorded at the time and are unaffected. Answers are now kept for 180 days.
Other measured skills in the registry, with their headline benchmark lift.