Skip to content

Fix Plexon analog block offsets when block sizes differ - #1980

Open
evadiva3 wants to merge 1 commit into
NeuralEnsemble:masterfrom
evadiva3:fix/1976-plexon-block-offsets
Open

evadiva3 wants to merge 1 commit into
NeuralEnsemble:masterfrom
evadiva3:fix/1976-plexon-block-offsets

Conversation

@evadiva3

Copy link
Copy Markdown

Closes #1976.

The Plexon reader calculates each analog block's start from the current block's sample count. When consecutive blocks have different sizes, this shifts their offsets and can return the wrong signal samples. Accumulate the preceding block's sample count instead.

The regression writes a small PLX file with blocks of 100, 200, and 50 samples, parses it through PlexonRawIO, and checks both block starts and a public chunk read across a boundary. It fails before the fix ([0, 200, 250] instead of [0, 100, 300]) and passes after.

I also checked the existing public recording plexon/File_plexon_3.plx. Its signal channel contains 5,007 blocks with sample counts of 120 and 86. The original parser puts the final block start 34 samples early. With the fix, all starts match the preceding payload lengths, and a chunk near the end matches the raw stored samples exactly. The chunk ends inside the final block so this check is independent of the end-of-block issue in #1971.

Validation on Python 3.13.15:

  • pytest neo/test/rawiotest/test_plexonrawio.py neo/test/coretest: 652 passed, 13 skipped, 1 warning. External-data tests skip without their dataset harness; the generated-file regression runs independently.
  • Black checks pass for both changed Python files at line length 120.
  • Pyflakes/syntax checks pass. Full Flake8 reports the same six pre-existing findings in plexonrawio.py as the unchanged base, with no new findings; the test file is clean.

OpenAI Codex assisted with investigation, the implementation and regression, real-recording validation, test execution, and this description.

@zm711 zm711 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.

Thanks @evadiva3. I believe that @h-mayorquin has more experience with plexon so I'll leave him to also give this a read. In general we do not allow for generated file regression tests as the goal of the library is to be tested on real data. It would be better for you to write a test based on plexon/File_plexon_3.plx.

This branch has not been deployed

No deployments
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.

Plexon reader: each block's start offset is computed from its own size instead of the previous block's, so offsets are wrong when block sizes differ

2 participants