Round before casting preprocessed traces to integer dtypes#4653
Open
CodeBlackwell wants to merge 1 commit into
Open
Round before casting preprocessed traces to integer dtypes#4653CodeBlackwell wants to merge 1 commit into
CodeBlackwell wants to merge 1 commit into
Conversation
…er dtype whiten, common_reference and highpass_spatial_filter cast their float result straight to an integer dtype with astype(), which truncates toward zero instead of rounding and biases the output; filter.py already rounds before the same cast. Round on the integer-dtype path in those three, and stop casting the ScaleRecording offset to the integer dtype (which zeroed out fractional offsets). Adds tests covering the integer-rounding paths.
Member
|
We've been discussing this a bit and two questions:
|
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.
Several preprocessors cast their float result straight to an integer
dtypewithastype(), which truncates toward zero instead of rounding. Over many samples that biases the output (toward zero for centered data, downward otherwise).filter.pyalready rounds before the same cast — this bringswhiten,common_referenceandhighpass_spatial_filterin line with it. It also drops theoffset.astype(dtype)cast inScaleRecording, which was silently zeroing fractional offsets for integer dtypes.Added tests covering the integer-rounding paths.
Noticed while looking at #1972; this addresses the integer-cast rounding, not the zscore/
int_scalestd question in that issue.