Repository navigation
IS-J1: robust, honest join of channels to contacts - #557
Merged
neuromechanist merged 8 commits intoNov 18, 2026
Merged
Conversation
153 public files and Zarr label excerpts from 24 recordings of 23 datasets, with dataset, version, path, URL and SHA-256 in SOURCES.json, and the loader the next tests share.
Ordered tiers (exact, normalized, suffix, close) as a table of named rules read from the survey, ambiguous_name for two readings, claims so an exact name keeps its contact, and the file's own coordinate cells carried through the parser. close has no rule: the one candidate is right in one dataset and wrong in another. Tests read the committed real recordings; each of the card's six mutations fails its test.
Rows, titles, the Selected lines, notes and the status line name the contact as recorded, the channel beside it and the kind of match; the recorded line is the file's own text with its unit word and frame; an approximate match is drawn half transparent. Unit, provenance and headless e2e tests; on005415 now has a Brain toggle.
Counts per pattern over 328 recordings of 93 datasets, each rule's rows, and the pending patterns with the reason.
Deploying nemar-website with
|
| Latest commit: |
474cb44
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://61e0c147.nemar-website.pages.dev |
| Branch Preview URL: | https://feat-is-j1-robust-join.nemar-website.pages.dev |
Near-miss names (A1-2, A1-AVG, pol A3, A1-Reference and more) are pinned unlocated so a loosened rule anchor fails a test; zero padding never carries a name across a shaft (L01 does not join L1 beside L0); bipolar pairs are claimed like contacts (POL A1-A2 does not take A1-A2); the -AV and -REF sentences say what the name does, not what it means; P3 evidence corrected (CH0 to CH31 plus four state_* channels); the close marker's opacity limit is documented; the alpha test uses a literal. Each new test fails under its mutation.
scripts/ieeg-channel-survey.ts re-derives the note's counts (name-resolved and located, the _channels.tsv corroboration, per dataset) over the committed list of 338 recordings; --sample draws a fresh list. Three runs the same day agree.
How to re-derive the counts, what channels and located mean, the _channels.tsv corroboration by rule and dataset, and the corrected P3 evidence.
Non-exact POL A1-A2 and POL A2-A1 both refuse (duplicate_contact) while exact A1-A2 and A2-A1 both stay; the reason is documented at settleClaims. Behavior unchanged. The sorted-key mutation now fails this test.
neuromechanist
merged commit Nov 18, 2026
6cba53d
into
feature/issue-537-epic-spatial
5 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Card IS-J1 of the iEEG spatial view plan (the intracranial track of epic #537, ADR 0033).
Part of #537.
What changed
The panel joined a recording's channels to electrode contacts by exact name, so a dataset whose Zarr store names a channel
LTP1-20000where the BIDS electrodes sayLTP1(on005415) never got a Brain toggle.The join now runs ordered tiers, every non-exact join carries its kind and is said in the panel and the files, and anything ambiguous refuses with a cause.
src/lib/ieeg-spatial/channel-match.ts(new): the tiersexact,normalized,suffix,closeas a table of named rules, each with its pattern, a real example, the datasets that need it and its sentence;PENDING_PATTERNSfor what the survey saw and no safe rule joins;matchName,settleClaims.normalized:whitespace(LENT 1forLENT1),type_prefix(POL A3,EEG A1-Ref, andPOL A1-A2as a bipolar pair),leading_zeros(LSF1forLSF01, either side).suffix:reference_name(O1-REF1, read as a reference),average_reference(A1-AV, read as the average reference),numeric_tail(LTP1-20000: four or more digits, and never when the shaft plus those digits is itself a contact). The sentences say what the name does, not what it means: no dataset states the meaning (iEEGReferenceisn/awhere checked).close: the tier, its tag ("approximate name match"), its marker and an engine-level guard (exactly one removed shaft letter, same index) exist; the rule table is empty (see Deviations).ambiguous_name, listing both candidates); it never takes the first and never falls to a lower tier.duplicate_contact).src/lib/ieeg-spatial/geometry.ts:joinChannelsuses the tiers (exact name, then the exact bipolar split, then the tiers); every join hasmatchKindandrule;Contact.rawcarries the electrodes row's own x, y, z and size text through the parser.src/lib/ieeg-spatial/export.ts,panel.ts,src/styles/eeg-viewer.css:contactTitle(the one place) now saysLTP1 (channel LTP1-20000 [suffix match]); recorded (...) m, frame: ACPC; list rows show the contact as recorded, the channel in parentheses, a small tag and the rule's words as its tooltip; a selected channel readsLAF1-LAF2 (contacts LAF1, LAF2; midpoint)orLTP1-20000 (contact LTP1; suffix match); the status line addsjoined by name rules: 646 suffix match; one note per rule chain says how many joined and shows three real name pairs; unlocated channels are listed by original name with their cause (a name that fits two contacts says which, a channel that lost its contact says whose it is). The files carry the same sentences because they read the same model.-7.589096499647889e-05,-5.0,63.150000000000006stay as written), with the file's own unit word (m,cm,mm,pixels) and the declared frame; asizethe file gives is added as written,n/aand empty are left out..context/research-ieeg-channel-names.md(new) and a pointer in.context/research.md: the survey, dataset ids and counts only.scripts/ieeg-channel-survey.tsand.context/research-ieeg-channel-names-recordings.json(new, review round 1; a scope addition the review asked for): the script re-derives every count of the note from live data over the committed list of 338 recordings (--sample <file>draws a fresh list); the last two runs produced identical tables.test/fixtures/ieeg-channel-names/(new): 153 real files and Zarr label excerpts from 24 recordings of 23 datasets, with dataset, version, path, URL and SHA-256 inSOURCES.json(each excerpt also carries the hash of the full upstream response);test/ieeg-channel-fixtures.tsis the shared loader.Survey (2026-11-18, 93 usable datasets, 328 recordings, 33,834 channels)
A1-AVaverage_referencePOL A3;POL A1-A2type_prefixLTP1-20000numeric_tailO1-REF1reference_nameLENT 1whitespaceLSF1forLSF01leading_zerosPOL A1-AV;EEG A1-Refstate_*), or no row for the contactRules S3 to S11 join 4,311 channels (12.7 percent) in 18 datasets; in 14 datasets the sampled recordings had nothing the old join could place and now have a Brain toggle (nm000379, on004551, on005007, on005415, on005545, on005670, on005931, on006107, on006233, on006910, on006914, on007118, on007119, on007120).
Each implemented rule cites its row in the note.
"Channels" is name-resolved: a channel whose contact the file leaves at
n/astill counts, so the panel places 4,301 of the 4,311 rule joins (S5: 646 name-resolved, 638 located, the other 8 beingEKG*-20000channels). Reproduce withbun scripts/ieeg-channel-survey.ts.Corroboration by each dataset's own
_channels.tsv(the row at the Zarr row's index names the contact): 646 of 646 for S5 (on005415), 1,157 of 1,157 for-AVin on006107, on007118, on007119 and on007120, 209 of 209 for on004194's padding; 3,228 of the 4,311 non-exact joins (74.9 percent) have the contact in the dataset's own channel list. The check is silent where the dataset's file repeats the store's label (nm000379, on004473, on005398, on005670 sub-02, on003848) or is absent (on005670 sub-01); those joins rest on the survey reading, which the note says.Gates (measured at head aaf2fc4 after review round 1, round 2 below; the epic tip d162257 is the base; nothing newer to merge)
bun install --frozen-lockfile:Checked 416 installs across 568 packages (no changes)bun run typecheck:Result (517 files): 0 errors, 0 warnings, 19 hints(the base's 19)bun run lint:Checked 445 files in 216ms. No fixes applied.(andbiome check scripts/ieeg-channel-survey.ts:Checked 1 file in 5ms. No fixes applied.)bun run test src/lib/ieeg-spatial:Test Files 12 passed (12),Tests 447 passed (447)bun run test:Test Files 189 passed | 3 skipped (192),Tests 5473 passed | 14 skipped (5487)E2E_PORT=4417 PUBLIC_DATA_BASE_URL=https://data.nemar.org bun run test:e2e e2e/ieeg-spatial-panel.spec.ts(headless, dev server):28 passed (2.5m)(the 26 earlier tests, two of whose patterns now saysize -999because the recorded line is verbatim, and 2 new). Two earlier runs stopped before the end (serial mode skips the rest): one on a transient data-plane 500 (a directory listing past the quiet retries, in the failed-read test, while the embed's own landing fetch also logged an upstream error), one on two patterns of mine that neededsize -999; the third run passed 28 of 28.bunx astro buildandgzip -9c <chunk> | wc -c, base and head built the same way: panel chunk 90,024 raw and 33,013 gzipped at the base, 99,124 raw and 36,109 gzipped here (+3,096 gzipped; the owner's budget is 64 KB, so 35.3 KB used); viewer chunk 166,137 raw and 58,277 gzipped at the base, 58,280 here (a file name hash). The pending table is only imported by tests, so none of its text is in the chunk.Revert checks
Each is one line mutated, the named tests fail, the line is reverted,
git status --porcelainclean afterwards (run twice, the second time on the final code).String(x)(2); unit word rewritten to mm (2); no approximate marker (1); bipolar channel line dropped (2); match notes dropped (2); ambiguous candidates hidden (1); size cell dropped (1).Deviations from the card
closehas no rule. The card's stop condition applies: the one surveyed candidate (a doubled shaft letter) is right in on003374 (mmAL1formAL1) and wrong in nm000454, whereDHAAis a real shaft the file lacks and the edit would put four channels on shaftDHA. A general edit distance would join left and right shafts (AL,AR). The tier, its tag, its marker, the status wording and a guard that allows only one removed shaft letter with the same index are in place and tested with rule tables of the tests' own (matchName,joinChannelsandplaceContactstake an optional rule table), on real contact names. nm000454 is pinned as the counterexample.closemarker is opacity (0.55), through the colors the panel already hands to the 3D renderer and the 2D views, because the card keeps the renderer out of scope; the tag, the status line and the "[approximate name match]" in titles say it in words. Known limit, documented atAPPROXIMATE_ALPHA: while anything is selected the other contacts are dimmed to 0.3 and the selected one is drawn in full, so the opacity cue is gone then. Nothing is affected today (no shipped rule joins byclose); the first close rule must add a cue that is not opacity (a ring or marker in the renderer and the 2D views).normalizedhas three rules, not the card's five. Case, Unicode lookalikes and theSEEGprefix are not in the survey (no name outside ASCII among 69,806; no label starts withSEEG; case differences occur only in on004624, where the labels runCH0toCH35against contactsCh1toCh32, so a case-folded join could be off by one). They are inPENDING_PATTERNSwith that evidence.type_prefixalso reads a bipolar pair after the word, and rules chain (EEG A1-Refistype_prefix+reference_name).numeric_tailneeds four or more digits, soA1-2(a bipolar pair in short form) andT7-1are never read as a tail. The tail's meaning is not stated by any dataset (iEEGReferenceisn/ain all six datasets checked); the rule rests on the survey and is corroborated by the dataset's own_channels.tsv, which names the joined contact at the same row for 646 of 646 channels in on005415.-AVis the same kind of reading, corroborated the same way in four of its five datasets (1,157 of 1,157). Both sentences say what the name does, not what it means., size Xwhen the file gives a size other thann/aor empty, as written and with no unit of ours (on005522 writes-999).(channel X)in parentheses.scripts/ieeg-geometry-census.tsis not edited: the census classifies geometry, and the join is not part of its classes.Review round 1 (head aaf2fc4)
No Critical and no false join were found; the deviations were accepted (no
closerule, the engine kept,-AVkept with rewording, opacity deferred). Fixed:A1andA3copied from real rows (A1-2,A1-9,A1-999,pol A3,Eeg A3,EEG A3,XEEG A3,A1-AVG,A1-AV2,A1-av,A1-Reference,A1-Ref+3; contactsA1andA3because a refusal ofpol A3shows nothing unlessA3exists), so a loosened anchor fails; a repeated identical label at the winning tier is tested (the redundant first guard ofsettleClaims, which only shielded an equivalent mutation, is removed).-AVand-REFsentences and patterns now say what the name does, "read as the average reference" and "read as a reference"; no dataset states either meaning.CH0toCH31plus fourstate_*channels (36 in all) against contactsCh1toCh32; the fourstate_*channels are signals (N1), so P3 is 192 channels, N1 891.scripts/ieeg-channel-survey.tsand the list of recordings are committed; the note says how to re-derive the counts, that "channels" is name-resolved including channels with no position (the "Located" column is what the panel draws), and gives the_channels.tsvcorroboration by rule and dataset. Where the file is silent (it repeats the store's label, or is absent) it says so; the measured agreement is stronger than the survey reading for S5, S3 (four of five datasets) and on004194, and silent for S7 and S8.L1andL0:L01does not joinL1; both directions), and the surveyed padding is untouched (S9 counts unchanged).duplicate_contact, the same word as for one contact (the pair is listed ascontacts).POL A1-A2besideA1-A2is refused;A1-A2andA2-A1, both exact, both stay as today; two differently written non-exact names for one pair both lose it; a contact and a pair never compete.APPROXIMATE_ALPHAandcontactColors(and in deviation 2). No shipped rule joins byclose, so nothing is affected today; the first close rule must add a cue that is not opacity. The text cues (the tag, the status line, the title) stay.Revert checks (one line mutated, the named test fails, reverted, tree clean afterwards), one per new test:
{3,}to*in the numeric tail (the near-miss test fails); the type prefix to any word, and with/i(the same test);-AV$to-AV.*$(same);-ref\d*$to-ref.*$(same);topLabels.size === 1totop.length === 1(4 tests, among them the repeated-label ones); the-AVsentence and the-REFsentence back to the old words (1 test each); P3 back toCH35(1); the shaft guard removed (2); pair claims skipped (2); exact pairs refusing each other (1);APPROXIMATE_ALPHA0.55 to 0.5 (1). The earlier 18 mutations (the card's six and the display and verbatim twelve) were rerun on the final code, head aaf2fc4, and each still fails its tests (suffix off 17, suffix first 1, take first 4, close guard 1, claims skipped 6, pending reason 2, then 4, 5, 4, 2, 2, 2, 2, 1, 2, 2, 1, 1); the tree was clean after every one.e2e, whole spec once on the final source:
28 passed (2.5m). Survey script: three runs the same day, the last two with identical tables; 33,834 channels, 2,437 requests, 0 exhausted.Review round 2
Merge-ready, no false refusal on real data; one optional finding fixed without changing behavior: the pair claim key sorts the two contacts, so non-exact
POL A1-A2andPOL A2-A1(opposite polarity, plausibly two real channels) both refuse asduplicate_contact, while exactA1-A2andA2-A1both stay. A refusal is the safe side: two non-exact spellings cannot be told apart from a duplicate, while exact names are unambiguous; no surveyed recording has it. The reason is documented atsettleClaims, and a known-answer test row on real contacts pins both halves (plus an exact pair keeping the pair from a non-exact opposite spelling, and either opposite spelling joining alone). Revert check: the sorted key turned off (c.contacts.joinfor the sorted join) fails that test (1 failure). Gates on the head after round 2: lintChecked 445 files in 244ms. No fixes applied.; typecheckResult (517 files): 0 errors, 0 warnings, 19 hints;bun run test src/lib/ieeg-spatial12 files, 448 passed;bun run testTest Files 189 passed | 3 skipped (192),Tests 5474 passed | 14 skipped (5488); leak check on the two changed files prints nothing. Only a test and a comment changed, so the e2e (28 passed (2.5m)) and the bundle figures above stand.Not run, would check
gh pr checks.MATCH_RULESentry and a test row.Patch notes for other owners
channels.tsvnames (the Zarr index already counts them asunits_report.unmatched_channels). Writing the BIDS channel name into the store's label would remove the need for these rules for those datasets.src/lib/ieeg-spatial/entry (outside this card).Card: IS-J1.