Skip to content

[pop_reref] Leave the dataset unchanged when every channel is excluded - #804

Merged
arnodelorme merged 2 commits into
developfrom
agent/20261128-fix-794
Nov 28, 2026
Merged

arnodelorme merged 2 commits into
developfrom
agent/20261128-fix-794

Conversation

@claude

@claude claude Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

An average reference with every channel excluded no longer raises. reref returns the samples unchanged, as reref.m does, and pop_reref logs a warning and keeps the reference labels and ICA, unlike EEGLAB, which relabels EEG.ref as average and drops ICA; the help and docs note the difference. An excluded explicit reference still raises.

Fixes #686
Part of #794

🤖 Generated with Claude Code

EEGLAB reference evidence

EEGLAB reference run 46183773551 on d02f609 (develop merged in), EEGLAB d0963be9, eeglab_tests fec88f9f: 4,486 passed, 5 failed, 58 skipped, about 55 minutes (19:57 to 20:52 UTC). The 5 failures are the suite's current baseline and do not involve reref or pop_reref: test_coregister_traditional_warp_matches_eeglab, test_synthetic_traditional_warp_matches_fieldtrip, test_bem_leadfield_and_multifit_match_fieldtrip, test_matlab_kmeans_numbering_matches_fixed_initial_centroids and test_struct_near_assertion_matches_source. The same five failed on the November 27 reference run of agent/20261127-fix-746 (45951378985).

The claim that reref.m returns the samples unchanged when every channel is excluded was also checked directly in MATLAB R2025b with the vendored EEGLAB (420769355): reref(randn(4,50), [], 'exclude', 1:4) returns a 4 by 50 array whose largest difference from the input is 0, and with 'exclude', 2:4 the one remaining channel becomes 0 while channels 2 to 4 are unchanged (largest difference 0), which is what the new tests assert.

An average reference with every channel excluded no longer raises. reref
returns the samples unchanged like reref.m, and pop_reref warns and keeps
the reference labels and ICA. Part of #794, fixes #686.

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

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor Author

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.

@claude

claude Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor Author

Claude finished @claude[bot]'s task in 44s —— View job


Code review

  • Overall assessment: Mostly correct. The early return in pop_reref only fires for an average reference where every channel is excluded, with no refloc and no interpchan. An explicit reference whose channels are excluded still raises in reref, at reref.py:64-65. When refloc is set, the appended channel is never excluded, so the change can't misfire there. The one gap is process: the MATLAB reference evidence that AGENTS.md requires is missing.
  • Highest-risk area: src/eegprep/functions/sigprocfunc/reref.py. This is ported core processing code.
  • Merge recommendation: Needs changes. The code is fine; the PR description is missing the required MATLAB reference evidence.

Blocking

None.

Important

  • The PR changes core numerics but has no MATLAB reference evidence (reref.py, pop_reref.py). AGENTS.md § Testing says: "Before merging a PR that changes core function implementations … trigger .github/workflows/eeglab-reference.yml … Put that run in the PR description." This PR changes what reref does when every channel is excluded: it used to raise and now returns the data. The description doesn't include that run.
    • Why it matters: the run is the evidence a human approver needs. It is also the only check of the claim that reref.m applies an empty refmatrix and returns the samples unchanged. The vendored EEGLAB checkout isn't present in this runner, so I couldn't check that claim against reref.m.
    • Fix: run the EEGLAB reference workflow on agent/20261128-fix-794. Add to the description: the run link, the EEGLAB and eeglab_tests commits, the pass/fail/skip counts and the runtime.

Nits

  • reref.py:79-80, the if not chansin: pass branch: an empty branch that exists only to skip the elifs is harder to read than it needs to be. Wrapping the existing if/elif/else in if chansin: would do the same thing, and the parity comment could move onto that guard.

Test gaps

None. The three new tests cover all three cases:

  • Every channel excluded: the samples, labels, ICA and history command are unchanged, and the low-level reref returns the data unchanged.
  • One eligible channel: that channel is set to zero.
  • An explicit reference that is also excluded still raises.

EEGLAB parity notes

  • After this change, EEGPrep keeps EEG.ref, the per-channel ref labels and the ICA matrices. EEGLAB relabels the reference as average and drops ICA. The data are unchanged, so keeping ICA is the mathematically consistent choice. The difference is documented in pop_reref.md and interactive_pop_workflows.rst and locked in by test_average_reference_with_every_channel_excluded_returns_the_dataset_unchanged. Under the repo's rule for documented and tested deviations, it is not a parity bug.

I couldn't run the tests here because the runner's permissions blocked pytest, so all of this comes from reading the code.

@arnodelorme
arnodelorme merged commit 23a7d50 into develop Nov 28, 2026
17 of 20 checks passed
@arnodelorme

Copy link
Copy Markdown
Collaborator

Follow-up to the review, after #776 was merged.

The code needed no change. The missing evidence is now in the description. The EEGLAB reference run on this branch (46183773551) has 4,486 passed, 5 failed and 58 skipped. The 5 failures are the suite's current baseline (coregister, dipfit BEM, k-means numbering, struct near), the same as on the November 27 run of another branch, and none involves reref. I also ran reref.m in MATLAB R2025b: with every channel excluded it returns the samples unchanged (largest difference 0), which is what the new tests assert.

Develop was merged into the branch (no force push), and the pop_reref tests pass locally. The review's nit about the empty if not chansin: pass branch was left as it is, to keep the change small.

The review is now clean and every other check passes, so I merged it with a squash, as Arno asked.

— 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.

[fuzz][python-only] python-only:ValueError in pop_reref

1 participant