Skip to content

Fix Neuropixels handling in SpikeGadgetsRawIO#1847

Open
h-mayorquin wants to merge 1 commit into
NeuralEnsemble:masterfrom
h-mayorquin:fix_spikegadgets
Open

Fix Neuropixels handling in SpikeGadgetsRawIO#1847
h-mayorquin wants to merge 1 commit into
NeuralEnsemble:masterfrom
h-mayorquin:fix_spikegadgets

Conversation

@h-mayorquin
Copy link
Copy Markdown
Contributor

@h-mayorquin h-mayorquin commented May 11, 2026

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.

@dkassybayeva
Copy link
Copy Markdown

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?
I.e. does it affect channelmap.prb construction?

@alejoe91
Copy link
Copy Markdown
Contributor

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? I.e. does it affect channelmap.prb construction?

I don't think it will, but @h-mayorquin can confirm!

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.

3 participants