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
[fuzz] pop_clean_rawdata wide start=1202: MATLAB ASR calibration fails on 3 RMS windows, eegprep applies ASR (max abs 74.79) #651
The wide bids pop_clean_rawdata fuzz case (all 32 channels, start=1202, length=1024, srate=128) still diverges on develop 8289770: max abs 74.79348223853694, max rel 2048.468151541101, finite index 8042. Tolerances and goldens are not involved.
clean_drifts (highpass) differs only by filter roundoff (max abs 1.85e-13, max rel 4.04e-11), which doesn't change any later decision.
clean_channels agrees: both remove EOG1 and T8 (32 to 30 channels).
The first material divergence is ASR.
clean_asr's calibration clean_windows (0.075, [-inf, 5.5], 1 s) keeps 118 of 1024 samples on both sides. asr_calibrate then forms 0.5 s RMS windows (N=64, overlap 0.66) and gets n=3 windows (starts 0, 22, 44). The only short-reference error in asr_calibrate.m is for length(rms)==1, so n=3 goes on into fit_eeg_distribution.
There the default quants are [0.022, 0.6], so min_width = 0.25*0.578 = 0.1445, and m = round(n*(max_width:-0.01:min_width)) includes m=0 when n is 2 or 3. MATLAB asr_calibrate.m line 395 indexes X(m,:) and errors with "Index in position 1 is invalid." eegprep's fit_eeg_distribution (private/stats.py) skips m <= 0, fits on the remaining widths (1 or 2 values), and applies ASR. ASRCalibrationError covers only S < N or fewer than 2 RMS windows.
clean_artifacts.m lines 270-275 catch any clean_asr error and return immediately, which also skips restoring srate and the final clean_windows stage. On this crop MATLAB's output is bit-identical to the post-channel, pre-ASR recording. eegprep applies ASR, and its final clean_windows is a no-op here. The 74.79 / 2048.47 at index 8042 is eegprep's ASR repair against MATLAB's unrepaired data.
Options:
Raise ASRCalibrationError when the RMS window count is too small for the fit grid (any m <= 0), so eegprep also leaves the recording unrepaired by ASR, but still restores srate and runs the final clean_windows. MATLAB's early return would be documented as an EEGLAB bug, with a test locking in the difference.
Keep skipping invalid widths (current behaviour) and document MATLAB's index error as an EEGLAB bug.
Repro on jamming: /mnt/v1/arno/suraj3/pr640/fuzz-out-wide/repros/pop_clean_rawdata-numeric-data.json
Human decision: confirm option 2 and approve the harness-only follow-up below (no PR opened yet)
Research
Option 2 is already the documented, intentional behavior from #526/#582: EEGPrep skips non-positive fit widths and still calibrates, and MATLAB's X(m,:) index error plus the early return in clean_artifacts.m is listed as an EEGLAB defect. So no core-code change is needed. The real gap is in the fuzz harness. Both known-defect classifiers only match case.function == "clean_asr" with entry == "clean_rawdata"and MATLAB output equal to the raw input. In the wide-bids pop_clean_rawdata target, the flatline/highpass/channel stages run first. MATLAB therefore returns the post-channel, pre-ASR recording rather than the input, so the case falls through to judge as a divergence.
Keep option 2. Option 1 would reverse a decision already in the docs and changelog. It still would not match MATLAB, which also skips the final clean_windows and the srate restore.
Extend the known-defect check in tests/fuzz/harness.py to the pop_clean_rawdata target. Run EEGPrep's pop_clean_rawdata with the same options but BurstCriterion='off' and WindowCriterion='off'. Classify the case as known #582 only when (a) the MATLAB oracle matches that pre-ASR output within the clean_asr tolerance, and (b) _fit_width_reaches_zero is true for the reference that clean_windows kept on the pre-ASR data. Add one harness test with a crop that leaves 3 calibration RMS windows. This touches test tooling only (about 40-60 lines) and changes no tolerances.
Not opened as a PR: a human needs to confirm option 2 first. The classifier also has to be checked with MATLAB against the jamming repro (fuzz-out-wide/repros/pop_clean_rawdata-numeric-data.json), which this runner can't reach.
Activity
claude commentedon Nov 18, 2026
🤖 Plan:
Research
Option 2 is already the documented, intentional behavior from #526/#582: EEGPrep skips non-positive fit widths and still calibrates, and MATLAB's
X(m,:)index error plus the earlyreturninclean_artifacts.mis listed as an EEGLAB defect. So no core-code change is needed. The real gap is in the fuzz harness. Both known-defect classifiers only matchcase.function == "clean_asr"withentry == "clean_rawdata"and MATLAB output equal to the raw input. In the wide-bidspop_clean_rawdatatarget, the flatline/highpass/channel stages run first. MATLAB therefore returns the post-channel, pre-ASR recording rather than the input, so the case falls through tojudgeas a divergence.Relevant code
private/stats.py#L171- skips m <= 0 (option 2)eeglab_migration.rst#L288-L293- documented divergence ([fuzz] pop_clean_rawdata|numeric|8e1 #582)tests/fuzz/harness.py#L1696-L1724- zero-width classifier,clean_asronly, oracle == inputtests/fuzz/harness.py#L1770-L1785-_wrapper_returned_unchanged, same restrictiontests/fuzz/targets.py#L347-L355- fullpop_clean_rawdatatarget, not coveredProposed Fix
Keep option 2. Option 1 would reverse a decision already in the docs and changelog. It still would not match MATLAB, which also skips the final
clean_windowsand the srate restore.Extend the known-defect check in
tests/fuzz/harness.pyto thepop_clean_rawdatatarget. Run EEGPrep'spop_clean_rawdatawith the same options butBurstCriterion='off'andWindowCriterion='off'. Classify the case as known #582 only when (a) the MATLAB oracle matches that pre-ASR output within theclean_asrtolerance, and (b)_fit_width_reaches_zerois true for the reference thatclean_windowskept on the pre-ASR data. Add one harness test with a crop that leaves 3 calibration RMS windows. This touches test tooling only (about 40-60 lines) and changes no tolerances.Not opened as a PR: a human needs to confirm option 2 first. The classifier also has to be checked with MATLAB against the jamming repro (
fuzz-out-wide/repros/pop_clean_rawdata-numeric-data.json), which this runner can't reach.