Repository navigation
[ICA] Record pAMICA rejection with EEGLAB defaults - #674
Conversation
There was a problem hiding this comment.
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.
9d894bf to
607973e
Compare
Map do_reject, numrej, rejsig, rejstart and rejint so a rejecting fit allows three passes. Record the passes that ran as rejection_passes, and name the last iterate returned_iter instead of best_iter. Co-authored-by: Suraj Ranganath <[email protected]>
|
claude review this |
|
claude review this |
Code review
BlockingNone. ImportantNone. NitsNone. Test gapsNone. EEGLAB parity notesNone. Checked for correctness bugs, EEGLAB parity, data structure compatibility, changed-behavior tests, and CLAUDE.md/AGENTS.md compliance. Specific areas checked: |
eeg_pamica now copies pAMICA's rejection settings as the backend ran them (do_reject, rejsig, rejstart, rejint, maxrej) and their outcome (rejection_passes, n_good_samples, n_rejected_samples) into EEG.etc['pamica'], so pipelines that enable rejection can report how many samples were dropped. Adds a test that a rejecting fit records these values and still replays from its record.
Fixes #671
The sentence above this block is from the first draft and is wrong: the pass count is rejection_passes, not numrej. numrej is only the EEGLAB spelling of the maxrej setting.
eeg_pamica applies EEGLAB's AMICA rejection defaults and records the outcome under names that do not collide with those settings. do_reject=True allows 3 passes, EEGLAB's numrej, instead of pAMICA's own maxrej of 1. The passes that ran are rejection_passes. With rejection on, the weights are the last iterate, named returned_iter, and best_iter is omitted because those likelihoods were averaged over different samples.
Settings: do_reject, rejsig, rejstart, rejint, maxrej.
Outcome: rejection_passes, n_good_samples, n_rejected_samples. returned_iter is stored only when do_reject is on. Counts only, no per-sample mask.
EEGLAB runamica15.m pAMICA
do_reject (default 0) do_reject (flag, default False)
numrej (default 3) maxrej (pAMICA's own default is 1)
rejsig (default 3.0) rejsig
rejstart (default 2) rejstart (iterations counted from 1)
rejint (default 3) rejint (iterations counted from 1)
rejstart and rejint match Fortran AMICA. In pamica 0.4.0, schedule.rejection_due (schedule.py lines 136-149) adds 1 to the 0-based loop index and then uses the same predicate as amica15.f90 line 1136: do_reject and maxrej > 0 and (iter == rejstart or (mod(max(1, iter - rejstart), rejint) == 0 and the pass count < maxrej)). The first pass is iteration rejstart on both sides. Later passes are every rejint iterations. maxrej stops the count. The iter == rejstart arm does not consult the pass count, on both sides.
best_iter is omitted under do_reject, and keep_best is not written into the record. pAMICA leaves keep_best True and does not use it, then returns the last iterate. Storing keep_best: False would say the caller turned the safeguard off, and storing best_iter beside it would still present argmax of the likelihood history as the source of the weights. Those likelihoods are divided by that iteration's good-sample count, so the maximum is not where the weights came from.
Defaults test before this mapping, do_reject=True alone:
AssertionError: {'maxrej': 1} != {'maxrej': 3}
Omitting 4 identical items: do_reject True, rejsig 3.0, rejstart 2, rejint 3.
After, eeg_pamica(EEG, max_iter=4, do_reject=True):
{'do_reject': True, 'maxrej': 3, 'rejsig': 3.0, 'rejstart': 2, 'rejint': 3, 'rejection_passes': 1, 'returned_iter': 3, 'n_good_samples': 2954, 'n_rejected_samples': 46}
test_do_reject_alone_records_the_runamica_rejection_defaults PASSED
Fixes #671