Skip to content

Quality views: sensor positions from names (W2b) - #603

Merged
neuromechanist merged 14 commits into
feature/issue-586-epic-pipeline-progressfrom
feature/issue-588-w2b-sensor-labels
Nov 26, 2026
Merged

neuromechanist merged 14 commits into
feature/issue-586-epic-pipeline-progressfrom
feature/issue-588-w2b-sensor-labels

Conversation

@neuromechanist

Copy link
Copy Markdown
Contributor

Part of #588 (epic nemarOrg/nemar-cli#2324)

Summary

Adds nemar.sensor-labels.v1 (neuroschema 0.6.0) as src/lib/quality-views/sensor-labels.ts, a pure, worker-safe port of neuroschema.views.sensor_labels, and puts both scalp-map paths on it.
The quality views' model (model.ts) now places sensor-field maps without a layout role by name, replacing the site's labels_pending word; the module and the fourteen montages it matches are loaded by dynamic import only when a map is placed by name.
The signal viewer's scalp map (eeg-viewer/scalp-map.ts) uses the same algorithm; name-placement.ts and its test are deleted, and with it the interim EGI-by-names rule (namedCap) the owner accepted until W2b.
Precedence is unchanged: measured positions in a known frame are used as they are; frame_unknown, positions_flat and positions_partial fall back to names with the reason kept in the caption; intracranial frames are never placed by name.
The refusal sentences live once, in src/lib/quality-views/sensor-labels-copy.ts; render/words.ts shows them as they are and the viewer shows them after "No scalp map:".
No standard-montage.ts or net-montages.ts remained on the base branch.

Maps lost, and why

  • A viewer recording placed by name with fewer than 8 candidate channels, or fewer than 8 matched names, now shows the refusal sentence (too_few_channels, too_few_matched) instead of a map; before, 3 matched labels drew one.
  • A viewer recording whose names are fewer than 80% one montage's (share_too_low), name pairs of electrodes (bipolar_labels), or fit two montages that disagree (montage_ambiguous, such as A1, A2 and C1 to C6) now shows its sentence.
  • Every EGI recording in the viewer placed by name is now cap_model_unknown: the recording store carries no CapManufacturersModelName, and names alone never decide an EGI net. Before, namedCap put numbered E labels on a HydroCel net by the highest number. Follow-up: the converter would need to embed CapManufacturersModelName and EEGReference in the store attrs; ScalpInput already takes capModel and reference.
  • A BioSemi recording now goes to the smallest cap its names fill (A1 to A32 is biosemi32), or is refused with net_coverage_low; before it went to biosemi128 or biosemi256 by the highest bank.
  • No e2e asserted a map from fewer than 8 labels: viewer-scalp-map.spec.ts (on004504, 10-20 names) still draws on standard_1005, so no e2e changed. Unit tests that pinned the old rule were changed: scalp-map.test.ts "places an EGI net's numbered channels on that net" now asserts cap_model_unknown without a cap model and GSN-HydroCel-129 with HydroCel GSN 128 1.0; "too_few_matched ... E1, E2, E300" became 7 of 8 names; "refuses labels no montage names" uses 8 names; a new case asserts three 10-20 names show the too_few_channels sentence; the MontageCenterUnavailable case is gone because the placed montage's own center is passed, so it cannot happen; the measured fixtures drop T3 to T6, which the 10-05 file lists beside T7, T8, P7 and P8 and which are duplicate_label by name.

Test plan

  • bun run typecheck: 0 errors, 0 warnings.
  • bun run lint: clean.
  • Targeted Vitest (test/quality-views-*.test.ts, src/lib/eeg-viewer, src/lib/quality-views): 42 files passed, 1 skipped; 2314 tests passed, 9 skipped.
  • test/quality-views-sensor-labels.test.ts: all 86 vector cases replayed exactly (every refusal reason covered), placed positions equal the montage files, the montage files' SHA-256 equal the vectors' and PROVENANCE.json's digests.
  • test/quality-views-models.test.ts: the 21 kinds-models cases placed by name are now compared whole (were labels_pending); quality-views-presets.test.ts spectrum_maps_names likewise.
  • Size (bunx astro build && bun scripts/check-quality-views-size.mjs --require-build), all gated rows ok. First screen Spectrum 28.8 KB (base 27.8), Components 28.4 (27.4), Spectrum no preload 29.1 (29.2), Components no preload 29.2 (29.2), Activations 26.4 (25.2), Activations no preload 26.8 (26.6), budget 30 KB; worker with lazy chunks 15.6 KB (15.6), budget 16 KB. sensor-labels is a lazy chunk of its own (2.7 KB gzipped), and each montage a lazy chunk; neither loads with a first screen.
  • Speed gate (bun run test:quality-views-perf), 7 passed. Medians of 5: montage_128 cold 2.4 / 17.3 ms, eager 11.0 / 26.1 ms; montage_256 cold 3.7 / 63.5 ms, eager 18.8 / 81.3 ms (first maps / view); budgets unchanged.
  • e2e on a private port (E2E_PORT=4417 PUBLIC_DATA_BASE_URL=https://data.nemar.org): viewer-scalp-map, quality-panel, quality-views-perf and the embed route specs (ieeg-spatial-panel, ieeg-subject-anatomy, ieeg-spatial-validation): 96 passed, 3 failed. The 3 failures are in ieeg-spatial-validation (on005415 and on004473 data-template-state) and fail the same way on the base branch (4 failed there), so they are not this change's.
  • CI's test job is expected to fail on exactly the 12 drift tests (compute-pipeline-contract-drift 5, quality-route-contract-drift 5, quality-views-vocabulary-drift 2).

Mutations (each applied alone, then restored; targeted tests: sensor-labels, models, presets, scalp-map)

Mutation Result Killed by
10-05 aliases applied to every family killed the rules: 10-05 aliases on a 10-20 named BioSemi cap
HydroCel alias (VREF) applied on 10-05 killed vector vref_outside_egi_nets and a rules case
MIN_MATCHED 7 killed vector too_few_matched, two rules cases
MIN_MATCHED 9 killed vectors eight_matched and 6 more
0.8 share check dropped killed 12 tests, vectors among them
tie not refused (montage_ambiguous dropped) killed vectors egi_e1_to_e28, egi_e33_ambiguous_with_biosemi_e_bank and 4 more
measured known-frame positions overridden by names, model killed 28 tests (kinds-models and spectrum cases)
measured known-frame positions overridden by names, viewer killed scalp-map "lays them out ... in their declared frame"
reference suffix not stripped killed vector reference_names

Agentic AI tools were used in preparing this PR.

@cloudflare-workers-and-pages

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

Copy link
Copy Markdown

@neuromechanist
neuromechanist merged commit fdf5bfc into feature/issue-586-epic-pipeline-progress Nov 26, 2026
3 of 4 checks passed
@neuromechanist
neuromechanist deleted the feature/issue-588-w2b-sensor-labels branch November 26, 2026 16:30
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