Skip to content

Match EEGLAB's probability loop in pop_autorej - #325

Open
arnodelorme wants to merge 1 commit into
developfrom
fix/autorej-final-pruning
Open

Match EEGLAB's probability loop in pop_autorej#325
arnodelorme wants to merge 1 commit into
developfrom
fix/autorej-final-pruning

Conversation

@arnodelorme

Copy link
Copy Markdown
Collaborator

Run the pop_autorej probability loop like EEGLAB: a pass rejects only when fewer than maxrej percent of the epochs are flagged, and once nothing is flagged the threshold walks back toward 5 s.d. for up to eight pruning rounds instead of stopping at the first clean pass. Adds a parity test with reference rejections from tests/matlab/pop_autorej_reference.m (EEGLAB develop aadfd19a7). The final kurtosis pass stays mode-aware; EEGLAB skips it in channel mode because it reads icarejkurt.

@claude claude Bot left a comment

Copy link
Copy Markdown

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's credit balance is too low for Code Review to run.

An organization admin can purchase credits or upgrade the plan in Plans & Billing.

Once credits are available, reopen this pull request to trigger a review.

@claude

claude Bot commented Sep 9, 2026

Copy link
Copy Markdown

Claude encountered an error after 0s —— View job


I'll analyze this and get back to you.

@arnodelorme

Copy link
Copy Markdown
Collaborator Author

🤖 ## Code review

  • Overall assessment: Faithful port of the EEGLAB probability loop; CI is green on the branch.
  • Highest-risk area: loop termination and threshold walk-back (verified line by line against pop_autorej.m).
  • Merge recommendation: Safe to merge after a trivial rebase. The only conflict with develop is the adjacent Unreleased entry in docs/source/changelog.rst.

Blocking

None.

Important

None.

Nits

None.

Test gaps

None. Ten parametrized cases cover the raise, reject, and prune phases in both channel and component mode, with reference values from tests/matlab/pop_autorej_reference.m.

EEGLAB parity notes

Compared against pop_autorej.m (vendored, lines 165-224):

  • MATLAB runs one pass before the while repeat loop and then identical logic inside it; folding both into one loop with numrej = 1 as the initial sentinel is equivalent.
  • numrej / trials >= maxrej / 100 -> raise 0.5 s.d. is the complement of MATLAB's (numrej/EEG.trials) < opt.maxrej/100 -> reject, and both use the current (post-rejection) trial count.
  • limit > DEFAULT_STARTPROB and pruning_rounds < MAX_PRUNING_ROUNDS is opt.startprob > 5 && maxiter < 8. MATLAB's if maxiter > 8, opt.maxrej = 15 branch is unreachable (maxiter never exceeds 8), so omitting it is correct.
  • The mode-aware final kurtosis pass is a deliberate deviation from EEGLAB, which reads icarejkurt in channel mode and therefore never rejects there. It is documented in the changelog, the test module docstring, and the reference script, which is the right way to carry it.

Verification on develop (b377c3f) + this branch (28b5221) + #323: tests/test_pop_autorej.py 10 passed as part of a 135-test study/autorej run.

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