Repository navigation
feat: resolve and join iEEG contacts (IS-C1) - #548
Merged
neuromechanist merged 10 commits intoNov 18, 2026
Merged
Conversation
Deploying nemar-website with
|
| Latest commit: |
7d3a020
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://681fd74f.nemar-website.pages.dev |
| Branch Preview URL: | https://feat-is-c1-contacts.nemar-website.pages.dev |
neuromechanist
merged commit Nov 18, 2026
f320f1f
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.
What changed
Card IS-C1 of the iEEG spatial plan: one pure module that, for an iEEG recording, resolves the dataset's own
_electrodes.tsvand_coordsystem.jsonfiles through the data plane and returns the recording's contacts.src/lib/ieeg-spatial/geometry.tsresolveRecordingGeometry({ datasetId, version, recording, listDir, readText })walks the recording's directory and every ancestor to the dataset root, applies BIDS inheritance perspace(a file applies when every entity exceptspaceequals the recording's; deepest directory wins, then most entities; a tie isambiguous), pairs a coordsystem only with an equalspace(both absent counts as equal), and returns every space, ordered by name, none preferred.template(case-insensitive match to the BIDS appendix table, canonical spelling andcaseNormalized),native(ACPC,ScanRAS),described(Other, description verbatim),pixels, orunknown(with awhy). No description, prefix or partial match promotes a frame.m,cm,mmscale to millimeters;n/a, absent or anything else leaves values as written andunitsDeclared: false. Nothing is inferred from magnitudes.no_electrodes_file,no_coordinates,all_zero,unreadable,no_coordsystem,ambiguous,listing_failed.joinChannels(space, labels): exact name first, thenA-B/A - Bwhen exactly one-split names two contacts (position at the midpoint, markedbipolar); otherwise unlocated with a cause. No case folding, no prefix.dataPlaneSource(id, version)is the productionlistDir(the realfetchDirListing) andreadText.test/fixtures/ieeg-geometry/: 119 real files and directory listings from 19 public datasets plus one pinned BIDS appendix file, byte for byte, 369 KB of content (about 780 KB of disk blocks), withSOURCES.json(dataset, version, path, URL, bytes, SHA-256); the pinned BIDS appendix entry also carries its license note (CC-BY-4.0, source URL and commit).src/lib/ieeg-spatial/geometry.test.ts: 51 tests.Gates (final head, after review round 1)
bun install --frozen-lockfile:Checked 416 installs across 568 packages (no changes).bun run test src/lib/ieeg-spatial:Test Files 2 passed (2),Tests 72 passed (72)(51 here, 21 from IS-M1).bun run test:Test Files 177 passed | 3 skipped (180),Tests 5037 passed | 14 skipped (5051).bun run lint:Checked 423 files in 190ms. No fixes applied.bun run typecheck:Result (490 files): 0 errors, 0 warnings, 19 hints(same hints as the base).geometry.ts,geometry.test.tsandSOURCES.json: nothing printed.geometry.ts, tests rerun, then reverted;git status --porcelainclean afterwards): 25 mutations, none survived, rerun on the merged head. Card tests 1 to 7: space compared with the recording's entities (34 fail),n/aas 0 (5), unit scale dropped (1), case-sensitive template compare (2), prefix accepted (1),Othermapped to a template (4), bipolar joined by the first name only (4),no_electrodes_fileon a failed listing (4). Review round 1: deleting the exact-nameduplicate_contactreturn, the pairduplicate_contactreturn, or theambiguous_pairreturn each fails the new join test (1 each). Also killed: coordsystem paired across spaces, entities ignored, tie broken silently, depth reversed, entity count reversed, root not walked,all_zerodropped, header untrimmed, exact join skipped,no_positiontreated as located, unnamed rows kept, non-200 read returning its body, a changed fixture byte, an unlisted fixture file.366e4d4(IS-M1) is merged into this branch.Not run, would check
gh pr checks.Deviations and findings
on005522recording. Inon005522each subject has one space (MNI152NLin6ASymfor 91 directories,Talairachfor 3), never two in one directory. The per-subject pairing is tested onon005522; the both-spaces case uses real recordings that do have two:nm000485(OtherandTalairach),on004473(ACPCandScanRAS),on004457(spaceless andACPC),on006253(session-levelfsaverageplus a subject-levelspace-mnifile with no coordsystem).mniandMNIas declared labels. Of the 5,845 readable raw-tree coordsystem files in the 164 public iEEG datasets whose manifest could be read, none declares aniEEGCoordinateSystemofmni,MNIorMNI152; those occur only asspaceentities (nm000405,on003374,on006253) and the files declareOtheror no coordsystem. Sonm000405isunknownthrough the entity mismatch rule, and the prefix mutation is proven on a known-answer label table (mni,MNI,MNI152,MNI152NLin6, ...).ambiguousbranch and the depth and entity-count precedence rules, and contact rows built from real on005522 contacts for theduplicate_contactandambiguous_pairjoins. No public data reaches any of these.no_coordsystemnever withholds contacts. The plan counts the 8 datasets with an electrodes file and no coordsystem among the 97 with usable coordinates, so such a space is shown in its own frame with undeclared units and carries the word asframe.why.feat/is-c1-contactsas the manager gave it (the card saysfeature/is-c1-ieeg-geometry).Patch notes for other owners
For IS-V1 (the panel):
0 0 0inside a file that also has real rows is returned at the origin, as written. Only a file whose every located row is at the origin isall_zero(the card's rule; documented in the module header). Real files do this (on005670,on006890); the panel may treat origin placements as suspect.unreadablecovers a transient read failure (HTTP 500, network error, abort) and a malformed file alike;listing_failedmay be transient too. There is no retry and no size cap on reads. Do not cache either as permanent; offer a retry. The data plane has answered 500 intermittently to sidecar reads.units.unit === "mm". Unitnull(58 datasets) is labeled "as written", with no scale claim.Pixelsframes carry unit"pixels".spacevalue, not a recommendation.describedframe carries its description verbatim. Anunknownframe throughspace_mismatchloses the native label, so show bothdeclaredandspaceEntity.signal.abortedbefore rendering a result.causeandcontacts; never re-implement joins.on004100declaresfsaveragein meters but its values are millimeter-sized (17.7791 for one contact); the declared unit decides, so those contacts land 1000 times too far out. A "far outside a head" warning belongs in the panel; this module does not infer.on005522writes-999insize; it is returned assize: null(an area cannot be negative).Other:
fsaverage3tofsaverage6,UNCInfant0V21and kin) areunknown.src/lib/ieeg-spatial/entry; that edit is outside this card's scope.Card: IS-C1.
Part of #537