Repository navigation
[IO] Import EDF and BDF files with EEGPrep's own reader: BIDS import and File > Import data - #868
arnodelorme wants to merge 24 commits into
Conversation
The NumPy EDF/BDF reader no longer passes EDF+D files with gaps to MNE: it joins the records as BIOSIG does in MATLAB. Channels at different sampling rates are repeated up to their common rate and a file shorter than its header announces is read up to its last complete record, both as in EEGLAB. tools/edf_bdf_reader_compare compares this reader and neo's EDFRawIO with EEGLAB's pop_biosig on a collection of files (issue #865).
It stays reachable from the previous commit for the issue and the pull request.
pop_readedf imports EDF, EDF+, BDF and BDF+ files with EEGPrep's NumPy reader, with nothing to install. Its entry, From EDF/EDF+/BDF/BDF+ files (EEGPrep reader), follows EEGLAB's two BIOSIG entries under File > Import data. Tests compare EEGLAB's test.bdf and test.edf with the values of pop_biosig in MATLAB (issue #865).
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.
# Conflicts: # docs/source/changelog.rst
Review of pull request 868: the BDF Status channel counts in the common rate as in BIOSIG, events are sorted by latency, and an annotation duration in an EDF+D file with gaps counts recorded samples only. The comparison tool notes when two readers give different labels for the same number of channels.
Code reviewThis pull request was reviewed by two other AIs, both read-only on commit 712e566: Gemini 4 Carbon at medium effort (through agy), which asked for changes with four findings it rated blocking, and Codex, model GPT-6.1 Terra, which asked for changes with five findings rated "should fix". The blocking findings are all fixed, in commits 38365e8, bbb7443 and 12f6d17. After the fixes the reader gives the same data on every file of the comparison. Gemini 4 Carbon, blocking, all fixed
Gemini 4 Carbon, should fix or minor
Codex GPT-6.1 Terra
Check that the fixes moved nothing away from EEGLAB
— orchestrator |
Status triggers are decoded from the records already read, so a shortened BDF file keeps the triggers of its complete records. Annotations are read one record at a time and placed with time stamps that need not be in order, and one after the last record is dropped exactly. A record duration or a sample count of zero is refused with a clear message. Samples are calibrated before they are repeated. The pop_readedf test compares the command with a POSIX path, and a console test is added.
EEGLAB's pop_biosig reads all 60 records of test.edf when its header announces 0 data records (MATLAB R2025b). The reader refused such a file; it now reads the complete records, as for a header that announces -1.
# Conflicts: # docs/source/changelog.rst
Question 3, the ds003343 files: EEGLAB reads them correctly, the new reader does notArno asked by email on November 29, 2026 to look at the EDF specification and at the signals before he chooses. The check reverses what this pull request says about these files.
Numbers for the two files of the comparison
— orchestrator |
Arno's answer 1b on pull request 868. The records stay joined and the data do not change. Each gap gets a boundary as eeg_eegrej writes it in EEGLAB: half a sample before the first sample after the gap, duration the missing time in samples, not rounded (NaN where two records overlap, as pop_mergeset). tests/data/edf_plus_d_gaps.edf is the example file, written by tools/write_edf_plus_d_gaps.py.
|
For question 3, this figure shows 3 seconds of one ds003343 file read from byte 4608 (the header-length field, as EEGLAB reads) and from byte 5376 (as the new reader reads): only the first reading gives continuous signals and real triggers, as the comment above explains (#868 (comment)). The second figure (sub-18, run 02) and the script that drew both are in the same commit: figure, script q3.py. Nothing is changed in where the reader starts: this waits for Arno's choice. — orchestrator |
|
Automatic checks and EEGLAB reference workflow on the initial reader implementation. Both workflow runs started for the initial implementation of this pull request have now finished with zero failures. The EEGLAB reference workflow completed and passed all seven suites ( On commit — orchestrator |
|
Question 2 is answered and done: the last channel becomes events only when it holds triggers. Arno answered "2a. Yes, leave it out. The last channel can stay as a data channel", and asked for the same test in EEGLAB and EEGPrep, with a pull request on EEGLAB if needed. What was found. On the 17 files of the comparison where EEGLAB's rule fired, it was right 4 times and removed a signal 13 times. The number of different values cannot decide alone: a contact quality channel (values 0 and 4) and a saturated channel (2 values) look like a trigger channel. The rule now, the same in both programs. The last channel becomes events and is removed only when its label names a trigger channel ( Result. The channel count differed from EEGLAB's on 19 of the 44 files both programs read. It now differs on 2, the two ds003343 files of question 3, which is still open. In the four files where the channel becomes events, the events are those of EEGLAB (same types and latencies). EEGPrep follows the EEGLAB branch, not EEGLAB develop, on 13 files until pull request 1005 of sccn/eeglab is merged (biosig2eeglab: the last channel becomes events only when it holds triggers: sccn/eeglab#1005, branch Details
— orchestrator |
Question 1, answer 1b: a boundary event at each gap of EDF+D and BDF+D filesArno answered by email on November 29, 2026: "1b. Add boundary to each gap, but file an issue for EEGLAB along with an example file the requirement to test against Python. After that, create a pull request in EEGLAB." This is done in commit 84d3498 of this branch.
The rules, and why
The example file and the tests
— orchestrator |
After the review by Codex GPT-6.1 Terra. A difference of less than one sample between two records is no longer a gap: no sample is missing, and eeg_checkset in EEGLAB removes a first boundary shorter than one sample, so both programs now return the same boundaries. The example file writer also gives the BDF+D twin of the file, used by a new test.
Code reviewWho reviewed. Codex with the model GPT-6.1 Terra read the EEGLAB change (pull request 1005 of sccn/eeglab: sccn/eeglab#1005) and its Python port (pull request 868 of sccn/eegprep: #868), read only. Gemini 4 Carbon (Medium) was asked first through agy and gave no answer in 10 minutes. The code was written by Claude (Fable 5.2). Its verdict. One finding marked blocking and six smaller ones. It found the event loop faithful to MATLAB (first sample, last sample, negative and fractional values) and the channel removed consistently (data, labels, channel count, mixed sampling rates). Fixed.
Left, and why.
— orchestrator |
Code reviewThe boundary events at the gaps of EDF+D and BDF+D files were reviewed by another AI, read-only: Codex, model GPT-6.1 Terra. It read the three changes together (commit 84d3498 of #868, the first commit of sccn/eeglab#1006 and the test of sccn/eeglab_tests#19) and asked for changes, with four findings it rated blocking and four rated "should fix". Gemini 4 Carbon at medium effort (through agy) was asked first with the same text and had returned nothing after 20 minutes. Three of the blocking findings and one other are fixed, in commits 9d97943 (sccn/eegprep), 49a92d04c (sccn/eeglab) and 5b8a3e7 (sccn/eeglab_tests). Four are left, with the reason for each. Fixed
Left, and why
After the fixes: the 59 tests of the two EEGPrep test files pass, the 9 EEGLAB tests pass in MATLAB R2025b, the 55 files of the EEGPrep comparison are identical before and after the fix commit, and on 54 files EEGLAB develop and EEGLAB with the change differ only by the boundaries of the two files with gaps, which are the same as EEGPrep's. — orchestrator |
After the review by Gemini 4 Carbon. A text boundary after numeric BioSemi triggers was not found by the functions that look for boundaries, which read the type of the first event. As eeg_checkset does in EEGLAB, event types that mix numbers and text all become text when a boundary is added. The boundary type is now taken from the events sorted in time.
Code review, second reviewerThe review by Gemini 4 Carbon at medium effort (through agy) arrived after the comment above, 22 minutes after it was asked. It read the first commits, before the fixes made for Codex, and also asked for changes, with 5 findings it rated blocking, 3 "should fix" and one nit. Four repeat findings of Codex that were already fixed or answered. Two are new and fixed, in commits 169f1a3 (sccn/eegprep) and the third commit of sccn/eeglab#1006. New and fixed
Already fixed for Codex: the wrong offset of BIOSIG in BDF+ files, annotation channels that are not next to each other, a first boundary shorter than one sample (Gemini adds that Left, and why
After these fixes the 60 tests of the two EEGPrep test files pass, the 9 EEGLAB tests pass in MATLAB R2025b, and the 55 files of the EEGPrep comparison are unchanged. — orchestrator |
# Conflicts: # docs/source/changelog.rst
|
Checks after the boundary events at the gaps of EDF+D and BDF+D files (answer 1b), on commit 169f1a3 and on the branch head bdd972c. This is the final state of the automatic checks of the three pull requests on November 29, 2026 at 11:41, once the two code reviews were answered and the reference workflow finished.
Next step, if Arno asks for it: moving the pinned EEGLAB commit — orchestrator |
|
Last channel rule (question 2): the checks passed, and the rule is now in EEGLAB develop. This closes the work on Arno's answer 2a.
Question 3 (the two ds003343 files) is untouched and still waits for Arno's choice. — orchestrator |
|
🤖 Review (Claude Fable 5.2), on the branch merged with develop ( The branch was written by Gemini 4 Carbon and reviewed twice on November 29 by Codex and Gemini. This is a third read by another vendor, of the whole reader (
Important
Open question, unchanged
Checked, no change needed
Nits
|

EEGPrep now reads EDF, EDF+, BDF and BDF+ files with its own NumPy reader in the BIDS import and in a new entry of File > Import data, with no BioSig, no MNE and nothing to install (issue #865).
The new entry opens a file chooser and has no window of its own, so the menu is the only thing to show. Both captures were taken on jamming with the menus really open. The EEGLAB window was enlarged to 1000 by 640 pixels first, because MATLAB R2025b draws its menus inside the figure and cut them at the default size.
EDFRawIO. On 55 files it reads all 44 files EEGLAB reads and is at exactly 0 µV from EEGLAB'spop_biosigon 42 of them. neo reads 38, is at 0 µV on none (median 0.54 µV, thousands of µV on BDF) and needs the compiledpyedflib.pop_readedf. It comes right after EEGLAB's two BIOSIG entries, whose order is unchanged.pop_biosigand the BioSig menus.agent/issue-812), which is not merged yet: this pull request shows its commits until it is merged. The head of that branch (its commit 00607eb, which turns BioSig off on Windows) and develop were merged in again at 46f8677.Questions for Arno:
tests/data/edf_plus_d_gaps.edf, EEGLAB with that change and EEGPrep return the same data and the same three boundaries.The rule, the same in both programs. The last channel becomes events and is removed only when its label names a trigger channel (
status,trig,event,marker, or a label that starts withsti, in upper or lower case) and it holds few different values (20 at most in its first 100 samples, 1000 at most overall). Any other last channel stays a data channel, andpop_readedf(file, importevent='off')turns the rule off, as'importevent', 'off'inpop_biosig.Totals. On the 17 files where EEGLAB's old rule fired, it was right 4 times and removed a signal 13 times (a sine wave, a block wave, an accelerometer, a contact quality channel, a saturated channel). The channel count of EEGPrep differed from EEGLAB's on 19 of the 44 files both read. With the new rule in both programs it differs on 2, the two ds003343 files of question 3. In the four files where the channel becomes events, EEGPrep gives the same events as EEGLAB (108, 14, 14 and 12, same types and latencies).
EEGLAB. Issue 1004 (biosig2eeglab turns a signal in the last channel of an EDF or BDF file into events and removes it: biosig2eeglab turns a signal in the last channel of an EDF or BDF file into events and removes it eeglab#1004) and pull request 1005 (biosig2eeglab: the last channel becomes events only when it holds triggers: biosig2eeglab: the last channel becomes events only when it holds triggers eeglab#1005). Arno then answered that the label stays required (a last channel with a plain label such as
Ch33stays in the data even when it holds triggers), and at his request that pull request was merged on November 29, 2026 (commit 78e6e2b8 on EEGLAB develop) with its test (Test for the last channel of EDF and BDF files in pop_biosig eeglab_tests#18: Test for the last channel of EDF and BDF files in pop_biosig eeglab_tests#18). EEGPrep therefore follows EEGLAB develop on the 13 files where the rule changed. In the BIDS import the events ofevents.tsvreplace the events of the file as before, and a trigger channel is removed either way, as in EEGLAB's BIDS import.EEGLAB reference run (55 files, MATLAB R2025b)
The table of every file, with where it comes from, is in the comparison comment of issue #865: #865 (comment)
edfPlusD.edf): same 2200 samples as EEGLAB, 0 µV. Since commit 84d3498 the reader adds 5 boundary events (latencies 200.5, 400.5, 1600.5, 1800.5 and 2000.5, durations 200, 200, 400, 400 and 600 samples), which EEGLAB develop does not have and EEGLAB with pop_biosig: boundary event at each gap of EDF+D and BDF+D files eeglab#1006 has. On the 55 files nothing else moved: the 44 other files the reader reads are identical before and after that commit (data and events).edfAnnonC.edf,test_reduced.edf,test_uneven_samp.edf): samples repeated up to the common rate as in EEGLAB, 0 µV.pop_readedfwas run inside Pyodide 0.29.5 (Python 3.13, WebAssembly) with the repository's runnertools/pyodide/run_pyodide.mjson four real files (test.bdf,test.edf,edfPlusD.edf,edfAnnonC.edf). The data are the same to the last bit and the events are the same as in the native run.eeglab-reference.yml): completed and passed all 7 suites (study,core,misc,parity,stats,heavy, andhybrid): https://github.com/sccn/eegprep/actions/runs/46284661990tests/eeglab_tests/__init__.pypins): on commit 5778057, which holds the boundary commit 84d3498 and the last channel rule of answer 2a, all 7 suites passed: https://github.com/sccn/eegprep/actions/runs/46291295040 . An earlier run on commit 2d503d7 had failed in one test ofmisc,tests/test_runica.py::test_reference_runica_extended(a difference of 0.0151 against a limit of 0.0145), in ICA code this pull request does not change, andmiscpassed in the two runs after it. The run on the final commit 169f1a3 (after the fixes of the two reviews) also completed and passed all 7 suites (study,core,misc,parity,stats,heavy, andhybrid): https://github.com/sccn/eegprep/actions/runs/46292727866pop_biosigfix. The remaining three jobs of that run were superseded when commit 2d503d7 was pushed: https://github.com/sccn/eegprep/actions/runs/46287309736Scripts:
tools/edf_bdf_reader_compare.mandtools/edf_bdf_reader_compare.py.What changed in the code
src/eegprep/plugins/EEG_BIDS/edf_bdf.py: gaps joined (nopop_mneio) with a boundary event at each gap (the rules are in the comment on answer 1b), mixed rates repeated up to their least common multiple with a memory guard, shortened files read up to the last complete record.src/eegprep/functions/popfunc/pop_readedf.py: the new function. History commandEEG = pop_readedf('file');. Help pagesrc/eegprep/resources/help/pop_readedf.md.eeglab_menu.pyandmenu_actions.py: the menu entry and its action.raw.py,pop_load_frombids,pop_importbids,bids_preprocand the export wizard already read through the NumPy reader. neo is not used.tests/test_pop_readedf.pyon EEGLAB'stest.bdfandtest.edfwith the values ofpop_biosigin MATLAB, and the reader tests oftests/test_bids_load_frombids_helpers.py.Refs #865, #812, #857, #492.
🤖 Generated with Claude Code