fix: resolve NP2004 probe model correctly from SpikeGLX metadata - #2
Merged
Merged
Conversation
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
This was referenced Aug 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 Human guided, AI assisted PR (using this skill). AI text below. 🤖
Summary
A user has a Neuropixels probe with
imDatPrb_pn=NP2004whose SpikeGLX metadata reportsimDatPrb_type=2003— a numeric type code not covered by the existing1100/21/24branches inSpikeGLXMeta. The fallback branch stringified the raw type code (producing"2003"), which never matches any registeredProbeType. This caused ingestion to fail with either:NotImplementedError: Processing for neuropixels probe model 2003 not yet implemented, ordatajoint.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:self.probe_PN(the part number, e.g."NP2004") instead ofstr(probe_model)whenimDatPrb_typedoesn't match a known code.probe_geometry.Malready has geometry defined forNP2004.imMaxInt-basedIMAXlookup (SpikeGLX.get_channel_bit_volts), reading gain/max-int directly from the meta file when present, falling back to theIMAXdict only when absent. Without this,IMAX["NP2004"]wouldKeyErrorsinceIMAXis only keyed by the four generic probe model names, not part numbers.imDatPrb_typedefault changed from1to0, matching upstream, so meta files missing this field correctly enter the< 1branch.element_array_ephys/probe.py:"NP2004"increate_neuropixels_probe_types()so the correspondingProbeTyperow is created automatically on schema activation, rather than requiring a manualprobe.create_neuropixels_probe("NP2004")call.These changes were verified against this exact metadata:
which now correctly resolves
probe_modelto"NP2004".Test plan
ProbeInsertion/EphysRecordingpopulate without errorIMAX/probe_modelchanges)Assisted-by: ClaudeCode:claude-sonnet-5