Repository navigation
IS-V1: iEEG Brain panel in the signal viewer - #552
Merged
neuromechanist merged 11 commits intoNov 18, 2026
Merged
Conversation
Deploying nemar-website with
|
| Latest commit: |
55a1ef8
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://50ecc10c.nemar-website.pages.dev |
| Branch Preview URL: | https://feat-is-v1-panel.nemar-website.pages.dev |
neuromechanist
merged commit Nov 18, 2026
6419138
into
feature/issue-537-epic-spatial
5 checks passed
This was referenced Nov 18, 2026
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-V1 of the iEEG spatial view plan (the intracranial track of epic #537, ADR 0033).
What changed
On an intracranial EEG (iEEG) recording the signal viewer shows a "Brain" toggle. It opens a side panel that draws the recording's contacts in the frame the dataset declares (no anatomy yet: the template surface is IS-V2), colors them by the window's activity only while an "Activity" switch is on, links contacts and traces both ways, says plainly what it cannot show and why, and always carries the credit link.
src/lib/ieeg-spatial/panel.ts(new): a pure state machine (reduce,viewModel) that makes every decision, andcreateSpatialPanel, the DOM half that runs its effects (resolve the dataset's sidecars withgeometry.ts, read level-0 samples in slices of 16 channels and compute them withactivity.ts, drivebrain-gl.ts) and paints its model. The credit is a field of the model in every state, so no state can leave it out; the DOM half mountscreditLinkon every mount and no option omits it.src/lib/ieeg-spatial/panel.test.ts(new): 69 tests, no DOM and no mocks. Geometry comes from the real files committed for IS-C1 and is read by the module's ownresolveRecordingGeometry.src/lib/eeg-viewer/viewer.ts: one optionalViewerOptions.spatial(dataset id, version, recording path); the Brain toggle (built only when the caller names the recording and some group is iEEG, shown only for an iEEG group); the panel's box in the plot row; a highlight band over the selected trace; clicks on a trace or its label select the channel's contact(s) while the panel is open; the panel is disposed with the viewer.src/lib/eeg-viewer/viewer-session.ts: passesspatialfor both mounts, so the dialog and the embed route get the panel. It is a view, not an action, and its credit is a plain link (ADR 0023).src/styles/eeg-viewer.css: panel styles, all design tokens.src/lib/ieeg-spatial/layout.ts(new, small): the rules the viewer needs before the panel's code loads (iEEG modality, beside or below, the scope floor).e2e/ieeg-spatial-panel.spec.ts(new): the headless check, 10 tests.Behavior the card fixes, as built:
no_coordinatessentence).N of M channels located; frame: IDENTIFIER; positions as declared by the dataset, the Activity switch (off by default) with measure and band selectors and the colorbar, the contact list (a listbox: arrows, Home, End, Enter), and the credit link in the canvas corner.Deviations from the card
resolveWithRetries, tested). Refusals that are properties of the data are never retried.unreadableandlisting_failed(IS-C1: possibly transient) the toggle stays enabled, titled "open to retry", so the panel can show the refusal, the credit and Retry. Every permanent reason is disabled with its sentence.spatialLayout,.eegv__plot--stack); the e2e measures it at 360 px (scope and panel both span the viewer, no sideways scroll). In the embed, whose scope fits the host, the panel counts as chrome there and the document may scroll. This is the part to confirm.N of M channels locatedcounts channels.paintCredit" has no call site to check yet. A test scanssrcand fails anypaintCreditcall with fewer than five arguments (proved with a four-argument probe file).data-spatial-*,data-stage,data-activity-state,data-activity-reads).Gates (head 55a1ef8)
bun install --frozen-lockfile:Checked 416 installs across 568 packages (no changes)bun run typecheck:Result (503 files): 0 errors, 0 warnings, 19 hints(the base's 19 hints)bun run lint:Checked 435 files in 190ms. No fixes applied.bun run test src/lib/ieeg-spatial src/lib/eeg-viewer:Test Files 23 passed (23),Tests 772 passed (772)bun run test:Test Files 183 passed | 3 skipped (186),Tests 5228 passed | 14 skipped (5242)(8.6 s)bun run test:e2e e2e/ieeg-spatial-panel.spec.tsagainstbun run dev,PUBLIC_DATA_BASE_URL=https://data.nemar.org, headless:10 passed (1.0m), twice in a row. It covers on005522 (toggle, contacts drawn, switch off by default with zero reads, switch on colors them, window moves re-read only while on, credit link href,target=_blank,relwithnoopener,aria-label, Tab focus,aria-controls, Escape closing the panel and returning focus, selection both ways with a bipolar channel marking two contacts, recording change leaves nothing behind), that an EEG dataset (on009081) never requests the panel's code or an electrodes file, the no-WebGL2 state, a failed electrodes read (refusal, credit, Retry recovers), nm000537 (disabled,no_coordinatessentence) and 360 px (panel below, scope at least 280 px and drawn at its own height, stable, nothing scrolls sideways, closed panel changes nothing).bunx astro buildandgzip -9c <chunk> | wc -c. Base: viewer chunk 161,956 raw, 56,848 gzipped. Now the panel is its own chunk, fetched only for an iEEG recording: viewer chunk 166,137 raw, 58,277 gzipped (+1,429, the toggle, highlight band and loader); panel chunk 58,830 raw, 21,645 gzipped (renderer, activity, geometry, credit, panel). An EEG or MEG viewer pays the +1,429 only. Before this round, with the panel inside the viewer chunk, the viewer chunk was 222,880 raw and 78,070 gzipped for everyone. Withbrain-glstubbed out the renderer measured +6,460 gzipped against its 14 KB budget (14,336), and the rest of the panel code +14,762 against the 30 KB budget (30,720); the split adds about 1.8 KB for the second chunk. The threegenerate:*Open Graph steps ofbun run buildwere skipped (they render cards from the live catalog and touch no chunk), as in IS-R1.panel.ts,layout.ts,panel.test.ts, the e2e spec, the stylesheet and the added lines of the viewer files: all three commands print nothing.Review round 1
The independent review found no critical issue and accepted the deviations; the driver accepted the stacked narrow layout with a floor. Fixed in this push (head 55a1ef8; the epic tip 4392b32 was already in the branch):
.eegv__plot--stack .eegv__scopeandstackedScopeHeightin the embed's fit, so the canvas is drawn at that height and the fit does not loop); the stack class is set only while the panel is open, so a closed panel changes nothing. The embed's document scrolls instead.paintCreditscan counts arguments without a trailing comma, and a test feeds it synthetic calls of 4 and 5 arguments with and without one.aria-controlsnames the panel box; Escape inside the panel closes it and returns focus to the toggle (e2e).resolveWithRetriesraces its pause against the abort signal (abortableSleep), so an abort cancels the timer; tested with a 60 s pause that ends within 2 s.computeActivityPlan(the slicing loop, now exported) refuses withmixed_unitswhen a later slice's unit differs from the first slice's (voltage in one, field in another); tested on the real on006136 window, together with slicing not changing the values,not_level0, and abort.import()gated on an iEEG recording with a spatial input, after the first frame; EEG and MEG viewers fetch neither it nor any electrodes file (e2e). Because the viewer must not importpanel.tsstatically, the rules it needs moved to the smalllayout.ts. This departs from ADR 0033's "loaded with the viewer's lazy chunk": the driver amends that line.Revert checks, each proved by a one-line mutation that fails the named test and reverted with a clean tree: stale token guard, mixed-units check, abort listener, slice size, abort before the first read, the floor in
stackedScopeHeightand in the stylesheet, the counter's trailing-comma handling; for e2e, Escape's focus return, EEG loading the panel, the floor in the viewer's fit,aria-controls.Mutation checks
Each test was shown to fail under a one-line mutation of
panel.ts, reverted afterwards (git status --porcelainclean). The card's five: skipping the reset on a recording change (1: selection kept; the in-flight read not aborted; activity state kept), starting reads with the switch off (2), removing the 4,000,000 bound (3), selecting only the first contact of a bipolar channel (4), omitting the credit in the refusal state (5). Fifty more for the other tests (stale tokens, group and frame change, closing the panel, the Nyquist and short-window refusals, selection toggles, bounds on position warnings, millimeters only when scaled, the default frame, the toggle's reasons, retry counts and pauses); none survived. Four e2e mutations were also caught (reads while off, credit omitted, a permanent refusal left enabled, layout always beside).Not run, would check
gh pr checks.Card: IS-V1. Part of #537