Repository navigation
IS-V3: 2D three-view fallback and figure exports with the credit - #555
Merged
neuromechanist merged 8 commits intoNov 18, 2026
Merged
Conversation
Deploying nemar-website with
|
| Latest commit: |
d890bfc
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://4aed6952.nemar-website.pages.dev |
| Branch Preview URL: | https://feat-is-v3-exports.nemar-website.pages.dev |
neuromechanist
merged commit Nov 18, 2026
d162257
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-V3 of the iEEG spatial view plan (the intracranial track of epic #537, ADR 0033). Part of #537.
What changed
Without WebGL2, or when the reader asks, the panel draws the contacts in three orthographic views (left, top, front) as accessible SVG; "Save PNG" and "Save SVG" produce figure files that carry the credit inside them.
src/lib/ieeg-spatial/views2d.ts(new, pure):layoutViews(one scale for all three views, orientation pinned tocamera.ts's presets by a test, far-to-near drawing order, selected contact last, radius by the 3D view's rule only when units are millimeters),viewsMarkup(a<g>per view, one<circle>with a<title>per located contact),parseViewOutlines(reads the vendoredviews.json, refuses anything else). A contact without a finite position is never drawn.src/lib/ieeg-spatial/export.ts(new):exportSvgandexportPng, the only entry points. OneFigure(title, 3D frame or the three views, colorbar, labels wrapped to lines, a reserved footer) is read by two serializers:buildDrawList(the raster operations, the last one is always the credit, run byrasterizewith the export canvas's own ratio, 2 canvas pixels per figure pixel) andbuildSvg(views, labels, colorbar, a<metadata>block with dataset id, version, recording path, frame, every label, the credit and its address and the paper DOI, and last the credit's<a href>around its<text>fromcreditSvg). File names are<recording stem>_contacts_<frame>.png|svg, from the path and a closed vocabulary.src/lib/ieeg-spatial/panel.ts:PanelState.view2d, eventview_changed, stage kindviews2d,PanelModel.view; the DOM half adds the "2D views" switch (disabled and pressed without WebGL2, with that sentence as its title), the two save buttons, the inline SVG views (click a dot to select; the contact list stays the keyboard path), and a download helper that says in words when the browser refuses.templatePlacementFor(state)is the named seam for IS-V2.src/styles/eeg-viewer.css: the 2D stage, the actions row, and.eegv__spatial-inner > * { flex-shrink: 0 }(with the extra row the panel's content can exceed the scope's height, and a shrinking flex child squashed the contact list to nothing; the panel scrolls instead).e2e/ieeg-spatial-panel.spec.ts: 4 more tests (below).The files say what the screen says: every label is read from the panel's own
PanelModel(status line, frame choice, template sentences, notes, activity message, summary and no-data line, colorbar ends, the selection), in the same words. The SVG is always the three views; the PNG is the live 3D frame (BrainRenderer.snapshot(), no API change was needed) when the view is 3D, and the three views otherwise.Seam for IS-V2 (documented in
export.tsandpanel.ts)templatePlacementFor(state): TemplatePlacement | nullinpanel.tsreturns null for every state today, so no outline is drawn and no template sentence is said. IS-V2 replaces its body.TemplatePlacement(inexport.ts) carriesoutlines(fromviews.json, viaparseViewOutlines), optionalpositions(one per placed contact, in the template's millimeters after IS-V2's transform; absent means as declared) andlabels(the template and "approximate" sentences). The 2D views and both exports read this and nothing else. No transform and no mesh loading is implemented here. Live 3D template sentences are IS-V2's to paint from the same value.Deviations and interpretation
exportPng(state)takes anExportInput(state, itsviewModel, thecontactColors, the theme tokens, the seam value, the frame name) plus the optional 3D frame, so the pure builders need no import ofpanel.tsvalues (no import cycle).<title>.role="group"so each circle's<title>stays reachable.http://www.w3.org/2000/svg,http://purl.org/dc/elements/1.1/) and addresses built fromRAVE_CREDIT; nothing else.Gates (round 1 head 03ba9aa, epic tip 221321e, nothing newer to merge)
bun install --frozen-lockfile:Checked 416 installs across 568 packages (no changes)bun run typecheck:Result (509 files): 0 errors, 0 warnings, 19 hints(the base's 19 hints)bun run lint:Checked 439 files in 201ms. No fixes applied.bun run test src/lib/ieeg-spatial/export.test.ts src/lib/ieeg-spatial/views2d.test.ts:Test Files 2 passed (2),Tests 55 passed (55)bun run test:Test Files 186 passed | 3 skipped (189),Tests 5318 passed | 14 skipped (5332)PUBLIC_DATA_BASE_URL=https://data.nemar.org bun run test:e2e e2e/ieeg-spatial-panel.spec.ts(headless, dev server):14 passed (1.4m)bunx astro buildandgzip -9c <chunk> | wc -c. Base (epic tip): panel chunk 58,830 raw, 21,645 gzipped; viewer chunk 166,137 raw, 58,277 gzipped. Now: panel chunk 76,690 raw, 28,362 gzipped (+6,717 gzipped); viewer chunk 166,137 raw, 58,279 gzipped (+2, a hash). The panel chunk is under the plan's 30 KB panel budget; IS-V2's addition to the same chunk is not counted here. The threegenerate:*Open Graph steps ofbun run buildwere skipped (they render cards from the live catalog and touch no chunk).export.ts,views2d.ts, both tests, the e2e spec and the stylesheet: see deviation 5.Real-browser evidence (headless Chromium, on005522)
sub-R1001P_ses-0_task-YC1_acq-bipolar_ieeg_contacts_mni152nlin6asym.png, 1920x880, signaturePNG; decoded in the page, the bottom-right 440x60 region holds 173 distinct colors and 1,518 dark pixels, the bottom-left region of the same size holds 1 color and 0 dark pixels (the plain background), so the difference is the credit.DOMParser(image/svg+xml), no parser error; threeg[data-view](left, top, front); 264 circles for 88 contacts, each with a non-empty<title>; the last child of the root isg.eegv-credit, whose<a href>is the addresscredit.tsdeclares around the sentence it declares; the metadata holds the dataset id, the status line, the address and the DOI.Mutation checks
Each test below fails under the one-line mutation named, reverted afterwards (
git status --porcelainclean after each run).creditSvg(2 fail).templateargument is notundefined, so a null one is read (20 fail, including the native and described frame tests).camera.ts); top draw order reversed; wrapped lines losing their trailing space; credit painted at ratio 1; a frame label built from free text; notes, the selection line, the colorbar ends or the WebGL sentence dropped from the files;¬ escaped in a title; the selected circle not larger;view_changedignored; the switch enabled without WebGL2; the 3D frame enlarged past its size; the recording dropped from the metadata; the seam's positions ignored; the value dropped from a title (21 mutations, 21 caught).Expected: > 8, Received: 1); skip the SVG credit (Expected: "eegv-credit", Received: null).Not run, would check
gh pr checks.panel.ts: the second PR to merge takes the base in; this branch'spanel.tsadditions are theview2dstate and event, theviews2dstage kind,PanelModel.view,templatePlacementFor, and the DOM half's views and actions.Card IS-V3.
Review round 1 (head 03ba9aa)
Fixed: I1 the activity measure and band ("Band power, relative (dB): High gamma, 70 to 150 Hz", from the selectors' own words, one
measureSentence) are in the model, the live 2D notes, the SVG, the PNG draw list and the 3D PNG; I2escapeXmlstrips XML-forbidden control characters (unit test, a full-figure test with U+0001 and U+000B in a contact name, and an e2e that parses the markup with the browser's XML parser); S1 chose to correct the comment and the test name: the 3D frame is capped at its pixel count in figure pixels and is drawn at exactly 2x (smoothed); S2 orientation letters on every view (R/L and A/P and S/I from the view definitions, a test pins them to the 3D camera's projection; in live view, SVG and PNG); S4downloadFiletakes ascheduleseam and tests use the real URL registry (resolveObjectURL) to prove the revoke, also when the click throws; S5doiUrl()exported fromcredit.ts, used bycreditSvgandexport.ts(a scan test keepsdoi.orgout ofexport.ts).S3: the "Selected:" line is a deliberate addition to the exports (not in the live status): it restates the selected contacts with the same sentence as their circle titles.
Owner addition (transparency): every circle title, the "Selected:" line and each contact-list row now say the contact name as recorded first, the channel(s) beside it in parentheses, and where the dataset recorded it:
LAF2 (channels LAF1-LAF2, LAF2-LAF3); recorded (-48.8321, 53.1194, 1.08525940626615) mm, frame: MNI152NLin6ASym; 1.50 µV². One function,contactTitle(withrecordedLocationandtemplateLocation), builds it for all of them, so the wording is declared once. The recorded line is numerically equal to the file's value to 15 significant digits, not the file's own characters: trailing zeros and exponent notation are normalized, because IS-C1's parser keeps numbers, not text. In the file's own unit the number prints as parsed; for a converted unit (a file in meters) IS-C1's millimeters are divided back and read to 15 significant digits, so the line says meters as the file did (the committed fixtures reproduce character for character). Carrying the raw coordinate strings through IS-C1's parser, so the line is verbatim, is assigned to the next card, IS-J1.TemplatePlacementgainedapproximate: boolean; a template position is added astemplate (x, y, z) mm, approximateonly when the seam supplies one, and says "approximate" only when the seam says so. A native frame has only the recorded line.Round 1 gates (head 03ba9aa):
bun run typecheckResult (509 files): 0 errors, 0 warnings, 19 hints;bun run lintChecked 439 files in 283ms. No fixes applied.;bun run test src/lib/ieeg-spatialTest Files 9 passed (9),Tests 308 passed (308);bun run testTest Files 186 passed | 3 skipped (189),Tests 5334 passed | 14 skipped (5348); e2e15 passed (1.1m). Chunks: panel 78,547 raw, 29,021 gzipped (base 21,645, +7,376); viewer 166,137 raw, 58,277 gzipped (same as base). Revert checks (each fails its named tests, then reverted, tree clean): drop the recorded line from the title (6 fail), round the recorded position (4), band left out of the measure (2), control characters not stripped (2), front letters not swapped (3), download address never revoked (2), DOI address built inexport.ts(1), letters left out of the PNG draw list (1), template line drops "approximate" (2), list rows lose the recorded line (5), title drops the channel (6), measure label left out of the files (2).S6 (wiring IS-V2's seam) is pending until V2 has merged;
templatePlacementForstill returns null.Round 2: IS-V2 merged in, template seam wired (head 61c3df6)
The epic tip (IS-V2, bbe44a8) is merged into the branch (merge, no rebase). Conflicts in
panel.ts,eeg-viewer.css(one copy of the shared.eegv__spatial-inner > *rule, V2's comment kept) and the e2e spec resolved keeping both sides' behavior. One existing assertion changed: without WebGL2 the template box now reports the outlines' loading state (the 2D views wait onviews.json, never on the mesh);panel.test.tssays so and still pins that the surface is never asked for. V2's e2e mesh watcher now counts only the two.mesh.binfiles (the outlines file is watched apart).templatePlacementFor(state, outlines)now returns, for a frame with a registry row (V2'stemplateRuleOf) and outlines in hand: the outlines parsed fromviews.json(parseViewOutlines), the positions through V2'splaceOnTemplate,approximatefrom the rule, the labelstemplateLabel(rule)andtemplateNotice()(the notice's words are the live box's:TEMPLATE_NOTICE_PREFIX,TEMPLATE_REFERENCE.text,TEMPLATE_LICENSE_TEXT, withTEMPLATE_REFERENCE.hrefandTEMPLATE_LICENSE_HREFin the SVG's metadata). Native, described, pending, unsupported-units frames, and outlines still loading or failed, give null: no outline, no template line, no label (the "No template placement ..." note still comes from the panel's own notes).PanelState.outlines(idle, loading, ready, failed) with eventsoutlines_loaded/outlines_failedand effectload_outlines, mirroring V2'stemplate: the fetch is wanted only with the panel open on a registered frame and contacts drawn (3D, 2D or without WebGL2, because the SVG is always the 2D views); never for EEG, ACPC or a closed panel; a module-level promise caches it, so a reopen does not refetch; a failure is retried on a reopen, frame or recording change.templateModelcovers the 2D stages from the outlines' status, so the live box shows the same label, notice and two links in 3D and 2D. The 3D PNG says what the model said (loading, failed or ready, in V2's words); the SVG and 2D PNG say what the seam says.template (x, y, z) mm, approximateline once a template is drawn (ContactRow.template,placedRule), by the sametemplateLocation.Gates (head 61c3df6): typecheck
Result (512 files): 0 errors, 0 warnings, 19 hints; lintChecked 442 files in 183ms. No fixes applied.;bun run test src/lib/ieeg-spatialTest Files 10 passed (10),Tests 364 passed (364);bun run testTest Files 187 passed | 3 skipped (190),Tests 5390 passed | 14 skipped (5404); e2e26 passed (1.9m)(the run before a format-only change). Chunks: panel 89,506 raw, 32,877 gzipped (the owner's budget is 64 KB); viewer 166,137 raw, 58,278 gzipped.Real fixtures: nm000454 (own frame, not approximate), nm000376 (IXI549Space), on005522 monopolar (Talairach, positions checked against
applyAffine(TALAIRACH_TO_MNI, ...)), nm000485 and nm000355 in e2e; ACPC (on004473), Other (nm000485), a pending identifier (a real state with its frame replaced by NIHPD) and an undeclared-units frame (nm000373) for the negative cases. e2e: nm000485 downloads the SVG (three outlines, both sentences equal to the live box's, the title of every circle with both lines, the credit last) and a PNG whose corner holds the credit, and counts oneviews.jsonrequest across a close and reopen; nm000376 does it from the 3D view; nm000355 has no outline, template line, label or request; an EEG dataset never asks.Revert checks (each fails its named tests, reverted, tree clean): outlines without a registered rule (5), template line for a frame with no template (10), template sentences left out of the files (6), recorded line left out (10), list rows without the template line (4), outlines wanted for every frame (1), outlines refetched on every reopen (1), notice left out of the seam (3), addresses left out of the metadata (3), contacts not moved by the transform (1), approximate never said (3), 2D stage ignoring the outlines status (4), 3D frame labels taken from the seam (1).
Round 3 (head d890bfc)
data-view-frame) and PNG (aframedraw operation). A geometric test on the layout (row and 2x2 grid) asserts every letter lies inside its own frame and keeps at least 8 px from every letter of every other view (the glyph footprint is 0.6 em by 1 em); the drawing area's padding grew to 18 px so letters stay clear of dots.templateOutlines(read),forgetTemplateOutlines()for tests): two panels opened in sequence share one read, a failed read is not kept, a wrong format is refused and not kept. The reader is given the real committedviews.json.recordedLocation, test comments, and above).Gates (head d890bfc): typecheck
Result (512 files): 0 errors, 0 warnings, 19 hints; lintChecked 442 files in 182ms. No fixes applied.; ieeg-spatialTests 368 passed (368); fullTest Files 187 passed | 3 skipped (190),Tests 5394 passed | 14 skipped (5408); e2e26 passed (2.0m); panel chunk 90,024 raw, 33,013 gzipped; viewer 166,137 raw, 58,277 gzipped. Leak check: only the two XML namespace identifiers. Revert checks (each fails its named test, reverted): left letters back at the cell edge (1), right letters back at the cell edge (1), frames not written in the markup (1), frames missing from the draw list (1), cache??=changed to=(1), a failed read kept in the cache (2).