You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
clean_windows / asr_calibrate: extra trailing window vs EEGLAB when the step is fractional #490
EEGLAB uses offsets = round(1:N*(1-window_overlap):S-N) (clean_windows.m:97, asr_calibrate.m:201), so the last start is at most S−N. EEGPrep uses np.arange(1, S - N + 1, step) (clean_windows.py:138) and np.arange(0, S - N, step) (asr_calibrate.py:269). Both allow a start up to just below S−N+1, so when 1 + k*step falls in (S−N, S−N+1), EEGPrep adds one window that EEGLAB doesn't have.
Repro: N=256 (256 Hz, 1 s), overlap 0.66, S=1040. MATLAB gives 9 starts [1 88 175 262 349 436 523 610 697]; EEGPrep gives 10 (adds 784). Over S = N+1 … N+3000, offsets differ for 34 lengths at N=256, 68 at N=128 and 70 at N=125 (overlap 0.66), and for none with integer steps (overlap 0.5 or 0.75). Each time EEGPrep has exactly one extra trailing window. A full clean_windows run (8 channels, 256 Hz, overlap 0.66) at S=5392 keeps 5049 samples in MATLAB and 4962 in EEGPrep (87 trailing samples differ); S=5393 matches.
Impact: about 1/step of recording lengths (~1–2.5% at common settings). The extra window can remove trailing samples in clean_windows and shift the ASR calibration threshold.
Fix: build starts as 1 + step*k for k = 0 … floor((S-N-1)/step) (asr_calibrate: the same, 0-based), then round_mat. This matched MATLAB for all 18,000 lengths tested.
Related, untested: MATLAB clean_windows uses N = window_len*srate without rounding, while EEGPrep rounds it; they can differ when window_len*srate isn't an integer.
Activity