Repository navigation
Commit d3e2b1f
committed
[FIX] ASR: init clean_windows rejection masks before one-sided zthresholds
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.1 parent 3721224 commit d3e2b1f
2 files changed
Lines changed: 25 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
353 | 353 | | |
354 | 354 | | |
355 | 355 | | |
| 356 | + | |
| 357 | + | |
356 | 358 | | |
357 | 359 | | |
358 | 360 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
171 | 171 | | |
172 | 172 | | |
173 | 173 | | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
174 | 197 | | |
175 | 198 | | |
176 | 199 | | |
| |||
0 commit comments