Skip to content

reref: average reference in double precision, as in EEGPrep - #998

Merged
arnodelorme merged 1 commit into
developfrom
agent/reref-double-precision
Nov 29, 2026
Merged

arnodelorme merged 1 commit into
developfrom
agent/reref-double-precision

Conversation

@arnodelorme

Copy link
Copy Markdown
Collaborator

The average reference of reref.m is now computed in double precision and cast back to the class of the data: single(double(X) - mean(double(X),1)) for single precision data. Before, it multiplied the single precision data by the matrix eye(n) - 1/n, whose result depends on the BLAS library of the machine, so MATLAB and EEGPrep (which averages in float64 since sccn/eegprep#606) could differ by a fraction of a microvolt and clean_rawdata then kept different samples.

Only the average reference branch changes. A reference to one or several channels and the Huber average are unchanged. Double precision data give the same result as before up to roundoff.

Checks in MATLAB R2025b on this Mac:

  • On the 13 recordings of sccn/eegprep_parity_test (step 1 outputs), pop_reref(EEG, []) equals single(double(X) - mean(double(X),1)) exactly (0 differing values), and the data stay single.
  • With the parity test, the average reference is identical between MATLAB and EEGPrep on all 13 recordings, and after clean_rawdata the 12 table subjects keep the same channels and samples on both sides (at most 7e-6 µV apart).
  • 'exclude' leaves the excluded channels untouched, and a reference to one channel still works.

Consequence: the sample counts after clean_rawdata in the published parity table change (for example sub-001 keeps 185,480 samples instead of 187,971), so the reference table of sccn/eegprep_parity_test is regenerated with this change. Related: sccn/clean_rawdata#51, sccn/eegprep#832, sccn/eegprep#833 (closed in favour of this).

🤖 Generated with Claude Code

@claude

claude Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Claude encountered an error —— View job


I'll analyze this and get back to you.

@arnodelorme

Copy link
Copy Markdown
Collaborator Author

Full parity test with this branch (EEGLAB develop 4405bab + this commit, clean_rawdata 2.12, MATLAB R2025b) against EEGPrep develop 4df5bbe8, 13 recordings, 7 steps:

  • Steps 1 and 2 identical on all subjects; step 3 same channels and samples on both sides, at most 7×10⁻⁶ µV apart.
  • 11 of the 12 table subjects stay within 0.0007 µV through epoching, with the same ICLabel rejections.
  • sub-013 diverges at Picard (AMARI 0.033, minimum component correlation 0.50), 1.32 µV after ICLabel and 1.51 µV after epoching, although the same component is rejected. With the old single precision reference it was 0.00003 µV.
Details

The sample counts after clean_rawdata change for every subject (for example sub-001 185,480 instead of 187,971), so the reference table of sccn/eegprep_parity_test was regenerated: https://github.com/sccn/eegprep_parity_test/commit/4e1c55d

— orchestrator

@arnodelorme
arnodelorme merged commit 5c299dd into develop Nov 29, 2026
2 of 3 checks passed
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