Skip to content

fix: resolve NP2004 probe model correctly from SpikeGLX metadata - #2

Merged
tabedzki merged 1 commit into
mainfrom
tabedzki/fix/np2004-probe-model-resolution
Aug 11, 2026
Merged

fix: resolve NP2004 probe model correctly from SpikeGLX metadata#2
tabedzki merged 1 commit into
mainfrom
tabedzki/fix/np2004-probe-model-resolution

Conversation

@tabedzki

Copy link
Copy Markdown

🤖 Human guided, AI assisted PR (using this skill). AI text below. 🤖

Summary

A user has a Neuropixels probe with imDatPrb_pn=NP2004 whose SpikeGLX metadata reports imDatPrb_type=2003 — a numeric type code not covered by the existing 1100/21/24 branches in SpikeGLXMeta. The fallback branch stringified the raw type code (producing "2003"), which never matches any registered ProbeType. This caused ingestion to fail with either:

  • NotImplementedError: Processing for neuropixels probe model 2003 not yet implemented, or
  • datajoint.errors.IntegrityError: Cannot add or update a child row: a foreign key constraint fails ... FOREIGN KEY (probe_type) REFERENCES #probe_type (probe_type)

depending on which insertion path is hit.

Changes

  • element_array_ephys/readers/spikeglx.py:
    • Fall back to self.probe_PN (the part number, e.g. "NP2004") instead of str(probe_model) when imDatPrb_type doesn't match a known code. probe_geometry.M already has geometry defined for NP2004.
    • Pull in upstream's imMaxInt-based IMAX lookup (SpikeGLX.get_channel_bit_volts), reading gain/max-int directly from the meta file when present, falling back to the IMAX dict only when absent. Without this, IMAX["NP2004"] would KeyError since IMAX is only keyed by the four generic probe model names, not part numbers.
    • imDatPrb_type default changed from 1 to 0, matching upstream, so meta files missing this field correctly enter the < 1 branch.
  • element_array_ephys/probe.py:
    • Register "NP2004" in create_neuropixels_probe_types() so the corresponding ProbeType row is created automatically on schema activation, rather than requiring a manual probe.create_neuropixels_probe("NP2004") call.

These changes were verified against this exact metadata:

imDatPrb_pn=NP2004
imDatPrb_type=2003

which now correctly resolves probe_model to "NP2004".

Test plan

  • Re-run ingestion against a session containing the NP2004 probe metadata above and confirm ProbeInsertion/EphysRecording populate without error
  • Confirm existing probe types (1.0 3A/3B, UHD, 2.0 SS/MS) still resolve and ingest correctly (regression check on the IMAX/probe_model changes)

Assisted-by: ClaudeCode:claude-sonnet-5

The imDatPrb_type SpikeGLX code (e.g. 2003) does not always map to one
of the known probe model constants (1100/21/24). Previously the
fallback stringified the raw type code (e.g. "2003"), which never
matches a registered ProbeType, causing ingestion to fail with
NotImplementedError or a foreign key violation on insert.

Fall back to the probe part number (imDatPrb_pn, e.g. "NP2004")
instead, matching the geometry already defined in probe_geometry.M.
Also pull in upstream's imMaxInt-based IMAX lookup and the
imDatPrb_type default fix (1 -> 0), and register NP2004 in
create_neuropixels_probe_types() so it is created automatically on
schema activation.

Assisted-by: ClaudeCode:claude-sonnet-5
@tabedzki
tabedzki merged commit 348a58d into main Aug 11, 2026
2 of 14 checks passed
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