Skip to content

NEMAR procedures: band power topography, ERP topography, time-frequency by condition (#721) - #722

Merged
neuromechanist merged 13 commits into
developfrom
feature/issue-721-topography-tf-procedures
Nov 11, 2026
Merged

neuromechanist merged 13 commits into
developfrom
feature/issue-721-topography-tf-procedures

Conversation

@neuromechanist

@neuromechanist neuromechanist commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Refs #721
Refs #719

Summary

Three more NEMAR procedure documents (band power topography, ERP topography, time-frequency by condition), so NEMAR declares seven.
This PR finishes #721 on the existing commits: the shared electrode position table is trimmed from 343 to 92 labels, the shared scalp-map prose is trimmed, the time-frequency slow-run warning is tested, the compute block is timed in the Pyodide lane. The dataset page's starter questions are unchanged (see the update below).
The issue stays open: it needs the post-merge consistency check and live runs, which are the maintainer's.

  • Position table: the 10-10 labels (Fp1 to Iz), the aliases T3 T4 T5 T6, and the sites A1 A2 M1 M2, derived from the existing table (not re-derived from MNE), same fence in both documents.
    I1, I2 and every 10-05 label (AFp1h, FFC1h, ...) are gone.
    A1, A2, M1 and M2 were already in the old table, so none had to be placed again.
  • Time-frequency: the maintainer's slow-run warning (single processor, limited compute and memory) is unchanged, word for word; a test now pins its phrases and that it comes before the numbered steps.
  • Dataset page: unchanged. A scalp-map starter question was added and then removed in ad663ba: many NEMAR datasets name channels in schemes the 10-10 table cannot place (EGI E1 to E128, BioSemi A1 to D32), and it would have pushed the ERP image question out of the first three. A test pins the ERP image among the first three and no scalp-map template.
  • Test lane: frontend/test-data-lane.js times the document's compute block (one warm-up, three timed runs, median, printed and never asserted).

Size

Prompt size (measured with the real CommunityConfig and CommunityAssistant._format_procedures_section):

develop (4 procedures) this branch (7 procedures)
len(nemar.system_prompt) 12,914 12,914 (unchanged: the procedure list is not part of it)
## Known procedures section, propose_plan bound 1,269 1,907 (+638)
## Known procedures section, no propose_plan 1,068 1,706 (+638)

The seven documents, in characters (len(document) from procedure_documents(); the limit is 32,000):

document before the trim (b0db120) after
power-spectrum 5,822 5,822
band-power 7,457 7,457
erp-by-condition 4,443 4,443
erp-image-by-condition 5,712 5,712
band-power-topography 23,820 16,757
erp-topography 22,313 15,250
time-frequency-by-condition 9,666 9,674 (slowness rationale reworded)

The position fence went from 8,998 to 2,251 characters.
The issue's target of about 12,000 characters per topography document is not met, and the test cap (TOPOGRAPHY_SIZE_CAP) is 17,000, not 12,500.
The table was 9k of 22 to 24k; most of the rest is the shared drawing and matching blocks, the byte-identical Welch and filter blocks and the plan, which tests pin byte for byte.
Those pins are test choices and could be relaxed, so going lower is possible, but it means cutting shared blocks and loosening tests.
Accepted by the maintainer's session: about 17k per topography document (about 4,200 tokens, fetched only for a topography request). The 12,000 figure in the brief was an estimate made before the shared blocks were counted.
The PR stays on Refs #721 until that is decided; the headroom test (under 28,000) stays.

What nm000132 sub-001 N170 shows

Every block was run from the documents' own fences (scratch environment outside the repo, CPython 3.12 with eegprep_lean 0.5.0, the real recording, sub-001/eeg/sub-001_task-N170_eeg.set, group eeg_250hz, events from events.tsv), against the trimmed table.
All of the earlier figures are confirmed; none moved.

  • 30 EEG channels kept; HEOG_left, HEOG_right, VEOG_lower left out; all 30 have a position (left out, no position: none).
    The removed 10-05 labels change nothing for these 30 channels, nor for C3, Cz, C4.
  • Alpha (8 to 13 Hz) band power, 683 s, 682 segments: largest at FP2 (149.4), FP1 (148.1), F8 (144.8), F7 (136.5), F4 (132.2), F3 (130.3) in uV squared; smallest at Pz (15.6), PO3 (14.6), P3 (14.4).
    A frontal maximum, not the textbook posterior one.
  • ERP topography (average reference, 30 Hz low-pass, 150 to 190 ms): 60 face and 61 car epochs kept (20 and 19 of 80 dropped by the 100 uV rule).
    Face minus car is most negative at P9 (-4.55 uV), P10 (-3.57), PO7 (-3.46), P7 (-3.19) and most positive at FC4 (+4.14), F4 (+3.86), FCz (+3.23), Cz (+3.03).
    PO8 face minus scrambled face, 150 to 260 ms, mean -4.19 uV (79 and 78 epochs at that channel alone).
  • Time-frequency at PO8, 4 to 40 Hz, no filter, 67 face and 65 car epochs after the rule: alpha 8 to 13 Hz, 200 to 600 ms is -6.1 dB (face) and -6.3 dB (car); the largest change is -8.65 dB at 8 Hz, 384 ms (face) and -8.32 dB at 8 Hz, 404 ms (car).

The slow-run figure: not added

The lane measures the compute block (80 epochs per condition, 2 conditions, 19 frequencies, 250 Hz) at a median of 0.033 s (runs 0.032, 0.033, 0.037 s) in Pyodide under Bun on an Apple M4 laptop, 10 cores, 16 GB, not a browser; native CPython gives 0.016 s after a first call of 0.34 s.
That is not a figure of "about N seconds", and I did not extrapolate a browser figure, so the warning gains no "(about N in testing)" and there is no regex assertion for one.
The compute block alone is not what makes the run long on a single-processor browser with limited memory (the read, the package load and a longer window or more epochs are); the maintainer's warning stands as written.

Tests

  • tests/test_assistants/test_nemar_runtime.py: the table test is renamed and updated (aliases and extras, 3 decimals, radius bound, T3 == T7, T6 == P8, Cz at the origin, every other label a 10-10 label); both documents carry byte-identical fences under the size cap; the count in both documents and in CHANGELOG.md is the table's real count; every label of nm000132's 30 EEG channels (which are ERP CORE's 30, so nothing extra to add) and of xx099905's 3 is positioned after the document's own locate() and left out, no position: none prints; the time-frequency plan holds the warning's five phrases before the first numbered step.
  • Checked against the issue's Verify list: seven procedures load, each plan normalizes via normalize_step, shared blocks are byte-identical, markers only below 8 positioned channels with the plan still proposed, disjoint when lines, filtering decided once in time-frequency, findings for few channels. No gaps found.
  • scripts/plan_consistency.py was not changed or run (paid LLM calls); the post-merge consistency check and the live runs are the maintainer's.

Commands run

  • uv run python promptsize.py (scratch): prompt and document sizes above
  • uv run pytest tests/test_assistants/test_nemar_runtime.py: 107 passed
  • uv run --python 3.12 --all-extras pytest tests/test_assistants tests/test_core tests/test_frontend tests/test_api --no-cov: 4353 passed, 21 skipped, 0 failed (after the round-2 fixes; the earlier full run had 5 external-service failures unrelated to this change)
  • bun frontend/test-data-lane.js: 246 passed, 0 failed (same 30 labels, and the 3-label case C3, Cz, C4)
  • uv run ruff check . and uv run ruff format --check .: clean

…frequency by condition

Three documents and their config entries (seven procedures now); the two
sound-alike when lines are reworded. Blocks run on nm000132 sub-001 by hand;
the tests and the browser lane follow in later commits.
Declared step sequences for the three new documents, byte-identical shared
blocks, the position table against nm000132's 30 EEG labels and xx099905's
three, the few-channel caveat, and the when lines. Tested: pytest.
30 and 3 positioned channels draw one figure each (surface and markers, or
markers only); a synthetic tone peaks at its frequency and time in the dB map.
Tested: bun frontend/test-data-lane.js, 238 passed.
…s slow (single processor, limited compute and memory) and name ways to shorten it

Tested: tests/test_assistants/test_nemar_runtime.py, tests/test_core/test_config, tests/test_scripts pass.
…pute block in the Pyodide lane (printed, not asserted); tested
@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Preview Deployment

Name Link
Preview URL https://feature-issue-721-topography-demo.osc.earth
Branch feature/issue-721-topography-tf-procedures
Commit fca26e5

This preview will be updated automatically when you push new commits.

@neuromechanist

Copy link
Copy Markdown
Member Author

Review round 1: outcomes

Fix commits are on this branch (289c673, fb375bc, 715555b).
Checks run: uv run --python 3.12 --all-extras pytest tests/test_assistants tests/test_api/test_communities_endpoint.py tests/test_core/test_config (1174 passed, 16 skipped), bun frontend/test-data-lane.js (246 passed, 0 failed), ruff check and ruff format --check clean.

  1. Size criterion (important): partly fixed, the criterion is still not met, maintainer sign-off needed.
    Trimmed the shared scalp-map prose (the derivation paragraph and a restated sentence) in both documents: band-power-topography 17,278 to 16,757, erp-topography 15,771 to 15,250.
    The test cap is now TOPOGRAPHY_SIZE_CAP = 17_000 (about 1.5 percent above the larger document, so growth shows), and the comment states the 12k target is not met.
    Reaching about 12k is not possible from these documents alone: band-power-topography must contain band power's whole Step 1 byte for byte (a test pins it, about 6k), and the shared position, matching and drawing fences are about 7k more.
    Going lower means changing band-power.md and the shared blocks together.
    Maintainer: please either accept about 17k per topography document (record it in NEMAR procedures: band power topography, ERP topography, time-frequency by condition #721) or say to cut the shared blocks.
  2. Scalp-map suggestion never shown (important): fixed.
    Moved it to third in dataset_suggested_questions, ahead of the ERP image, so a Zarr dataset shows it on the opening screen (first three) and a dataset without Zarr is unchanged.
    Updated the comment above the list and added test_the_scalp_map_is_among_the_three_dataset_page_questions_a_zarr_dataset_shows.
  3. CHANGELOG missing the slow-run warning (suggestion): fixed.
    The entry now describes the time-frequency warning (before approval and in step 3, with ways to shorten the run), the printed lane timing, the third-place dataset question, and the topography sizes and cap.
  4. Time-frequency rationale unevidenced (suggestion): fixed in the document, PR-body claim softened here.
    The document no longer blames step 3's arithmetic: it says the run will likely take a long time on a single processor with limited compute and memory, longer with more epochs, more frequencies or a longer window.
    The user's warning wording is kept.
    I did not extend the lane to time the read and package load end to end; to be exact, the lane measures only the compute block (0.033 s in Pyodide under Bun), and that the browser run is slow is expected but not measured here.
  5. Ordering assertion on raw text (suggestion): fixed.
    Both indexes are now taken on the flattened Plan section, which is already cut at the next ## .
  6. Test clutter (suggestion): fixed.
    Removed the duplicate position-fence equality (the marker test pins it), the local import ast, and moved C3, Cz, C4 out of TABLE_ALIASES_AND_EXTRAS (they are now checked by a separate membership assertion and by the 10-10 pattern).
  7. PR-body figures from a scratch environment (suggestion): rejected, no code change.
    The nm000132 N170 numbers come from a run outside the repository on the real recording; the reproducible parts (the blocks run in the Pyodide lane, label coverage of the 30 and 3 channels) are in the tests.
    Not filed as an issue; nothing in the PR's code is affected.

@neuromechanist

Copy link
Copy Markdown
Member Author

Review round 2 outcomes (fix commit e15e12c on this branch):

  • Size target not met (important): filed for maintainer decision, not changed. The topography documents are 16,757 and 15,250 characters against about 12,000, with a test cap of 17,000. Reaching 12.5k means cutting the shared blocks and relaxing the byte-pin tests, which is a design choice for the maintainer. The PR body now says so and the PR stays on Refs #721; please record the accepted cap in NEMAR procedures: band power topography, ERP topography, time-frequency by condition #721 or ask for the cut.
  • PR body stale (important): fixed. Sizes (16,757, 15,250, 9,674 for time-frequency), the 17,000 cap, the reordered dataset question and the commands were updated (107 passed in the runtime test file; 4353 passed, 21 skipped across assistants, core, frontend and api tests under Python 3.12; 246 passed in the Pyodide lane; ruff clean).
  • ERP image question displaced (suggestion): fixed. The CHANGELOG entry and the PR body now say the ERP image question moves from third to fourth and shows only when an earlier one does not fit. If hiding it is not intended, that is a maintainer call.
  • Stale "343-label" comment (suggestion): fixed. Reworded to "the earlier full table was about 9k".

The time-frequency slow-run warning (single processor, limited compute and memory) is unchanged and still pinned by its test.

@neuromechanist

Copy link
Copy Markdown
Member Author

Project manager verdict: not merging.

Unmet: the size criterion. band-power-topography is 16,757 and erp-topography 15,250 characters, against the required about 12,000 each, and the test cap is TOPOGRAPHY_SIZE_CAP = 17,000, not 12,500. This is the open maintainer decision already noted in the review rounds: either accept about 17k per topography document (record it in #721) or cut the shared blocks and relax the byte-pin tests to reach 12.5k.

Also, at the time of this check Test (3.11), Test (3.12) and Frontend Tests were still pending; Lint passes.

Met: the table rename and label coverage tests, the time-frequency warning tests (before the numbered steps), no lane figure added (measurement was not a browser figure), the prompt-size and document-size facts, the N170 re-measurement, and Refs #721 and Refs #719. Every review finding has an outcome in the round 1 and 2 comments.

…question stays among the first three

Many NEMAR datasets name channels in schemes the 10-10 table cannot place (EGI E1-E128,
BioSemi A1-D32), so a scalp map offered on every dataset page would often place no
electrodes. Test now pins the ERP image among the first three and no scalp-map template.

Tested: tests/test_assistants, tests/test_core/test_config, tests/test_scripts (1314 passed);
bun frontend/test-widget-dataset-questions.js (61 passed); ruff clean.
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