Repository navigation
IS-V2: template anatomy for template frames - #556
Merged
neuromechanist merged 13 commits intoNov 18, 2026
Merged
Conversation
Deploying nemar-website with
|
| Latest commit: |
fc30ca5
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://6d6f1608.nemar-website.pages.dev |
| Branch Preview URL: | https://feat-is-v2-anatomy.nemar-website.pages.dev |
neuromechanist
merged commit Nov 18, 2026
bbe44a8
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-V2 of the iEEG spatial view plan (the intracranial track of epic #537, ADR 0033). Part of #537.
What changed
When the shown frame is a standard template identifier with a cited row, the Brain panel draws the vendored MNI152NLin2009cAsym surface (IS-T1) behind the contacts, after a cited affine where the frame is not the surface's own, and always shows the words "Template brain (MNI152NLin2009cAsym), not this subject's anatomy", plus "approximate: ..." whenever a transform or another MNI variant is involved. Every other frame keeps the contacts-only view and says
No template placement for FRAME: positions are shown in the dataset's own frame.src/lib/ieeg-spatial/transforms.ts(new): the registry, the two cited affines, the label and sentence words, the surface's file names,mergeMeshes(the two hemispheres as one mesh forsetMesh, 16-bit indices) andloadTemplateSurface.MNI152NLin2009cAsym: the surface's own frame, no transform, no "approximate".MNI152*identifier andIXI549Space: identity, "approximate: MNI template variants differ by a few millimeters".MNI305,fsaverageandfsaverageSym: FreeSurfer's published MNI305 to MNI152 affine, "approximate: MNI305 to MNI152 affine".fsaverageSymrests on the BIDS appendix sentence it shares word for word withfsaverage("the volumetric template corresponds to a FreeSurfer variant of MNI305 space"); the surface is a symmetric variant of fsaverage, so the relation is approximate (driver ruling, round 2).Talairach: the inverse of Lancaster et al.'s Eq. (3), "approximate: Talairach to MNI affine".MNIColin27,ICBM452AirSpace,ICBM452Warp5Space,fsLR,NIHPD,OASIS30AntsOASISAnts,OASIS30AtroposandUNCInfant. Each has an entry insrc/lib/ieeg-spatial/pending-templates.tswith the reason it has no row and the exact evidence that would place it (source, relation, worked example); the panel readsNo template placement yet for X: positions are shown in the dataset's own framefor them, distinct fromNo template placement for X: ...(ACPC, ScanRAS, Other, Pixels, non-standard labels, and a placed identifier whose units are not millimeters). None of the eight appears in the census.fsLRstays pending by ruling: an fsLR-labeled position may be a surface vertex coordinate, which no source covers, even though BIDS names MNI152NLin6Asym as its volumetric template. See "Findings per family".IXI549Spacekeeps its identity row as the one documented exception to the policy that a placed row needs a stated relation to the MNI152 frame: BIDS says it is "linearly transformed to ICBM MNI 452", a relation to ICBM452 (itself pending), not to an MNI152 template. The row's comment and source say so, a test pins it, and a source stating its relation to an MNI152 template with a worked pair would settle it (or the row moves to pending).talairach.xfm. The excerpt fixture now carries Table V's values, and a test pins the range to them.src/lib/ieeg-spatial/pending-templates.ts(new): the pending table. Only tests import it (a test pins that no runtime module does), so none of its text ships in the panel's chunk; the panel derives "pending" from the registry (isPendingTemplate: a template frame the registry has no row for), andtransforms.test.tsfails unless every such identifier has an entry.src/lib/ieeg-spatial/panel.ts: atemplatestatus in the state machine (idle,loading,ready,failed) and aload_templateeffect, emitted only while the panel is open on a registered frame with a canvas to draw on (never for any other frame, never without WebGL2); the template model with the label, the Fonov et al. reference link (doi) and the link to the MNI notice (LICENSE.txt); the no-placement line inframeNotes;drawnPositions(the contacts through the row's affine only while the surface is drawn, index for index withPlacement.contacts); the DOM half fetches the two files once per page, sets the mesh, and re-sets the contacts. A failed fetch leaves the contacts as declared with a sentence and no label; reopening the panel, a frame change or a recording change tries again.src/styles/eeg-viewer.css(one rule, see Deviations): the panel's items no longer shrink.e2e/ieeg-spatial-panel.spec.ts: 7 new tests, see Gates.test/fixtures/ieeg-transforms/: excerpts of the two sources (FreeSurfer's item 8 and 8b, the matrix rows of Lancaster's Eq. 3), with their sources and SHA-256 inSOURCES.json.Gates (head fc30ca5, round 2 delta review fixes; the epic tip 221321e is in the branch)
bun install --frozen-lockfile:Checked 416 installs across 568 packages (no changes)bun run typecheck:Result (507 files): 0 errors, 0 warnings, 19 hints(the base's 19)bun run lint:Checked 438 files in 198ms. No fixes applied.bun run test src/lib/ieeg-spatial/transforms.test.ts src/lib/ieeg-spatial/panel.test.ts:Test Files 2 passed (2),Tests 114 passed (114)(32 and 82)bun run test src/lib/ieeg-spatial:Test Files 8 passed (8),Tests 282 passed (282)bun run test:Test Files 185 passed | 3 skipped (188),Tests 5308 passed | 14 skipped (5322)bun run test:e2e e2e/ieeg-spatial-panel.spec.tsagainstbun run dev,PUBLIC_DATA_BASE_URL=https://data.nemar.org, headless:17 passed (1.3m)on this head (10 existing, 7 new). New: on005522 draws the surface with the label and "approximate: MNI template variants differ by a few millimeters", links the notice and the reference, requests nothing before the panel opens and exactlylh.mesh.binandrh.mesh.binafter, and does not refetch when the panel is closed and reopened; nm000355 (ACPC) draws no surface, requests no mesh and saysNo template placement for ACPC: positions are shown in the dataset's own frame; nm000454 (own frame), nm000485 (Talairach), nm000376 (IXI549Space) and on004100 (fsaverage) carry the label each row owes them; a failed mesh fetch leaves the contacts, says so without a label, and a reopened panel recovers; the EEG case requests no mesh. A run on the previous head had one transient failure of an unrelated embed load (on004100 never showed its viewer within 90 s; no panel code was involved); the run on this head passed 17 of 17, as did the one before it. Measured ink share of the panel canvas (the e2e's own evidence that a brain is drawn): 0.166 to 0.170 with the surface on four datasets, 0.045 for 152 contacts alone (nm000355); the bounds are 0.12 and 0.09.bunx astro buildandgzip -9c <chunk> | wc -c. Panel chunk: 58,830 raw and 21,645 gzipped at the epic tip; 66,990 raw and 24,736 gzipped on this head (+8,160 raw, +3,091 gzipped; the previous push measured 66,433 and 24,497, so this round added +557 raw and +239 gzipped: two longer row sources and thefsaverageSymrow). A first version with the pending text insidetransforms.tsmeasured 69,812 raw and 25,763 gzipped; moving the table to a module only tests import saved 1,266 gzipped bytes, and a grep of the build finds none of its text in any chunk. Viewer chunk: 166,137 raw and 58,277 gzipped at the epic tip, 166,137 and 58,278 now (the panel import's file name only). The two hemisphere files (266,170 and 266,092 bytes; 214,437 and 215,120 gzipped) are in no chunk and are fetched only on a placed frame.pending-templates.tsincluded, and on this body: all three commands print nothing (the four source sites whose hosts are not on the check's list are named in words below, not linked).Revert checks
Round 2 (this push), each a one-line mutation that fails the named test, reverted, tree clean after each: the Talairach wording back to claiming disparities "left" after Eq. 3, the range changed to 0.5 to 3.1 mm, the "per-package fits; pooled Eq. 3 not tabulated" words dropped, and a Table V value in the fixture changed (each fails the Talairach wording test, which reads Table V's values from the excerpt); the
fsaverageSymrow with the identity (3 failing, the worked example through the registry and the panel test), removed (7 failing), with its "so approximate" words dropped, with the Talairach label, or as a variant row (4 failing); thefsaverageSymentry put back in the pending table (the exhaustiveness test fails: both);IXI549Spacegiven the plain variant source, or its "documented exception" or "not to an MNI152 template" words dropped, or the word "exception" added to another row's source (each fails the IXI549Space test).Round 1 of the registry request (earlier push): this round's new tests (registry exhaustiveness, pending entries, the pending sentence, the import guard, the panel test), each failing under a one-line mutation and reverted, tree clean after each: a pending entry deleted (the appendix test fails: neither placed nor pending), a placed row deleted (the same test and the example tests), a family put in both tables, a pending entry with an empty
needed, with aneededlacking the worked example, with a one-wordreason,noPlacementSentencewithout theyet(the transforms test and the panel test),isPendingTemplatealways false (4 failing), a pending family given a placing fallback inplacementRuleFor(3 failing), andpanel.tsimporting the pending table (the import guard fails).Earlier rounds:
Each test was shown to fail under a one-line mutation, then reverted (
git status --porcelainclean after each). Unit: a transposedMNI305_TO_MNI152(8 failing), a transposedMNI_TO_TALAIRACH(4),TALAIRACH_TO_MNIset to the forward matrix (6), thefsaverageandTalairachrows with the wrong matrix (4, 6),units.unitignored (2), the variants list shortened (6), a variant row with a real transform (killed); load for every frame (templateRuleOfdropped fromwantsTemplate: 3 failing), open not required (4), canvas not required (1),drawnTemplatewithoutready(2), contacts not transformed (2), failed retry removed (2), WebGL2 withdrawal removed (2), the no-placement line removed (6), a report accepted when not loading (2), the label dropped for identity rows (4 intemplateLabel, 4 for the approximate-only variant, 2 in the model), the loading state claiming a drawing (2). The redundantkindbranch inplaceOnTemplatesurvived as an equivalent mutant and was removed. e2e: load for every frame (nm000355 fails), label dropped (on005522 fails), mesh never set (on005522 fails), the CSS rule removed (the toggle test fails, as it did before the rule existed).Findings per family (researched 2026-11-18, GET only, primary sources)
Every identifier of the pinned appendix table is accounted for: 14 placed (the surface's own frame, nine variants including
IXI549Space,MNI305,fsaverage,fsaverageSym,Talairach) and eight pending. A row is placed only where a primary source states the relation and a worked example (or an identity relation) can be tested; every other family stays pending, with what would settle it inpending-templates.ts. Four source sites (the LONI atlas page, the NITRC atlas page, the figshare record and the Mindboggle page) have hosts that the repository leak check does not list, so they are named here and not linked: each is the URL the BIDS appendix table lists for its family.MNI152NLin2009cAsympublic/vendor/brain-templatesprovenanceMNI152*IXI549SpaceMNI305,fsaveragefsaverageSymfsaveragerow rests on; FreeSurfer's Xhemi page adds nothing on fsaverage_sym coordinates; the surface is a symmetric variant of fsaverageTalairachICBM452AirSpaceICBM452Warp5SpaceMNIColin27NIHPDOASIS30AntsOASISAnts,OASIS30Atropostpl-OASIS30ANTs: its own grid, no space statement; the figshare record and the Mindboggle page describe the ANTs and Atropos templates with none eitherUNCInfanttpl-UNCInfant: three age cohorts (neonate, 1 year, 2 years) on their own grids; the NITRC page relates none to adult MNI spacefsLRMNI152NLin6Asym; TemplateFlowtpl-fsLRholds surfaces only and cites Van Essen et al. 2012variantrow once a source prints how vertex and volume coordinates relate, with a worked pairRulings (driver, after the delta review):
fsaverageSymis placed because its BIDS clause is the onefsaveragealready rests on, together with FreeSurfer's MNI305 to MNI152 worked example;fsLRstays pending for the reason in its row. The owner may veto either; placing or unplacing a family is a one-line change in the registry and its pending entry.Stop condition reached, for the lead (Talairach)
The card's first stop condition: a cited source gives no worked example to test against. FreeSurfer's page does (MNI305, both directions, pinned to 0.01 mm, and read from the committed excerpt). Lancaster et al. 2007, BrainMap's m-files and NiMARE give no worked point pair for Talairach to MNI: the paper prints the matrix (Eq. 3) only, the m-files carry code only, and NiMARE's test says its own "true" values are a TODO ("Get converted coords from official site"). The run could not ask, so this PR carries the Talairach row with the strongest evidence available and marks the acceptance open:
row("Talairach", ...)line inTEMPLATE_PLACEMENTSto delete, and the panel then showsNo template placement for Talairach.icbm_other2tal.mandtal2icbm_other.m, and NiMARE'stal2mniandmni2tal(so the 0.5 mm stop condition did not trigger).fractions, Gauss-Jordan on the four-decimal entries) is the known answer for five points to 1e-6 mm; (-44, 31, 27) agrees with NiMARE's test row to its eight decimals.Deviations from the card
LTP1-20000where the BIDS files sayLTP1; the panel joins by exact name only (IS-C1), so every on005415 recording has a disabled toggle ("None of this recording's channels match a contact") and no panel to open. nm000355 is a native-frame dataset (ACPC) whose labels join (152 of 152 located).src/styles/eeg-viewer.css(outside the card's Scope):.eegv__spatial-inner > * { flex-shrink: 0 }. The two lines the template adds under the canvas pushed the panel past the scope's height beside the scope; the contact list, a scroll container and so the one flex item allowed to shrink below its content, collapsed and its rows were drawn over the activity block, which failed the existing Escape test (clickintercepted). With the rule the panel scrolls inside itself, as its own comment says it should.test/fixtures/ieeg-transforms/, because the worker preamble wants the numbers a test compares against to come from a committed, sourced file. The m-files and the paper are not redistributed; only the matrix rows and two quoted sentences.fsaverage3tofsaverage6,UNCInfant0V21and kin) stay unknown frames ingeometry.ts(IS-C1's rule) and never reach the registry: they readNo template placement for X. The pending sentence has no trailing period, matching the sentence it is paired with. Rulings after the delta review:fsaverageSymis placed,fsLRstays pending,IXI549Spacestays placed as a documented exception; the owner may veto any of the three (placing or unplacing a family is a one-line change in the registry and its pending entry).MNI152NLin6Asym, units n/a, 30 recordings): it gets the no-placement sentence and the existing "units not declared" note, as plan 6.2 says forn/a.src/lib/ieeg-spatial/pending-templates.ts(the owner asked for the work insidetransforms.ts): kept apart so its text does not ship; its entries are reached only through tests.Not run, would check
gh pr checks.Card: IS-V2. Part of #537