[FIX] ASR: init clean_windows rejection masks before one-sided zthresholds - #113
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #113 +/- ##
==========================================
+ Coverage 83.10% 83.11% +0.01%
==========================================
Files 25 25
Lines 2823 2825 +2
==========================================
+ Hits 2346 2348 +2
Misses 477 477 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Collaborator
Author
|
Note: includes the |
Closed
nbara
force-pushed
the
fix/asr-clean-windows-mask-init
branch
from
July 16, 2026 07:15
922fbe1 to
a37a8c5
Compare
…holds mask1 and mask2 in clean_windows were only assigned inside their respective `if np.max(zthresholds) > 0` / `if np.min(zthresholds) < 0` branches, but combined unconditionally via `np.logical_or.reduce((mask1, mask2, mask3))`. Since zthresholds is a documented, user-facing parameter, passing a one-sided value (e.g. [1, 2] or [-5, -1]) skips one branch and raises UnboundLocalError. The default [-3.5, 5] straddles 0 so both branches run, keeping the bug latent. Fix: initialize both masks to all-False (matching the EEGLAB/BCILAB reference behavior of flagging no windows by default) before the conditionals, so each criterion that isn't evaluated simply rejects no windows instead of being undefined. Added a regression test exercising clean_windows with both one-sided directions of zthresholds on the eeg_raw.npy fixture.
nbara
force-pushed
the
fix/asr-clean-windows-mask-init
branch
from
July 18, 2026 16:10
a37a8c5 to
c2b9ca1
Compare
nbara
approved these changes
Jul 18, 2026
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.
In
clean_windows,mask1andmask2were only assigned inside their respectiveif np.max(zthresholds) > 0/if np.min(zthresholds) < 0branches, but combined unconditionally vianp.logical_or.reduce((mask1, mask2, mask3)). Sincezthresholdsis a documented, user-facing parameter, passing a one-sided value (e.g.[1, 2]or[-5, -1]) skips one branch and raisesUnboundLocalError. The default[-3.5, 5]straddles 0 so both branches run, keeping the bug latent.Initialize both masks to all-
Falsebefore the conditionals, so a criterion that isn't evaluated simply rejects no windows.Testing
Added a regression test exercising
clean_windowswith both one-sided directions ofzthresholds. Fulltests/test_asr.pypasses;ruffclean.