Repository navigation
A2: BrainVision and NIRx text-header readers - #2381
neuromechanist merged 10 commits into
Conversation
📦 Package PreviewYour package is ready to test! bun install -g nemar-cli@PR2381Version: 🤖 Updated on each push. |
* Add the h5py oracle for HDF5 metadata * Add HDF5 fixtures and their h5py oracle output * Add a bounded HDF5 metadata walker * Test the HDF5 walker against h5py * Count logical reads; default cap 20,000 * Review round 1: never throw, shuffle, zero sizes * Bound each fuzz walk at 200 ms
|
Merge gate (lead): head 7840826. Every remote check passes after one rerun of unit-pure shard 1, which was cancelled at the job time limit on its first run. Review: round 1 panel, 2 important findings (regex backtracking on long values; not-applicable evasion) and 3 more fixed; round 2 delta review found 2 further evasions (control bytes on a section line; BrainVision sections without [Common Infos]), fixed in 7840826 and verified by the lead by rerunning the reviewer's probes (each yields findings, none comes back not-applicable, about 5 ms for the long-line probes) and 247 targeted tests. No third round, per the two-round rule. The lead's rulings on companion naming, the marker limit, ages, NIRx free text and the not-applicable contract are in the PR body. |
eb6a76a
into
feature/issue-2182-epic-pq-evidence
Part of #2365. Part of #2182.
Card A2 of the publication-queue plan. It adds BrainVision (
.vhdr,.vmrk) and NIRx (.hdr,.inf) readers, which plug into the A1 registry, so datasets of those formats leave "recordings NOT screened". This revision applies the lead's rulings of 2026-11-25.What changed
shared/readers/brainvision.tsandshared/readers/nirx.ts, with the helpers they share inshared/readers/text-header.ts.partial(limit) and keeps the findings it made..eeg,.wl1,.wl2,.datand.evtare never read; each is claimed as a companion of its header.KIND_COPYentry:brainvision-comment-name(review);brainvision-segment-date(date kind, ADR 0090);brainvision-marker-text(review);nirx-subject-name(identifier, direct);nirx-demographics: an identifier (direct) for a birth date to the day, review for a year or a year and month;nirx-header-date(date kind);nirx-freetext(review).local-user-pathnow also covers BrainVision companion file names, marker descriptions, and NIRx contact and notes fields.ReaderResult.coveragemay benot-applicable. The builder then counts the file as unscreened under its extension, never as read, partial or failed, and does not look for its companions.ReaderResult.notescarries informational notes. The only one iscompanion-name-mismatch: counted ascompanion_name_mismatch(an optional version-2 key, present only when it is not zero), printed with its remedy fromNOTE_COPY, and never gating.FormatReader.extensionLimitsgives.vmrkits own limits.isNameLike,hasDateFinerThanYearanddatePrecisionare exported fromshared/identifier-scan.tsand built on the scanner's existing rules..vhdris removed fromOTHER_RECORDING_EXTENSIONS.KNOWN_FORMATSkeeps.vhdrand adds.hdr,.inf,.wl1,.wl2and.evt.scripts/dev/reader-fp-measure.tsis the shared false-positive script. It runs the screen's ownreadRecordings, optionally against full dataset listings so that companions which were not downloaded still pair, and prints only kinds and counts..vhdras "a format no reader parses" now use Neuroscan.cnt.Lead rulings applied (deviations from the card)
_config).companion_missing, per A1's contract.DataFile,MarkerFileorFileNamenames another file is not a gap: it is the notecompanion-name-mismatch. Its remedy is to correct the entry to the BIDS file name..vmrkand.inf: both are registered and read, andread_by_formatcounts files, not recordings.+or a label such astelorphone, because bare digit groups look like marker codes.name,subject,patient,operator,experimenter), defined intext-header.tsbecause A4 has not merged. Fields that describe the person (age, contact) or name a thing (experiment_name, a file) are excluded..hdrand a Windows.infarenot-applicablefor the NIRx reader, and an AppleDouble._file isnot-applicablefor the BrainVision reader. The test uses a real Analyze header from NiBabel (MIT)..datpairing: a.datis paired by basename only, becausecompanions()never sees file contents.False-positive measurement (final head, after review round 1)
Every downloaded file was deleted afterwards. The per-100 denominator is the files the readers counted: a file a reader found to be another format (
not-applicable) is counted as unscreened and is not in it, so the BrainVision denominator is 668 of the 670 files downloaded. The numbers did not change in review round 1.BrainVision: 670 files (338
.vhdrand 332.vmrk) from 162 public OpenNeuro EEG datasets, at most 3 recordings each, measured against each dataset's full listing. Of those, 668 are BrainVision files; the other two are AppleDouble._files, counted as unscreened.companion-name-mismatchnote.unchecked): 6 of 162, all because a basename companion is missing from the dataset. Before the rulings it was measured without listings (every dataset), and the earlier rule also made every dataset with a mismatched nameunchecked.NIRx (gate waived): 21 files, all of the public NIRx raw headers found: 19 from the MNE testing data and 2 from MNE's
fnirs_motor(OSF).fnirs_motor, for which there is no full listing, so its companions were not visible to the pairing.Tests
test/readers-brainvision.test.tsandtest/readers-nirx.test.tsrun real headers through the registry, the page cache andreadRecordings.test/identifier-coverage-contract.test.tscoversnot-applicableand notes through the fleet scan, the door and the description.test/fixtures/text-headers/README.md. One.vhdrand one.infare edited to hold a made-up name.not-applicable(NIRx and BrainVision back to partial, the builder counting the file as read, the fleet scan not counting it unscreened).bun run typecheck,bun run lint,bunx biome checkon every touched file, and the targeted tests: readers-brainvision, readers-nirx and identifier-fleet, 236 pass and 0 fail.Review round 1
FREE_TEXT_MAX_CHARS(4 KiB) andcapTextlive inshared/readers/text-header.ts, so later readers inherit them.partial(limit).@(64 characters before, 255 after).[Comment]and in a NIRx contact field, and a 16 MiB.vmrkwith one huge description each finish within 1 s, with adversarial words (x@,+1,tel 1, a home path).not-applicableevasion.not-applicableonly when no[GeneralInfo](for.inf,[Subject Demographics]) section exists anywhere and the file starts binary (startsBinary: more than 5% NUL or 10% control bytes in the first 512, never for UTF-16).partial/unsupported-version; a Windows driver.infis now that.[Common Infos]section.decodeHeaderdecodes UTF-16 by its byte-order mark (FF FE,FE FF), or by a NUL in every other byte when there is none.Codepageline declares.not-applicableis decided from the content alone, only when it shows another format, and never for a decode, limit or parse failure.not-applicable; binary NIRx scanned; the BrainVision[Common Infos]rule dropped; NULs kept; the binary threshold widened.Review round 2
decodeHeaderdrops every C0 control character except tab, line feed and carriage return (NUL included) before anything parses the text.not-applicableneeds all three of the following (isAnotherFormatintext-header.ts):Name=,Contact...=,Notes=,Comment=orMk1=key occurs anywhere.partial/unsupported-version.[SUBJECT DEMOGRAPHICS]; a binary start with[Marker Infos]and contact details; a[Comment]name or a datedNew Segmentwithout[Common Infos]; an.hdrwith only[ExperimentNotes]; key-only and lowercase section names. The Analyze and AppleDouble files staynot-applicable.New Segmentand free-text rules removed. The fallback's marker-description pass was redundant with the free-text pass over every line, so it was removed.