Repository navigation
pop_select: keep continuous point ranges in points so the last sample is not kept - #1008
arnodelorme wants to merge 2 commits into
Conversation
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Code reviewIndependent review by Codex (OpenAI GPT-6.1 Terra), asked by the orchestrator. The first version of this change was written by Gemini 4 Carbon and the present version (commit b887b4c, one added branch) by Claude Fable 5.2, so the reviewer is from a third vendor. Codex read the diff against develop in a read-only sandbox and found nothing blocking. It could not run MATLAB, so its review is a reading of the code. The runs are in the description of the pull request. Finding 1, a nit, left as it is. Codex notes that the comment says the regions are built as in the time code, although that code tests for time 0 and not for Finding 2, a remark, nothing to fix. A range far after the end of the data is still refused by the checks that this pull request does not touch, as on develop. Measured on 300 odd calls: the same 32 errors on the same calls before and after. What I fixed before this review. My own check of the first version found that it changed three kinds of out of range The text of Codex, unchangedNo blocking findings. The new branch preserves the intended point selection for the cases reviewed, including multirow and reversed ranges, subject to the existing validation checks. Epoched data with Nit, pop_select.m:568: The comment says the regions are built as in the time path, but that path tests for time zero rather than Out of range caveat: The three examples have the requested results if they pass the unchanged checks. For example, with Column vectors and other inputs without two columns are rejected before the new branch. I found no new indexing error for empty rejection regions. This is a source review only. MATLAB and Octave were unavailable for execution. — orchestrator |
Fixes #1007.
pop_selectkept the last sample of a continuous recording when a point range ended one sample before it at 300, 1024, 2048 and 30000 Hz. The cause is the trip of the point range through seconds:eeg_point2latrounds times to1e-9s, and the limit converted back witheeg_lat2pointfell1e-7sample after the end of the data. This pull request adds one branch topop_select.m(43 added lines, no line removed or changed): when the range was given in points ('point','nopoint','rmpoint') on continuous data, the regions to reject are built in points. The same change is in sccn/eegprep pull request 881, and the test is in sccn/eeglab_tests pull request 20.Example (10 samples holding
0to9, MATLAB R2025b)579a27d0d)b887b4c35)pop_select(EEG, 'point', [3 9])at 300 Hz2..9), one too many. The last region starts at point10.000000100000001,eeg_lat2pointflags it and the region[10 10]is dropped2..8), as requestedpop_select(EEG, 'nopoint', [10 10])at 1024 Hzpop_select(EEG, 'nopoint', [2 4])at 1024 Hz with an event on sample 2pop_select(EEG, 'point', [3 10])at 300 HzComparison with EEGPrep (MATLAB R2025b against Python 3.11, every point range
[a b]witha < bon 10 and on 37 samples at 100, 128, 250, 256, 300, 500, 512, 600, 1000, 1024, 2048, 4900 and 30000 Hz)'time','notime','rmtime', on a sample and between samples)'nopoint'and'rmpoint'regions that touch the start or the endEEG.xmax, boundary events, latencies,com)The 15 and the 12 calls that differ between the two programs are old differences that this pull request does not touch: keep ranges that overlap or are not in increasing order (EEGPrep sorts and merges them, EEGLAB does not), and point ranges on epoched data (EEGPrep keeps one more sample). They are listed in the EEGPrep pull request.
Why the change is in pop_select.m, and why it is one added branch
A range given in points is already in the unit that
eeg_eegrejtakes. The trip through seconds added an error of up to0.5e-9 * sratesample, which is not floating point round-off:10.0000001is really after the end of the data, soeeg_lat2pointis right to flag it, andeeg_point2lat.mcannot stop rounding without changing its other callers. The other two candidates (deciding "this limit is the end of the data" with a tolerance, or snapping a time close toEEG.xmax) keep the trip through seconds and need a threshold that depends on the sampling rate. Keeping points in points needs no threshold and is exact at every sampling rate.The checks above the new branch (
g.timeandg.notimecomputed witheeg_point2lat, clipped, with their messages and errors) are not touched, so that a call refused today is refused the same way and a message printed today is printed the same way. The new branch only replaces what was passed toeeg_eegrej. It repeats the lines of the time code below it with sample 1, sampleEEG.pntsand a step of one sample, then clips points after the end and drops a last region clipped to zero length, aseeg_lat2pointand lines 591 to 594 did. Epoched data (EEG.trials > 1) takes the first branch of the sameifand never reaches it.What else changes, and what does not (300 edge calls, 25 changed)
300 calls with odd or wrong input on 10 and 37 samples at 100, 300 and 1024 Hz, with three events, compared on values,
EEG.xmax, events, messages, errors andcombetween develop and this pull request (edge.m):singleclass, two ranges) and'nopoint', [10 11]at 1024 Hz'point', [2.5 7.5]at 1024 Hzint32'point', int32([3 9])returned an empty dataset, integer arithmetic ineeg_point2lat)double)comis the same in all 300 calls. A region completely after the end of the data ('nopoint', [11 11]on 10 samples) still removes nothing, and a range that passes the end ('point', [3 50]) is still clipped.Adjacent keep ranges (sccn/eegprep issue 864,
'point', [1 3; 4 8]) are not part of this pull request: the call still returns0, 1, 4, 5, 6, 7on0:9, and none of the 135 multi range calls changes.Tests
Tests of
sccn/eeglab_testsin the folders ofpop_select,eeg_lat2point,eeg_point2lat,pop_epoch,eeg_eegrej,eegrej,pop_selectevent,pop_comperp,pop_autorej,eeg_interp,eeg_insertbound,eeg_checkchanlocsandmmo(sccn/eeglab_testshas no folder forpop_rejcontoreeg_checkset): 46 pass before and after.test_check_eeglab_mmofails before and after becausepop_firwsis not installed in the worktree. The new testpass_point2latfails on develop and passes here.The branch has two commits because the first version of the fix (
2ca1ff72d) moved the checks into points as well, which changed 3 kinds of out of range'nopoint'calls into errors. The second commit (b887b4c35) restores the checks of develop and keeps only the added branch. The difference with develop is the 43 added lines.— orchestrator