Skip to content

Add HIPPIE optional dependency for neuron cell-type classification #120

Open
JesusGF1 wants to merge 5 commits into
mainfrom
hippie-integration
Open

Add HIPPIE optional dependency for neuron cell-type classification #120
JesusGF1 wants to merge 5 commits into
mainfrom
hippie-integration

Conversation

@JesusGF1
Copy link
Copy Markdown

Integrates https://github.com/braingeneers/HIPPIE as an optional SpikeLab dependency (pip install spikelab[hippie]) that lets users classify neurons into cell types using a pretrained multimodal cVAE, or train their own VAE for data compression.

What's new

  • spikelab/spikedata/hippie_adapter.py — public API: extract_features(), classify_neurons(), train_vae_on_spikedata(), compress_neurons(). All imports are lazy so base SpikeLab installs are unaffected.
  • pyproject.toml — new [hippie] optional extras group pulling in HIPPIE, torch, umap-learn, hdbscan, huggingface-hub.
  • MCP tools — three new tools in analysis.py + server.py: classify_neurons_hippie, train_vae_hippie, compress_neurons_hippie, all workspace-aware.
  • Tests — 13 pytest tests in tests/test_hippie_adapter.py; all skip cleanly if spikelab[hippie] is not installed (CI safe).
  • Docs — full pipeline guide (hippie_classification.rst) covering three Neuropixels entry points (Kilosort+bin, NWB, pre-computed waveforms) plus agent prompt reference.
  • Bug fix — NWB loader: clear partial spike-train list when pynwb fails mid-loop before h5py fallback, preventing a train/attribute count mismatch.

JesusGF1 and others added 5 commits April 26, 2026 17:45
Integrates the pretrained HIPPIE multimodal model (Jesusgf23/hippie on
HuggingFace) as an optional spikelab[hippie] extra. Neurons are encoded
via waveform + ISI + autocorrelogram into a 30-D latent space, then
visualised with UMAP and clustered with HDBSCAN.

Changes:
- spikedata/hippie_adapter.py: feature extraction from SpikeData and
  full classify_neurons() pipeline
- mcp_server/tools/analysis.py: classify_neurons_hippie() async tool
- mcp_server/server.py: tool schema and _TOOL_DISPATCH entry
- pyproject.toml: hippie optional extra (torch, hf-hub, umap-learn, hdbscan)
- tests/test_hippie_adapter.py: 13 unit tests, skipped without hippie
- docs/guides/hippie_classification.rst: full pipeline guide covering
  Kilosort+raw-bin (Path A), NWB (Path B), pre-computed waveforms (Path C),
  MCP agent prompts, and known MCP per-unit waveform limitation
- docs/guides/hippie_changes.md: codebase change schematic

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Extends the HIPPIE integration with a self-supervised data compression
path for users without cell-type or technology labels.

Changes:
- hippie_adapter.py: train_vae_on_spikedata() and compress_neurons()
- analysis.py: train_vae_hippie() and compress_neurons_hippie() MCP tools
- server.py: tool schemas and dispatch entries for both new tools
- hippie_classification.rst: new "Unsupervised VAE compression" section
  with Python, direct-API, and MCP agent examples and a comparison table
  against the pretrained classifier

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Documents copy-paste prompts for running pretrained HIPPIE classifier
and unsupervised VAE compression via the SpikeLab MCP server across
all three Neuropixels pipeline entry points.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
When pynwb appended one or more spike trains before raising an exception,
the h5py fallback path would add its own full set of trains on top, causing
a train/attribute count mismatch.  Clear both lists in the except branch so
h5py starts from a clean slate.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant