Skip to content

Blackrock: read NEV 2.2 spikes on electrodes above 255 - #1926

Merged
h-mayorquin merged 5 commits into
NeuralEnsemble:masterfrom
cboulay:nev-22-spikes-above-255
Nov 6, 2026
Merged

h-mayorquin merged 5 commits into
NeuralEnsemble:masterfrom
cboulay:nev-22-spikes-above-255

Conversation

@cboulay

@cboulay cboulay commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Addresses the dropped spikes in #1918: spike packets of a 2.2 .nev were only recognized for IDs 1-255, so a Ripple Trellis recording with electrodes 257+ lost every spike. The 2.2 range is now (1, 2048), the same as 2.3.

The test builds a 2.2 file from neo's 2.3 test file (spec byte changed, electrode 1 renumbered 300 in its NEUEVWAV header and spike packets) and checks that electrode 300's spikes equal electrode 1's in the original. It fails on the old range. I did not run the Trellis sample from the issue through this.

This does not add the warning the issue also asks for when data packets match no known type. I also added a comment above NEV_PACKET_IDENTIFIERS_BY_SPEC that lists the packet IDs of 3.0 files written by Central that are ignored on purpose, so a future warning does not need to treat them as surprises: 0x8000 + channel live-protocol preview packets, and 0xFFF9 recording events (start/stop/pause/resume, per Central's CNevFile30::AddRecordingEvent).

@h-mayorquin you mentioned working on Blackrock this week: we are fine with whatever solution you come up with for #1918 (the range, the warning, or both). Feel free to close this in favor of yours, or push to this branch.

Ripple Trellis writes 2.2 files with electrode IDs by front-end port (1-128,
129-256, 257-384...). Spike packets of a 2.2 file were recognized only for IDs
1-255, so every spike on a higher electrode matched no packet type and was
dropped without a warning. The 2.2 range is now 1-2048, as for 2.3.

Also document next to the table which packet IDs of 3.0 files written by
Central are ignored on purpose (preview packets, recording events).
@zm711
zm711 requested a review from h-mayorquin October 24, 2026 19:39
@zm711

zm711 commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

@cboulay I've requested Heberto to review your PRs. Thanks for the continued contributions!

@h-mayorquin h-mayorquin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The approach looks good to me. I have one question, where does the 2048 come from? Your comment says it is the range of 2.3, but I traced the 2.3 value back to the first draft of the reader in 2014 and could not find a source for it.

The only limit I could find is 1 through 10000, in section 4.5 of LB-0110. But that is the 3.0 document, and that range would also take the Trellis stimulation packets (5120 plus the electrode) as spikes. I would like to keep those apart and I will do another PR for them. So I am fine with leaving 2048, but if you have a better number or a source (Ripple's 2.2 document maybe?) that would be great.

I added your sample.nev (thanks for sharing it!)
https://gin.g-node.org/NeuralEnsemble/ephy_testing_data/pulls/192

Once the gin PR is merged (@zm711) and the tests updated here we can move forward here. I will review the other PRs as soon as I can.

@h-mayorquin

Copy link
Copy Markdown
Contributor

The data is already on gin.

@cboulay

cboulay commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

I don't have a source for 2048 either It was chosen as roughly halfway between the front-end electrode ids and Trellis's stimulation ids (5120 + electrode), without a documented ceiling behind it. A bound with a reason would be 5120: From what I've seen, Trellis writes stimulation on ids above 5120, so everything at or below it can be a spike electrode. Happy to switch to 5120 here, or something else?

This is only the second time I've worked with Trellis' .nsx / .nev files so I don't have a lot to go on.

@h-mayorquin h-mayorquin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5120 makes sense to me as it is a bound with a reason. Trellis writes stimulation on 5120 plus the electrode. So everything up to 5120 can be a spike electrode. In a separate PR I will give the stimulation its own entry in the table, "Stimulation" from 5121, so it is read apart from the spikes.

Can you change the range to 5120 and state the reason in the comment. Something like:

        # Packet IDs in this range identify spike events on electrodes. Wider than 2.1's range:
        # Ripple Trellis writes 2.2 files with electrode IDs above 255 (its front-end ports are
        # numbered 1-128, 129-256, 257-384...), and every spike on them was dropped without a
        # warning (NeuralEnsemble/python-neo#1918). The bound is 5120 because Trellis writes
        # stimulation packets on 5120 plus the electrode ID.
        "Spikes": (1, 5120),

With that and the test reading the Trellis file that is now on gin (blackrock/version_2_2/spikes/electrode_ids_above_255/electrode_ids_above_255.nev) I think this is ready.

@h-mayorquin h-mayorquin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I finished the last details on this, thanks a lot @cboulay

@h-mayorquin
h-mayorquin merged commit deda58c into NeuralEnsemble:master Nov 6, 2026
3 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.

3 participants