Repository navigation
Fix BCI2000RawIO scaling: decimal gains were parsed as 0 and the offset was applied with the wrong convention - #1932
Open
aaronkanzer wants to merge 1 commit into
Open
aaronkanzer wants to merge 1 commit into
aaronkanzer wants to merge 1 commit into
Conversation
Contributor
|
@h-mayorquin could you review this? I don't think about regex at all so I trust your review of this. As far as NumPy 2.5 we haven't officially started support that yet. I'm working on that now. |
This branch has not been deployed
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.
BCI2000RawIOhas three problems that together make the scaled signals wrong for every channel.parse_header()raisesTypeError: data type 'a64' not understood. The state definitions use the"a64"dtype alias, which was deprecated in NumPy 2.0 and removed in 2.5.SourceChGainvalues like0.01617are parsed as0. Header values are matched withr"(-*\d+)(\w*)", which stops at the decimal point. The string fallback in_parse_headerhas the same problem.SourceChOffsetis passed straight through as neo'soffset. BCI2000 definesuV = (raw - SourceChOffset) * SourceChGain, while neo computesraw * gain + offset.Repro with
bci2000/eeg1_1.datfrom ephy_testing_data. Its header hasSourceChGain= 64 0.01617 0.01591 ...andSourceChOffset= 64 43 55 .... Run with neo 0.14.6 and NumPy 2.2 (on NumPy 2.5 it fails atparse_header()):Observed:
Every channel is a constant equal to its raw offset.
Expected: gains
[0.01617 0.01591 0.01595], and channel 0 starting[-16.2185, 1.3745, -9.2331]uV. With the fix, the whole file matches BCI2000's ownFileReader.py(theBCI2kReaderpackage) to within 1.5e-5 uV.Fix:
"S64"instead of"a64".offset = -SourceChOffset * SourceChGain.The rawio test class also defined
entities_to_downloadtwice and never setentities_to_test, so the compliance tests never ran on these files. The test now lists the three files and adds a scaling check against values from BCI2kReader.