K-Dense-AI/scientific-agent-skills / skills/neuropixels-analysis
neuropixels-analysis
VerifiedAnalyzes 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.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 19.7 KB |
| assets/analysis_template.py | script | 9.3 KB |
| references/AI_CURATION.md | markdown | 6.4 KB |
| references/ANALYSIS.md | markdown | 11.1 KB |
| references/AUTOMATED_CURATION.md | markdown | 6.3 KB |
| references/MOTION_CORRECTION.md | markdown | 4.6 KB |
| references/PREPROCESSING.md | markdown | 4.8 KB |
| references/QUALITY_METRICS.md | markdown | 6.2 KB |
| references/SPIKE_SORTING.md | markdown | 5.8 KB |
| references/api_reference.md | markdown | 7.9 KB |
| references/plotting_guide.md | markdown | 11.7 KB |
| references/standard_workflow.md | markdown | 9.9 KB |
| scripts/_common.py | script | 2.7 KB |
| scripts/compute_metrics.py | script | 5.5 KB |
| scripts/explore_recording.py | script | 5.7 KB |
| scripts/export_to_phy.py | script | 2.6 KB |
| scripts/neuropixels_pipeline.py | script | 12.5 KB |
| scripts/preprocess_recording.py | script | 4.7 KB |
| scripts/run_sorting.py | script | 2.7 KB |
scripts/_common.py
View on GitHub"""Recording contracts shared by the bundled Neuropixels commands."""
from pathlib import Path
import numpy as np
import spikeinterface.full as si
def load_saved(path, child):
"""Accept an extractor folder or a bundled command's output parent."""
path = Path(path)
return si.load(path / child if (path / child).is_dir() else path)
def validate_recording(recording):
"""These commands process one continuous, calibrated probe recording."""
if recording.get_num_segments() != 1:
raise ValueError("Select one recording segment before using this command; preserve its time origin.")
fs = recording.get_sampling_frequency()
if not np.isfinite(fs) or fs <= 0 or recording.get_num_samples() == 0:
raise ValueError("Recording must have samples and a positive finite sampling frequency.")
locations = recording.get_channel_locations()
if locations.shape[0] != recording.get_num_channels() or not np.isfinite(locations).all():
raise ValueError("Every channel needs a finite location in micrometers.")
if np.unique(locations, axis=0).shape[0] != len(locations):
raise ValueError("Channel locations must be unique; verify shank geometry and channel mapping.")
if not recording.has_scaleable_traces():
raise ValueError("Recording needs calibrated gain_to_uV/offset_to_uV before amplitude analysis.")
def apply_phase_correction(recording):
"""Use recorded ADC offsets, never infer them from a probe-generation label."""
shifts = recording.get_property('inter_sample_shift')
if shifts is None or not np.isfinite(shifts).all():
raise ValueError("Missing inter_sample_shift metadata; verify ADC timing or explicitly skip phase correction.")
return si.phase_shift(recording)
def reference_by_shank(recording):
"""Median reference each shank using contact-to-device indices, not channel IDs."""
probe = recording.get_probe() # Deliberately requires a single attached probe.
indices = np.asarray(probe.device_channel_indices)
if sorted(indices.tolist()) != list(range(recording.get_num_channels())):
raise ValueError("Probe device-channel mapping must cover the selected channels exactly once.")
if probe.shank_ids is None:
raise ValueError("Missing probe shank_ids; annotate the verified shank assignment before referencing.")
shanks = np.asarray(probe.shank_ids)
groups = [recording.channel_ids[indices[shanks == shank]].tolist() for shank in np.unique(shanks)]
if any(len(group) < 2 for group in groups):
raise ValueError("Median reference needs at least two retained channels on every shank.")
return si.common_reference(recording, operator='median', reference='global', groups=groups)
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementation | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirements | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallback | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |