Fix Neuropixels handling in SpikeGadgetsRawIO#1847
Open
h-mayorquin wants to merge 1 commit into
Open
Conversation
|
If in old version channel ids were incorrect, does it mean the whole pre-processing, including kilosort, needs to be rerun for those sessions to get correct ids and probe positions? |
alejoe91
approved these changes
May 12, 2026
Contributor
I don't think it will, but @h-mayorquin can confirm! |
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.
SpikeGadgetsRawIO crashes with ZeroDivisionError when opening any Neuropixels .rec file from Trodes 2.8.2 onwards (closes issue #1844 and maybe #1810). Trodes writes chanPerChip="0" on those headers to signal that the recording has no Intan chip layout, and the existing reader divides by that value without a guard. While investigating, I found a separate silent bug in the existing NP1 data on gin: it writes chanPerChip="32" despite using a Neuropixels probe, so the old divisibility check passed and the file went through _produce_ephys_channel_ids, producing fabricated chip-style channel ids that did not match any real hardware channel.
The fix switches the discriminator from chanPerChip to the SpikeConfiguration.device attribute, which Trodes writes as "intan", "neuropixels1", or "neuropixels2" (absent on legacy files, which were always Intan). The hwChan path is now the default for every recording, and the Intan chip-id synthesis runs only as an override when device confirms the recording is Intan and the chip math works out. That route fixes both the NP2 crash and the silent NP1 misrouting in one change.