Repository navigation
W3: montages by digest, viewer topomap on sensor-field - #593
Merged
neuromechanist merged 15 commits intoNov 26, 2026
Merged
neuromechanist merged 15 commits into
neuromechanist merged 15 commits into
Conversation
Widen the vocabulary copy rule and its drift test to views/montages/*.json, PROVENANCE.json included, pinned by SHA-256 like the registry and vectors. Ship MNE-Python's and EEGLAB's license texts in the quality views' notice and list them under Required. Tested: drift test strict against the nemar-cli epic checkout.
Add montages.ts (strict nemar.montage.v1 reader) and a lazy per-file loader. The parity tests now read each montage center from the copied files, so the six template cases' center checks are independent of the vectors. Tested: montages, layout, field and worker tests.
The activity overlay takes its sequential colors from the quality views' SEQUENTIAL_STOPS and colorAt instead of the viewer's viridisColor. Digests taken from the former code pin the overlay's table and colorFor, ties included, as unchanged. Tested: iEEG spatial and colormap tests.
The live topomap is placed by nemar.sensor-layout.v1 (own positions; intracranial frames and non-EEG rows refused; unknown, flat or partial positions fall back to names and say why) or by name on neuroschema's montage files centered on each file's center, and drawn by nemar.sensor-field.v1 in the quality views' worker with the sequential map on the minmax axis. Every refusal, a montage that cannot load (MontageCenterUnavailable included) and a worker failure leave the map undrawn with a sentence. Removes the thin-plate spline, projectPositions, renderTopomap and the hand-copied montages. Tested: viewer, scalp-map and name-placement tests.
The size check now measures from every dynamically imported chunk whose static imports reach the client, so two lazy panels sharing a split-out client are each counted with their own code (website#592); the client's own in-thread fallback is never a root. The measuring half moves to quality-views-size-lib.mjs and is tested on made-to-order chunk layouts. Tested: astro build and the size check (client chunk 11.6 KB gz with its imports, worker 5.2 KB gz).
Name scalp-map.ts, name-placement.ts, the montages and the size library in the architecture map, and update the CI comment on the size step. Docs only.
Hide the empty canvas and the legend while a refusal stands in for the map, and show them again when a map is drawn. Checked in the dev server on a refused and a drawn recording.
Before and after the move onto nemar.sensor-field.v1, from the dev server on public recordings: own positions (on002718, nm000103), names on standard_1005 (on004504), and a refusal for untyped channels (on004584). Docs only.
On the embed route with public recordings: a map through the module worker, template positions by name with their note, and a refusal that hides the canvas and legend. Tested: 3/3 locally against the dev server.
Deploying nemar-website with
|
| Latest commit: |
165feb7
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://903e1fd8.nemar-website.pages.dev |
| Branch Preview URL: | https://feature-issue-588-w3-montage.nemar-website.pages.dev |
5 tasks
After a refused projection, place by name only the positioned rows typed EEG, as neuroschema's drawn_rows and named_eeg do; positioned EOG, ECG and MISC rows and rows naming no channel no longer block it. Add positions_unmatched (a viewer word), too_few_channels and no_eeg_sensors on the names path, and pin the store's OTHER as untyped. Regression fixtures from nm000254, on003690 and on003039 now place on standard_1005. Tested: eeg-viewer tests, mutations killed.
Comment in name-placement.ts that choosing an EGI net by names alone, the missing 0.8 share rule and the other sensor-labels checks are an accepted deviation from ADR 0137 that W2b removes. Comment only.
The size walk also measures every chunk that statically imports the client but sits in no lazy root's set, and names the chunks above it in a note; the client's own lazy fallback is excluded. Reproduces the review's page -> dataset-panel -> worker-client layout. Tested: size tests, astro build and the size check.
on004584 shows the reworded no_eeg_sensors sentence; nm000254 (frame Other, positioned ECG and EOG rows) now places its EEG rows by name on standard_1005. Docs only.
no_eeg_sensors on the positions path says the positioned channels are not EEG when some channel is; a recognized net matching one or two names and the 10-05 montage none says too_few_matched. Tests for both, and for placing only the drawn rows (no unpositioned EEG channel, no OTHER channel with an electrode name). Tested: eeg-viewer tests, mutations killed.
staticImports also follows export {..} from and export * from, so a facade re-exporting the client is measured; each docblock now sits above its own function. Tested: size tests, astro build and the size check.
neuromechanist
merged commit Nov 26, 2026
a1e4fc8
into
feature/issue-586-epic-pipeline-progress
3 of 4 checks passed
This was referenced Nov 26, 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.
Phase W3 of the quality-views epic (#586), tracked in #588, part of nemarOrg/nemar-cli#2324 (nemar-cli ADR 0137 as amended; website ADR 0035).
What changed
scripts/copy-quality-views-vocabulary.mjsandtest/quality-views-vocabulary-drift.test.tsnow copyviews/montages/*.json,PROVENANCE.jsonincluded, intosrc/lib/quality-views/vocabulary/montages/, pinned inpin.jsonlike the registry and the vectors.A
montages/entry the rule cannot place is refused, never skipped.The drift test also checks that every montage
PROVENANCE.jsonlists is shipped at the digest it records.CI's sparse checkout adds the montages folder, so the "hash what nemar-cli has beside its list" check covers them.
MNE-Python's BSD-3-Clause text and EEGLAB's BSD 2-Clause text ship in
public/licenses/quality-views/NOTICE.txt, item 3, beside the color maps' notices.They are also listed under Required in
THIRD_PARTY_NOTICES.md, with the upstreamsPROVENANCE.jsonrecords (FieldTrip, EGI, BioSemi; none states a license).test/quality-views-montages.test.tsholds both license texts to the onesPROVENANCE.jsoncarries.montages.tsreads onenemar.montage.v1file strictly.montage-loader.tsfetches one montage per lazy chunk, and PROVENANCE.json is never fetched.montageCentersFrom(which read the center from the vector itself) is replaced bymontageCentersFromFiles, which reads each center from the copied files.The six template cases (
positions_template,positions_template_midline,template_montage,template_full_1005,template_midline_9,template_coronal_9) now check their centers against data the vectors do not supply.eeg-viewer/scalp-map.tsplaces the sensors once per recording:sensorLayout.Pixels,ACPCandScanRASare refused withframe_not_scalp, with no fallback to names.no_eeg_sensors.positions_unmatched(a viewer word).frame_unknown,positions_flatorpositions_partial, the drawn rows (the positioned rows typed EEG, as neuroschema'sdrawn_rowsandnamed_eeg) are placed by name instead. Positioned EOG, ECG and MISC rows, and rows naming no channel (GND, REF), neither block the fallback nor are placed. The reason is kept (unused_positions) and shown.too_few_channels, and scalp channels all typed and none EEG areno_eeg_sensors. A recognized net that matches one or two names, with the 10-05 montage matching none, istoo_few_matched; no match anywhere stayslabels_unrecognized. The store'sOTHER(a channels.tsv type ofn/a) reads as untyped, pinned by a test.name-placement.tson neuroschema's montage files, centered on the file's own center (see "Accepted deviations from ADR 0137", item 1).nemar.sensor-field.v1in the quality views' worker. The viewer importsworker-client.tslazily, so the client is a chunk of its own. One draw is in flight at a time, and the newest request replaces any queued one.SEQUENTIAL_STOPSon theminmaxcolor axis, with EEGLAB's head, nose and ears, and a marker per plotted row.SCALP_MAP_SENTENCES): the canvas and legend are hidden, and the sentence stands in their place.labels_unrecognized,montage_unavailableand the three sensor-field words.MontageCenterUnavailable, which is caught by type.viewOfPlacement,viewOfDraw) under test.aria-pressedand title. The title now also says "template positions from " or gives the refusal sentence.topo.ts(the thin-plate spline,projectPositions,renderTopomap,viridisColor,VIRIDIS_CSS) and its test, plus the hand-copiedstandard-montage.tsandnet-montages.ts.ieeg-spatial/activity.tsandlive-activity.tstake their colors fromcolorAt(SEQUENTIAL_STOPS, ...). Digests taken from the former code pin the overlay's 256-entry table andcolorForat 102,001 values, rounding ties included: the colors are unchanged.The measuring half moved to
scripts/quality-views-size-lib.mjs.Its roots are now every chunk that something other than the client imports dynamically and whose static imports reach the client.
So two lazy panels that share a split-out client are each measured with their own code.
The client's own in-thread fallback is never a root.
test/quality-views-size.test.tsruns it on made-to-order chunk layouts, including the Quality views: W2 follow-ups (cold first view, size gate, guard tests) #592 layout, where one panel is over budget and the earlier rule did not see it.Static imports include the re-exports
export {..} fromandexport * from, so a facade that re-exports the client is followed.It also measures every chunk that imports the client statically but sits in no lazy root's set (a page that statically imports a panel that imports the client), against the same budget, and names the chunks above it (the page) in a note. The review's
page.js -> dataset-panel.js -> worker-client.jslayout is a test case.e2e/viewer-scalp-map.spec.ts, covers a drawn map through the worker, template positions with their note, and a refusal. It runs locally only, like every e2e spec here.The visible change
Before is on the left and after on the right. All four were taken from the local dev server on public recordings, at the window's center (5.00 s).
n/aOther, positioned ECG and EOG rows; its 61 EEG rows placed by nameWhat differs, and why:
minmaxwith a 5% margin, not symmetric ±max.The legend reads, for example, −85 µV to 32 µV where it read ±61 µV, and the full color range is used.
This is the amendment's
minmaxrule, with the sequential map.The field interpolates each value's deviation from the mean and adds the mean back, so a shared offset no longer ripples across the map.
The old thin-plate spline had an affine term and a ridge, so the maps differ in shape and not only in color: on002718's frontal low and parietal high stand out more.
The nose and ears are EEGLAB's polylines, and the head circle is drawn at
0.5 * squeezefac, while the field fills the 0.5 circle.When sensors sit below the equator, as on EGI nets (nm000103) or with T7/T8 at the rim (on004504), the head is drawn smaller inside the field, as EEGLAB's
topoplotdoes.The old view squeezed every sensor inside the rim.
A map needs 8 interpolated sensors (
too_few_sensors), where the old one drew with 3.None of these four is affected; a recording with 3 to 7 placed channels now shows the sentence.
nm000254's positions are in
Other; the old view projected them in an assumed frame. The new one does not use them, says why, and places the 61 EEG rows by name on standard_1005.on004584 and on003478 drew maps before.
Their channels.tsv types every channel
n/a, which the converter stores asOTHER, so no positioned row is typed EEG and the map is refused withno_eeg_sensors, as the amendment defines it ("untyped, or ..."). See "Accepted deviations from ADR 0137", item 2.Chunk sizes (production
astro build, gzip level 9)viewerworker-client(lazy, first imported by the viewer)worker-*.jsworker.*.js(only withoutWorker)standard_1005montage (lazy, on demand)GSN-HydroCel-129/-257,biosemi128/256montagesbun scripts/check-quality-views-size.mjs --require-buildreports two site-build lines.The main thread is measured from
worker-client: 11.7 KB gz with its static imports, against a 30 KB budget. Those imports include the embed page's own chunk, which holds Vite's preload helper.The worker is 5.2 KB gz against a 12 KB budget.
The entry build gives 5.2 KB and 5.2 KB.
Mutation testing
The script lives outside the repository. Each mutation edits one file, runs the named Vitest files, and restores the file.
montages/MontageCenterUnavailablenot caught by the placementu(a rounding tie differs)no_eeg_sensorslabels_unrecognizedtoo_few_channelsOTHEROTHERread as a typeno_eeg_sensorssentence never chosenlabels_unrecognizedTesting
bun run typecheck: 0 errors, 0 warnings.bun run lint: clean.src/lib/eeg-viewer,src/lib/ieeg-spatial): 1,494 passed, 4 skipped (after the review fixes). The skips are the perf gate outside its step, and the vocabulary drift's nemar-cli checks with no sibling checkout.NEMAR_CLI_QUALITY_VIEWS) against a checkout of nemar-cli's epic branch: 15/15.bunx astro build, thenbun scripts/check-quality-views-size.mjs --require-build: passes (sizes above).bun run test:quality-views-perf: 128 sensors, median view 23.6 ms (first maps 8.1 ms); 256 sensors, 76.3 ms (14.4 ms). Cold first run: 60.7 ms and 86.2 ms.bun run test: 7,033 passed, 52 skipped (after the review fixes).e2e/viewer-scalp-map.spec.tsagainst the local dev server: 3/3.Expected red in CI, as in W1 and W2: the 6 vocabulary and pipeline drift tests compare with nemar-cli
dev, which does not carry neuroschema 0.6.0 until epic nemarOrg/nemar-cli#2324 merges there.The budget steps run regardless.
Accepted deviations from ADR 0137
name-placement.tskeeps the #855 rule: numberedElabels give a HydroCel 129 or 257 net by the highest number, BioSemi bank labels a BioSemi cap, otherwise the 10-05 montage, case-insensitive, with T3/T4/T5/T6. The coordinates and centers are neuroschema's files.ADR 0137's amendment forbids the first part: a recording is placed on a HydroCel net only when its
CapManufacturersModelNamenames that net, because older EGI nets number their electrodes alike on other positions, so names alone never decide an EGI net.The #855 rule also has no 0.8 share rule (only 3 matched names and BioSemi's 60% bank dominance), and checks none of
montage_ambiguous,duplicate_label,net_coverage_lowor the hyphen split; that is part of this deviation.W2b replaces the file with
nemar.sensor-labels.v1and removes all of it; a comment inname-placement.tssays so.W3 ships the strict rule: the store's
OTHER(a channels.tsv type ofn/a) is untyped, and measured positions with no row typed EEG are refused withno_eeg_sensors(on004584, on003478 and 27 more of the surveyed recordings).The owner is taking a narrow rule to ADR 0137 and neuroschema 0.6.1: in an
_eegrecording, a positioned row typedn/aorOTHERcounts as EEG unless its name carries a non-EEG prefix, and explicit non-EEG types stay out.The viewer follows once neuroschema 0.6.1 lands; it is not implemented here.
Other deviations
too_few_matchedis sensor-labels.v1's word, used here for the interim rule's partial matches), each with its sentence:positions_unmatched(an electrodes file naming none of the recording's channels),montage_unavailable(a montage that cannot be loaded,MontageCenterUnavailableincluded) andworker(a worker that cannot draw). No specification word covers them.contours: "none"), as before. The worker's contours stay available for W4's views.minmaxaxis's two ends with their signs, where it showed ±max.frame_unknownfalls back to names, never to an assumed frame).Upstream converter note
on004022's channel labels carry trailing spaces in the store (
"C3 "), while its electrodes file saysC3, so no exact name matches and the viewer sayspositions_unmatched.That is a converter matter, not a viewer one: the viewer compares names exactly, as the specification does. No code change here.
Effect on the surveyed recordings
Of 622 surveyed recordings, 269 carry positions. The 54 whose positions have a non-EEG or unmatched row were run through the first revision and through this one, on their real store attributes:
no_eeg_sensorsbefore; now 29no_eeg_sensorsand 11positions_unmatched(electrodes files labeled1,2, ... orFp1against channelsE1orChannel1; on004022's channel labels carry trailing spaces, so no exact name matches).Otheror an undeclared frame, allframe_unknownbefore, now place by name: nm000254, on003690, on003039, on005473 and on005280 on standard_1005 (59 to 64 channels), on004000 on biosemi128 (100), and on007987 and on006171 on standard_1005 with 6 channels each, which the map then refuses withtoo_few_sensors.What W4 needs
The viewer now creates the worker on the first draw after the panel opens.
The cold numbers above (60.7 ms at 128 sensors against a median of 23.6 ms) are the same cold JIT that Quality views: W2 follow-ups (cold first view, size gate, guard tests) #592 measured.
The viewer's layout is known as soon as the store opens, so building the geometry early would warm the worker, but only for views that send their layout first.
Two things to know for the fix:
layoutKeyand checks the numbers, so any stable key works.SensorFieldClientstarts its own worker. A page that shows a quality panel beside the viewer would hold two unless they share one client.montage-loader.tsandcentersOfgive W4's sensor-field views without a layout role themontageCenterthey need for template positions;sensorLayoutstill throwsMontageCenterUnavailablewithout it.name-placement.tswithnemar.sensor-labels.v1on the same montage files, and adds the nine label refusal words toSCALP_MAP_SENTENCES.Refs #588, #592, nemarOrg/nemar-cli#2324
Agentic AI tools were used.