Skip to content

feat: iEEG per-channel activity metrics (IS-M1) - #546

Merged
neuromechanist merged 3 commits into
feature/issue-537-epic-spatialfrom
feat/is-m1-metrics
Nov 17, 2026
Merged

neuromechanist merged 3 commits into
feature/issue-537-epic-spatialfrom
feat/is-m1-metrics

Conversation

@neuromechanist

@neuromechanist neuromechanist commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

What changed

Card IS-M1 of the iEEG spatial view plan: a pure module that turns the level-0 samples of the visible window into one value per channel for rms, line_length or band_power (delta, theta, alpha, beta, low gamma, high gamma), with its unit, and maps values to colors on a stated scale.

  • src/lib/ieeg-spatial/activity.ts: Welch band power (Hann, 1 s segment rounded to a power of two, 50 percent overlap, mean removed per segment, radix-2 FFT in the module, no new dependency); refusals band_above_nyquist (upper edge above 0.45 times the rate, also per channel against its own native rate), window_too_short, not_level0 (a view-level window is a min/max envelope, never samples), bad_input (including a display unit of another dimension and a stored unit the store did not convert to SI); analyzedSamples and analyzedS say what band power really describes; one non-finite sample anywhere in the window nulls the channel for every metric; sequential (2nd to 98th percentile of located channels, viridis) and zscore (symmetric limits, diverging map declared once) scales with numeric limits for the colorbar.
  • src/lib/ieeg-spatial/activity.test.ts: 21 tests.
  • test/fixtures/ieeg-activity/: one real level-0 slice (on006136 v1.0.0, sub-P5, 14 channels, 2 s, 1000 Hz, volts as readLevel0 returns it), SOURCES.json, reference.json computed independently with scipy.signal.welch and NumPy, and the small reference.py that produced it.

Deviations from the card (accepted)

  • rms is mean-removed (the window's population standard deviation), consistent with the viewer's DC removal and the per-segment mean removal in Welch.
  • "Shorter than two segments" means fewer than two Welch segments at 50 percent overlap (1536 samples at 1000 Hz); the literal 2 x 1024 would refuse the card's own 2000-sample fixture.
  • Sequential limits are the 2nd and 98th percentiles of the located values; zscore limits are plus and minus the 98th percentile of |z| (population standard deviation).
  • The relative form is decibels against the channel's own power from 1 Hz to the lesser of 150 Hz and 0.45 times the rate.
  • The Nyquist mutation in the card would not fail a 250 Hz test alone, so a 300 Hz case (refused at 0.45, allowed at full Nyquist) was added.
  • Additions: activityChannelsFromWindow, displayUnit conversion within one dimension, per-channel nativeRateHz, reference.py inside the fixture directory.

Gates

  • bun run test src/lib/ieeg-spatial: 21 passed
  • bun run test: 176 files passed, 4986 tests passed, 14 skipped
  • bun run lint: no fixes applied
  • bun run typecheck: 0 errors
  • Each guarded line was mutated and the named test failed, then reverted (tree clean).
  • Leak check on every written file: nothing printed.

Not run

  • CI jobs: not run, would check every job green on the final head, because the manager reads gh pr checks.

Card: IS-M1. Part of #537

@cloudflare-workers-and-pages

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

Copy link
Copy Markdown

Deploying nemar-website with  Cloudflare Pages  Cloudflare Pages

Latest commit: b6dd2a7
Status: ✅  Deploy successful!
Preview URL: https://15347501.nemar-website.pages.dev
Branch Preview URL: https://feat-is-m1-metrics.nemar-website.pages.dev

View logs

@neuromechanist
neuromechanist merged commit 366e4d4 into feature/issue-537-epic-spatial Nov 17, 2026
11 of 13 checks passed
@neuromechanist
neuromechanist deleted the feat/is-m1-metrics branch November 17, 2026 23:52
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