Repository navigation
Give NEMAR's prompt the ERP low-pass as code - #485
Merged
Merged
Conversation
In a staging run on test.nemar.org/dataset/xx099906 the model wrote np.sinc(n) * np.hamming(taps) from the prose, which is a single spike: its gain at 50 Hz is 1.0, so every ERP image it drew was unfiltered. The prompt now carries the kernel as a python block with the cutoff (np.sinc(2 * 30 / rate * n)), puts the ERP image's time axis in milliseconds, and asks for deflections with latency and size before naming a component. test-data-lane.js runs that block as the prompt writes it in real Pyodide: 101 taps at 250 Hz, gain 1.000 at 5 Hz and 0.0007 at 50 Hz, and a 5 Hz plus 50 Hz sine comes out as the 5 Hz sine. Tested: bun frontend/test-data-lane.js 66/66; mutated the prompt to np.sinc(n), 2 checks fail; pytest test_nemar_runtime, test_nemar_mcp_wiring, test_core 616 passed; ruff clean.
Tested: docs-only.
Contributor
Preview Deployment
This preview will be updated automatically when you push new commits. |
Review of #485: at 60 Hz the 30 Hz cutoff reaches the Nyquist frequency and the kernel is a spike again, and at 5000 Hz np.convolve with 2001 taps is too slow for a browser. The prompt's filter clamps the cutoff to rate / 4 and convolves by FFT, which equals np.convolve(x, kernel, "same") and takes a channels-by-samples array. The test runs the block at 60, 125, 250, 1000 and 5000 Hz, compares it with np.convolve and row by row, and requires the block to follow the ERP bullet's opening lines. Tested: bun frontend/test-data-lane.js 93/93; mutations (no clamp, np.sinc(k), slice off by one) fail 2, 6+ and 6+ checks; pytest nemar runtime and wiring pass.
Member
Author
Review responseOne Sonnet review, no blocking findings. Every point is addressed in 5311f56.
Mutations, each run against the whole suite and restored: no clamp fails 2 checks;
|
3 tasks done
neuromechanist
added a commit
that referenced
this pull request
Sep 24, 2026
tests/test_tools/test_hed_validation.py calls hedtools.org in every test but only one class carried a marker (integration), so the unit jobs ran the rest and a slow response failed unrelated PRs: #484 (read operation timed out) and #485 (two validations returned False) on 2026-09-24. A module-level pytestmark = pytest.mark.network leaves them to test.yml's network job, which is continue-on-error. Tested: -m 'not integration and not llm and not network' deselects all 11; -m network runs all 11, passing against hedtools.org; ruff check and format clean.
This was referenced Sep 24, 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.
Found in the staging test on test.nemar.org/dataset/xx099906 (develop, 0.8.14.dev16), asking for "an ERP image of sub-01's SiB recording, one panel per condition".
What went wrong
The whole path worked:
nemar_get_eventswithlimit: 1, thencolumns, the event indices written into the code, reads from zarr-test, six code runs in one reply, and a four-condition figure. But the averages were dominated by high-frequency ripple, because the model wrote the prompt's windowed-sinc low-pass asnp.sincof whole numbers is zero everywhere but the center, so that kernel is a single spike: its gain at 50 Hz is 1.0, and nothing was filtered. The prompt said "np.sinctimesnp.hamming" and left the argument to the model. The figure also had its time axis in samples, and the reply called the result "P300-like" on averages that do not support it.The change
np.sinc(2 * 30 / rate * n)) and one sentence saying what happens without it.extentfrom -200 to 800).Test
frontend/test-data-lane.jstakes the python block out of the prompt's ERP section and runs it, as written, in real Pyodide at 250 Hz: 101 taps, gain 1.000 at 5 Hz and 0.0007 at 50 Hz, and a 5 Hz plus 50 Hz sine comes out as the 5 Hz sine to within 0.0007, unshifted.Mutation: replacing the prompt's kernel line with
np.sinc(n) * np.hamming(taps), the model's version, fails two checks (gain 1.0 at 50 Hz; residual 0.95).bun frontend/test-data-lane.js: 66 passedpytest tests/test_assistants/test_nemar_runtime.py tests/test_assistants/test_nemar_mcp_wiring.py tests/test_core: 616 passedruff check .Ships in 0.8.14 with the rest of the ERP work (#483).