Skip to content

Revert the float64 average reference of #606 to restore EEGLAB parity - #833

Closed
arnodelorme wants to merge 3 commits into
developfrom
agent/revert-606-average-reference
Closed

arnodelorme wants to merge 3 commits into
developfrom
agent/revert-606-average-reference

Conversation

@arnodelorme

@arnodelorme arnodelorme commented Nov 28, 2026 •

Copy link
Copy Markdown
Collaborator

This reverts the average reference change of #606 ("Sum average reference in float64 before casting to the input dtype", merged November 18, 2026), because changing Python alone broke numerical parity with EEGLAB.

End-to-end step 3 (ASR) comparison on all 13 recordings

MATLAB R2025b (maca64) with EEGLAB and clean_rawdata (#52) versus develop (with #606) and this branch (with #832) in native arm64 Python (NumPy 2.3.5, Apple Accelerate):

Subject MATLAB R2025b develop (with #606) This branch (arm64 Python) Max abs diff vs MATLAB RMS diff vs MATLAB
sub-001 57x187971 57x185480 (different) 57x187971 (exact size) 3.79e-6 µV 2.07e-7 µV
sub-002 33x149647 33x148718 (different) 33x149647 (exact size) 4.77e-6 µV 2.13e-7 µV
sub-003 55x185619 55x186958 (different) 55x185619 (exact size) 3.80e-6 µV 2.02e-7 µV
sub-004 56x169692 56x167779 (different) 56x169692 (exact size) 3.19e-6 µV 1.40e-7 µV
sub-005 50x191669 50x191733 (different) 50x191669 (exact size) 3.81e-6 µV 2.04e-7 µV
sub-006 52x195543 52x194388 (different) 52x195543 (exact size) 3.48e-6 µV 1.64e-7 µV
sub-007 54x121668 54x120988 (different) 54x121668 (exact size) 3.71e-6 µV 2.38e-7 µV
sub-008 59x182255 59x182647 (different) 59x182255 (exact size) 3.21e-6 µV 1.41e-7 µV
sub-009 57x154286 57x154032 (different) 57x154286 (exact size) 3.68e-6 µV 1.89e-7 µV
sub-010 56x181548 56x181420 (different) 56x181548 (exact size) 1.91e-6 µV 1.83e-7 µV
sub-011 33x176640 33x173891 (different) 33x176640 (exact size) 1.36e-5 µV 1.67e-7 µV
sub-012 34x167934 64x167932 (different) 34x167934 (exact size) 4.81e-12 µV 4.47e-13 µV
sub-013 60x166132 60x164585 (different) 60x166132 (exact size) 3.66e-6 µV 2.05e-7 µV
Step 2 BLAS and architecture comparison against MATLAB R2025b
Python stack and formulation sub-001 sub-002 sub-012
Native arm64 Accelerate or arm64 OpenBLAS 0.3.34, (block @ refmatrix).T (1 or 8 threads) 0 µV 0 µV 0 µV
Rosetta x86_64 Accelerate, (block @ refmatrix).T 0.00195 µV 0.03125 µV 0.03125 µV
Rosetta x86_64 Accelerate, refmatrix @ data 0.0625 µV 0.078125 µV 0.0625 µV
float64 mean cast to float32 (#606) against single-precision EEGLAB 0.15625 µV 0.15625 µV 0.171875 µV

Average reference of float32 data is computed again as EEGLAB's
single-precision matrix product, in the column-major order of the
transpose fix of #232. The float64 sum of #606 moved the result up to
0.15625 uV away from EEGLAB on ds003061 and changed the number of samples
clean_artifacts keeps for every subject of sccn/eegprep_parity_test.

The Picard tolerance changes of #606 and the current fuzz-harness test
are kept.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Code review skipped — your organization has no extra usage available to pay for this review.

If your organization's extra usage balance is empty, an organization admin can add extra usage credits at claude.ai/admin-settings/usage. If its monthly spend limit was reached, an admin can raise it on the same page. If neither applies, contact Anthropic support.

Once extra usage is available, someone with write access to this repository can comment @claude review on this pull request to trigger a review.

@arnodelorme

Copy link
Copy Markdown
Collaborator Author

Review of this pull request, asked by Arno on November 28, 2026. It had only the skip notice of the automated review.

What I checked in the diff
Both sides in double precision: measured on the 13 recordings of sccn/eegprep_parity_test

MATLAB R2025b with single(double(X) - mean(double(X),1)) and clean_rawdata after sccn/clean_rawdata#52, against develop with #832 (the float64 mean of #606) in native arm64 Python. Step 2 has 0 differing values on all 13 recordings.

Subject MATLAB step 3 EEGPrep step 3 Max abs diff Published table (single precision)
sub-001 57x185480 57x185480 3.8e-6 µV 57x187971
sub-002 33x148718 33x148718 7.1e-6 µV 33x149647
sub-003 55x186958 55x186958 3.8e-6 µV 55x185619
sub-004 56x167779 56x167779 3.6e-6 µV 56x169692
sub-005 50x191733 50x191733 3.8e-6 µV 50x191669
sub-006 52x194388 52x194388 3.6e-6 µV 52x195543
sub-007 54x120988 54x120988 3.8e-6 µV 54x121668
sub-008 59x182647 59x182647 3.2e-6 µV 59x182255
sub-009 57x154032 57x154032 3.7e-6 µV 57x154286
sub-010 56x181420 56x181420 1.9e-6 µV 56x181548
sub-011 33x173891 33x173891 3.8e-6 µV 33x176640
sub-012 (not in the table) 64x167934 64x167933 sizes differ by one sample 34x167934
sub-013 60x164585 60x164585 3.5e-6 µV 60x166132

So EEGLAB and EEGPrep stay as close to each other as today for the 12 subjects of the table, but every sample count of the table changes. Steps 4 to 7 were not run.

— orchestrator

@arnodelorme

Copy link
Copy Markdown
Collaborator Author

Closed without merging. Arno chose double precision on both sides (November 28, 2026): EEGLAB's reref.m now averages in double precision like EEGPrep since #606 (sccn/eeglab#998), and the parity test's reference table is regenerated. — orchestrator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant