Skip to content

W7: Activations tab - #599

Merged
neuromechanist merged 21 commits into
feature/issue-586-epic-pipeline-progressfrom
feature/issue-588-w7-activations
Nov 26, 2026
Merged

neuromechanist merged 21 commits into
feature/issue-586-epic-pipeline-progressfrom
feature/issue-588-w7-activations

Conversation

@neuromechanist

Copy link
Copy Markdown
Contributor

Refs #588, nemarOrg/nemar-cli#2324

Summary

Phase W7 of the live quality views (#588, epic #586, nemarOrg/nemar-cli#2324; nemar-cli ADR 0137 decision 9 as amended, website ADR 0035): the panel's Activations tab.

The browser applies no preprocessing. The activations are one multiply of the serving copy's physical values by the matrix the recipe wrote (_servingunmixing.tsv, with the unmixing, the sphere, the average reference and the store unit folded in). Each component is then drawn through a 1 Hz zero-phase high-pass, for display only.

Where the work runs

  • transforms/ic-activity.ts is a lazy chunk of the map worker. It runs checks 2 to 13 of neuroschema's docs/views/ic-activity.md, in order:

    • the inputs' locations and the decomposition's store;
    • each file's cap, presence, size and SHA-256;
    • the store digest, the rate and the window;
    • the matrix, the components and the bad segments;
    • the channel match, the units and the filter.

    It then does the multiply and the display filter: binary64 in the specification's order, real context of up to one second on each side, and the odd extension only at the recording's own ends.

  • The worker keeps no state between its two steps.

    • plan checks everything and returns the plan.
    • Only then does the page read the store's samples.
    • compute receives the samples transferred, and returns the activations and the filtered values transferred.
  • activations.ts runs on the main thread. It covers:

    • check 1 (the kind, then the declaration through the worker's guards);
    • the files, fetched but not read;
    • openServingStore and readLevel0: the Zarr group's channels (labels, units, scales and offsets as stored, absent where absent) and level-0's int16 for the plan's rows only;
    • the transfer;
    • the gl-trace adapter: one stacked trace per component, a.u. on the scale bar (ViewerFrame.unitLabel, new);
    • shading through renderChrome/shadedRects.
  • The viewer's reader is not imported statically. store.ts (for makeStore), zarrita, gl-trace.ts and render.ts are dynamic imports. They are the same chunks the page's viewer loads.

  • extras/activity.ts is the tab's lazy chunk. It builds the figure:

    • the caption;
    • Earlier and Later windows of 10 s, capped by max_window_s;
    • an aria-label naming the components and the span;
    • the notes: computed in the browser with no preprocessing; the archive caption when the decomposition read the archive; the display filter; the digest state; the transform's own caption; no_shaded_rows or no_bad_segment_table; and how many repaired spans are shaded in the window.
  • A refusal draws no activations. It shows its sentence (new ACTIVITY_SENTENCES in panel-words.ts, asked for as activity:<word>) and offers the three files.

  • The page gives the panel the store's address (registerStoreUrl in panel-bridge.ts, set in [id].astro with the index's cache token).

  • Store digest: every view is not_checked until Converter: write each Zarr group's content digest at commit nemar-cli#2343 (open question 1). The reader states no published digest.

  • floor-tables.ts: the floor's table reading and the product-stem rule are moved out of signal-window.ts, so the worker's transform does not carry the Signal tab.

Gates

  • bun run typecheck: 0 errors. bun run lint: clean.
  • Targeted Vitest: quality-views-*, quality-panel*, quality-summary*, src/lib/eeg-viewer, src/lib/quality-views.
  • test/quality-views-ic-activity.test.ts (new, 115 tests). It holds:
    • every C9 case (ic-activity.v1.json) on state, components, rows, factors, times, activations and filtered within 1e-6 of each component's peak, plus the shading and the notes;
    • every refusal word, checks on both threads in order;
    • the coefficient and filter cases;
    • the store_checks digest states;
    • an explicit channel-set refusal group (and a duplicated label matched by label);
    • the window cap (exactly floor(max_window_s·rate) passes, one more refuses, the first window never exceeds it), and a window ending at the last sample passes while one past refuses;
    • the worker path: same numbers, both steps answered by the worker, the samples' buffer transferred;
    • a recording switch: no read after the plan, no compute after the read;
    • readLevel0 on a real zarrita array (multi-chunk), rows in the plan's order.
  • bunx astro build then check-quality-views-size.mjs --require-build: pass (numbers below).
  • bun run test:quality-views-perf on M4: pass, no regression (below).
  • Playwright: quality-panel (18, 5 new for Activations), quality-views-perf (2), viewer-scalp-map, viewer-quality-marks: 25 passed. The Activations e2e serves a real Zarr v3 store (uncompressed int16, the converter's attributes) through page.route, so the page's own reader, zarrita and the worker run unchanged.
  • Full bun run test: 8,514 passed, 59 skipped, 0 failed. The drift tests skip here, because no NEMAR_CLI_* checkout was given. In CI they are the expected 8 failures..

Measured

Size (real site build, gzip 9, gated):

What Size Budget
First screen, Activations tab 24.4 KB 30 KB
Activations tab with no idle preload (and the record reader) 26.1 KB 30 KB
Lazy root activity (sum of separate files) 29.1 KB 30 KB
Worker with its lazy chunks (guards-computed + ic-activity) 15.1 KB 16 KB
Spectrum / Components tabs 28.0 / 27.7 KB (was 27.7 / 27.4) 30 KB
... with no idle preload 29.3 / 29.4 KB (was 29.0 / 29.2) 30 KB
Lazy root sensor-field-view 29.8 KB (was 29.5) 30 KB

Printed, not gated (owner's call): the Activations tab together with the viewer chunks it loads lazily (store, zarrita, render, gl-trace and their imports) is 47.6 KB, or 49.3 KB with no idle preload.

The transform's own chunk is 2.9 KB in the worker. Its in-thread copy, loaded only when no worker can start, is 2.5 KB.

Speed (M4, Vitest gate, median of 3, before → after):

Case Before After
256 sensors, panel opened after page load: first maps / view 17.2 / 78.9 ms 17.6 / 80.3 ms
128 sensors, panel opened after page load 8.4 / 24.4 ms 7.1 / 22.3 ms

These are within noise. The browser perf spec passes (256: first maps 17.9 ms median).

The transform (computeActivity in Bun on M4, median of 5):

Channels Components Window Time
64 63 10 s at 250 Hz 7.7 ms
128 127 10 s at 250 Hz 27.6 ms
256 255 10 s at 250 Hz 105 ms
128 127 30 s at 250 Hz 72.8 ms

It runs off the main thread.

Mutations (each must fail its suites)

The script is kept outside the repository. All 40 were caught (3 after added tests).

Mutation Result
T01 a published digest that differs is drawn caught
T02 a rate of 0 or below passes caught
T03 a window one past the store passes caught (after the new test)
T04 the window cap one sample too loose caught
T05 more component rows than matrix rows pass caught
T06 bursts repaired and none shaded: drawn caught
T07 no table said as no rows caught
T08 labels compared without case caught
T09 a label at two store rows takes the first caught
T10 store_row not checked against the label caught
T11 unit factor inverted caught
T12 cutoff at Nyquist passes caught
T13 the store offset dropped caught
T14 the browser re-references the store's values caught
T15 no real context before the window caught
T16 the odd extension one sample short caught
T17 padded at a start that has real context caught
T18 the filter starts from rest, not its steady state caught
T19 times from the window, not the recording caught
T20 matrix cells read without the number grammar caught
T21 the matrix's location not compared caught
T22 another recording's tables accepted caught
T23 the decomposition's store digest not compared caught
T24 a file's digest not checked caught
T25 presence checked before the cap caught
T26 the components' cells counted without the header's columns caught
T27 the recurrence's feedback sign caught
A01 kind_version true read as 1 caught
A02 the declaration not checked caught
A03 the store read after a switch caught
A04 computed after a switch caught
A05 no burst repaired read as repaired caught
A06 the first window ignores max_window_s caught
A07 level-0 rows read in span order, not the plan's caught
A08 an unpublished digest read from the store's attributes caught
P01 no Activations tab caught
P02 activations built as a stored-data view caught (after the new test)
W01 the worker posts the plan unawaited caught
X01 a store of another recording read caught (after the new test)
X02 no serving copy said nowhere caught

Deviations and judgment calls

  • Checks 2 to 4 run in the worker, not on the page. The page fetches the three files (never one whose declared size is over the cap) and the worker checks locations, the decomposition's store, then each file's cap, presence, size and digest, in the specification's order. This keeps the page's chunk inside 30 KB: the first draft, with these checks on the main thread, put the activity root at 30.7 KB. The cost is that a refused view may have downloaded its (small) files before the location check refuses it; nothing is parsed before its check.
  • The page gives the store's address, not a reader. A page-level dynamic import of activations.ts split model.ts into a chunk of its own, adding 0.24 KB to every tab.
  • Scale and offset: a store row whose scale or offset is not a finite number is treated as having no unit (unit_unknown), so it refuses rather than draws NaN. The specification has no word for it.
  • Window: the tab draws 10 s at a time (capped by max_window_s) from the recording's start, with Earlier and Later. Each window is computed with its own context, as the specification allows.
  • No hover readout. Activations are computed, not stored rows, so the C14 "snap to a stored row" rule has no row to print. The figure says the values are computed and in arbitrary units.
  • Shared code touched (W8/W9 overlap):
    • panel-model.ts: one TABS entry. Activations sits between Components and Signal, as ADR 0137 lists them.
    • panel.ts: one EXTRAS entry, and COMPUTED replaces the single signal-window comparison.
    • worker-client.ts, worker-protocol.ts, worker.ts: the activity message.
    • panel-bridge.ts: registerStoreUrl and storeUrlOf.
    • render.ts: unitLabel.
    • The panel's base set grew about 0.2 KB, so sensor-field-view's root is at 29.8 of 30 KB, leaving W8 little room on that root.
  • e2e: the "no Other views" test now makes its Other view by giving the activation view an unknown kind, since activations are no longer under Other. ArrowLeft from Signal lands on Activations.
  • ADR 0035: a W7 addendum (where the work runs, the viewer's reader, the not-gated viewer union, not_checked).

Agentic AI tools were used.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

@neuromechanist
neuromechanist merged commit e478545 into feature/issue-586-epic-pipeline-progress Nov 26, 2026
3 of 4 checks passed
@neuromechanist
neuromechanist deleted the feature/issue-588-w7-activations branch November 26, 2026 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant