Repository navigation
[pop_select] Keep one-sample edge rejections for point ranges - #856
Conversation
A continuous keep range such as point [2,5] produces a complement rejection of [1,1], which the zero-length filter discarded, so sample 1 was retained. eeg_eegrej ranges are inclusive; drop only inverted rows. Fixes #853 Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
|
Claude finished @claude[bot]'s task in 53s —— View job Code review
BlockingNone. Important
NitsNone. Test gapsNone. EEGLAB parity notes
Checked for correctness bugs, EEGLAB parity, data structure compatibility, changed-behavior tests, and CLAUDE.md/AGENTS.md compliance. |
|
Review (Claude Fable): needs more work
How to reproduceOne channel holding 0, 1, 2, ... at 2048 Hz, 122882 samples. pop_select(EEG, point=[2, 5000]) # MATLAB and develop: 4999 samples. This PR: 5000, sample 1 is kept
pop_select(EEG, point=[1000, 122882]) # MATLAB and develop: 121883 samples. This PR: 121882, the last sample is lostThe first line is the bug of #853 itself, moved from 128 Hz to 2048 Hz. The second one also happens with Cause
For a range that ends at the last sample, the trailing region overshoots, EEGLAB has no other filter: every region goes to Suggested change (tested in a private copy, not pushed)pts, flag = eeg_lat2point(notime_mat.reshape(-1), np.ones(nbtimes), srate, [xmin, xmax])
pts = pts.reshape((-1, 2))
# pop_select.m: a last region clamped to zero length is not a rejection
if flag and pts[-1, 0] == pts[-1, 1]:
pts = pts[:-1]
if pts.size:
EEG = eeg_eegrej(EEG, pts)
Please add one test at a rate where 1/srate is not exact, for example the two calls above at 2048 Hz. The 128 Hz sample file cannot see this defect. Numbers: 9243 point ranges against MATLABEvery range
This PR repairs 597 cases and breaks 281 that agreed with MATLAB on develop, all at 300, 1024, 2048 and 30000 Hz. The 129 cases left with the ported rule are at 250, 500 and 1000 Hz, for a range that ends one sample before the end. There EEGLAB itself keeps the last sample, because its out of range test has no tolerance, and Python returns the requested range. Example in MATLAB: 500 Hz, 30000 samples, Other checks
— orchestrator review |
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Code reviewIndependent review by Codex (OpenAI GPT-6.1 Terra, high reasoning effort), asked by the orchestrator, which made the change with Claude Fable. Codex read commit 71f5178 in a read-only sandbox and recommends not to merge yet. Its one blocking finding is real but is EEGLAB's own behaviour, so I left it and it is a question for Arno. Its text follows unchanged at the end. The change. The filter of this pull request is replaced by a direct port of Parity on the point ranges (every range
What was done with Codex's findings
Needs Arno
How the numbers were madeMATLAB R2025b, EEGLAB commit 4207693, Codex's review, unchangedBlockingAdjacent keep ranges can lose valid data at pop_select.py:503. With ImportantThe port is not exact at pop_select.py:503. Row major flattening followed by row major reshaping preserves the same endpoint pairs as MATLAB’s column major flattening and reshaping here, because conversion is elementwise. However, eeg_lat2point.py:71 sets Rejection behavior needs careful separation at eeg_eegrej.py:96. The called Repository requirements are incomplete. The change alters user visible behavior but includes no Sphinx update, contrary to NitsNone. Test gapsAt test_pop_select.py:150, the first new test checks removal of both the first and last samples, their boundaries, and the retained data. It would fail with the old equal endpoint filter. The next test also exercises first sample removal and a range ending at the last sample. Add cases for adjacent keep ranges, a one sample gap between keep ranges, explicit one sample removals through all four aliases, and an unsorted set of ranges. Also test a final equal row when another row causes For derived complements, Python sorts keep ranges before constructing them, so the last generated rejection is the latest in time. Explicit removal ranges retain their input order, so their last row need not be the latest. I cannot confirm MATLAB’s full ordering behavior because the requested MATLAB file is absent. The local Python source is the primary evidence for this review, credibility 10/10 for the checked checkout. I ran targeted Python examples, not the full test suite. The live PR head and MATLAB reference behavior remain unverified. Merge recommendation: Do not merge yet. Fix the data loss, resolve the parity and documentation issues, and complete the required reference validation. — orchestrator |
# Conflicts: # docs/source/changelog.rst
|
Adjacent keep ranges. EEGLAB removes the two samples where two keep ranges touch ('point', [1 3; 4 8] keeps 6 of 8 samples). (a) Keep EEGPrep equal to EEGLAB, as now. (b) Keep all requested samples in EEGPrep and fix EEGLAB too. For this keep EEGLAB range, but keep the issue open and we will fix it in both EEGPrep and EEGLAB later. The last sample at 250, 500 and 1000 Hz. (a) Leave EEGPrep as now: it returns the requested range and differs from EEGLAB in 129 of 9,243 ranges. (b) Remove the tolerance in eeg_lat2point.py for exact parity (0 of 9,243), which copies EEGLAB's defect. (c) Fix eeg_lat2point.m in EEGLAB. We will fix EEGLAB, so keep EEGPrep like this. |
# Conflicts: # docs/source/changelog.rst
|
Arno answered question 2 of the review above on November 29, 2026: "OK, fix EEGLAB and compare with Python. Create a pull request in EEGLAB", and "We will fix EEGLAB, so keep EEGPrep like this." This is the result. EEGPrep stays as it is: nothing is changed in this pull request or in
— orchestrator |
|
🤖 ## Code review Independent review by Google Gemini (model Gemini 4 Carbon, medium effort, through agy, with no right to write), on commit 75e659d. Its verdict is "good to merge", with nothing blocking and nothing important. It was asked to review only what was added today, since the rest of this pull request was reviewed by Codex yesterday and its one blocking finding, the two keep ranges that touch, is now decided by Arno (keep EEGLAB's result, issue #864). What was added today. Develop is merged into the branch. The only conflict was the changelog, where both entries are kept. One test is new, Finding of Gemini and what was done
Checks run today
— orchestrator |
|
🤖 I merged this pull request into develop, at Arno's request. Why. Arno's standing instruction of November 28 is to merge once his answers are applied and another AI has checked the change. His two answers of November 29 on this pull request ask for no change of behaviour: for two keep ranges that touch, "For this keep EEGLAB range, but keep the issue open and we will fix it in both EEGPrep and EEGLAB later", and for the last sample at 250, 500 and 1000 Hz, "We will fix EEGLAB, so keep EEGPrep like this." Why it was good to merge.
What stays open. The two samples lost where two keep ranges meet, in EEGPrep and in EEGLAB, are the subject of pop_select: two keep ranges that touch lose the two samples where they meet (EEGLAB too). The repair of — orchestrator |
Continuous
pop_selectpoint ranges that start at sample 2 or end one sample before the last one kept the edge sample.point=[2, 5]on 0:9 now returns 1:4, as in MATLAB.Comparison with EEGLAB (MATLAB R2025b, EEGLAB 4207693): every range
[a, b]of a recording of 10 and of 37 samples at 13 sampling rates from 100 to 30000 Hz, 9,243 ranges. Run again on the final head of this branch on November 29, 2026.Distance between MATLAB and Python, in samples per range: 0 for 9,114 ranges and 1 for 129 ranges. The 160 calls on recordings of 30,504 to 122,882 samples at 128, 300, 2048 and 4096 Hz all equal MATLAB.
Arno's two decisions (his comment of November 29, 2026):
eeg_lat2point.mgoes into its own pull request on sccn/eeglab.pop_select(EEG, 'point', [1 3; 4 8])keeps 6 of the 8 samples asked for, in EEGLAB and in EEGPrep. "For this keep EEGLAB range, but keep the issue open and we will fix it in both EEGPrep and EEGLAB later." The open point is issue pop_select: two keep ranges that touch lose the two samples where they meet (EEGLAB too) #864, pop_select: two keep ranges that touch lose the two samples where they meet (EEGLAB too). The new testtest_adjacent_keep_ranges_match_eeglabholds the EEGLAB result and names pop_select: two keep ranges that touch lose the two samples where they meet (EEGLAB too) #864, so the later fix changes it on purpose.Cause and change
The cause was a Python-only filter that dropped one-sample regions. It is replaced by a direct port of
pop_select.mlines 587 to 596: every region goes toeeg_eegrej, and only a last region clamped to zero length byeeg_lat2pointis dropped. One-samplenopoint,rmpoint,notimeandrmtimeregions now remove their sample.Verification
tests/test_pop_select.pyandtests/test_eeg_eegrej.pyon the final head (75e659d): 53 passed, 2 skipped (they need the MATLAB Engine for Python, which the test Mac does not have), 16 subtests passed. Ruff andpre-commit.pypass.EEGLAB reference run (rule of pull request #860)
pop_select: two intest_coregister_parity.py, one each intest_dipfit_bem.py,test_study_clustering.py,test_phase2_file_channel_location.pyandtest_package_help.py. The same six fail on develop itself at db5cff9 (run https://github.com/sccn/eegprep/actions/runs/46217339941), and develop repaired them since in [CI] Fix five EEGLAB reference failures on develop #691 and [GUI] Expose native format readers and document the FieldTrip alternatives #850. All 45 tests oftests/test_pop_select.pypassed in that run.Fixes #853