Skip to content

Epic #854: catalog channel count + electrode-system classification - #863

Merged
neuromechanist merged 6 commits into
devfrom
feature/issue-854-epic-channel-montage
Jun 28, 2026
Merged

neuromechanist merged 6 commits into
devfrom
feature/issue-854-epic-channel-montage

Conversation

@neuromechanist

Copy link
Copy Markdown
Contributor

Summary

Adds a per-dataset channel count + electrode-system class to the catalog so the website can filter/identify high-density and special-system (EGI geodesic, BioSemi) EEG datasets. Additive throughout — no existing column/alias/contract changes.

Phases (all merged to this epic branch)

  1. Phase 1: channel/montage schema + projection (#854) #857 — migration 0054 (n_channels, electrode_system) + list/detail projection. Columns ship NULL.
  2. Phase 2: channel/montage enrichment compute (#854) #858 — compute during enrichment: channel-montage.ts classifier (egi-geodesic/biosemi/10-20/10-10/10-05/other, MNE-grounded label sets; n_channels from EEGChannelCount cross-checked against a measured channels.tsv), wired into getBidsTreeStats (best-effort exemplar probe) + writeDatasetMetadataColumns.
  3. Phase 3: channel/montage backfill of existing datasets (#854) #859 — migration 0055 (channel_montage_checked_at) + POST /admin/datasets/channel-montage-sweep one-time backfill (writes the two columns directly, no updated_at bump) + driver script.

Deploy / backfill

Migrations 0054/0055 apply on deploy (dev D1 on this merge; prod D1 on the eventual dev→main). After deploy, run scripts/backfill-channel-montage.sh against dev to validate, then prod to populate the public catalog. Going-forward datasets populate via the reindex/enrichment walk.

The website's guarded Channels & montage filter (already built) lights up once these columns populate.

Testing

  • 22 new unit tests (classifier 18 + sweep 4), real-shape inputs / real migrations against SQLite, no mocks.
  • root + backend tsc --noEmit green across all phases; existing datasets/metadata suites unchanged.
  • D1 end-to-end verified post-deploy via api-test (no-mock D1 policy).

Closes #854. Closes #857, #858, #859.

Phase 1 of epic #854. Additive only:
- migration 0054 adds n_channels (INTEGER) + electrode_system (TEXT)
  to datasets, with indexes for filterability.
- expose both in the public list + ?mine list SELECTs. The detail
  endpoint already returns them via SELECT d.*.

Values stay NULL until phase 2 (#858) computes them and phase 3
(#859) backfills; the website channel/montage filter reads NULL as
"not classified yet". No existing column or alias changes, so no
contract regression.

Closes #857. Part of #854.
Phase 2 of epic #854. Populate the migration-0054 columns during
enrichment:

- channel-montage.ts (pure, unit-tested): parseChannelsTsv,
  parseEegChannelCount, resolveNChannels (measured channels.tsv EEG
  count wins over a disagreeing sidecar), classifyElectrodeSystem
  (egi-geodesic / biosemi / 10-20 / 10-10 / 10-05 / other), grounded
  in MNE-derived label sets (montage-label-sets.ts).
- getBidsTreeStats samples an exemplar eeg channels.tsv + eeg.json
  from the subjects it already walks and runs the classifiers
  (best-effort: a probe failure leaves the columns NULL, never
  breaks the modality/subject walk).
- writeDatasetMetadataColumns COALESCE-writes n_channels +
  electrode_system; the reindex caller threads them through.

EEG-only for now; populated via the reindex/walk path (the
LLM-enrich path omits them, COALESCE-safe). Backfill of existing
rows is phase 3 (#859).

Closes #858. Part of #854.
Phase 1: channel/montage schema + projection (#857)
Phase 2: channel count + electrode-system compute (#858)
Phase 3 of epic #854. One-time backfill for the columns added in
phase 1/2 across existing EEG datasets:

- migration 0055 adds channel_montage_checked_at (resumability
  marker, mirrors archive_checked_at).
- POST /admin/datasets/channel-montage-sweep?limit=N: candidates are
  repo-backed (nm*/on*), EEG, non-sandbox, unchecked rows. Runs the
  phase-2 getBidsTreeStats probe and writes n_channels +
  electrode_system DIRECTLY (no updated_at bump, so the backfill
  doesn't re-sort every EEG dataset to "newest"). Idempotent;
  bounded per call (<=30) under the Worker subrequest cap.
- scripts/backfill-channel-montage.sh drives it until remaining=0.

Real-SQLite test applies migrations 0054+0055 and pins the candidate
scoping + the no-updated_at-bump write.

Closes #859. Part of #854.
@github-actions

Copy link
Copy Markdown

📦 Package Preview

Your package is ready to test!

bun install -g nemar-cli@PR863

Version: 0.8.71-PR863.0b70fc3
Commit: 0b70fc3


🤖 Updated on each push.

@neuromechanist
neuromechanist merged commit 0742e97 into dev Jun 28, 2026
10 checks passed
@neuromechanist
neuromechanist deleted the feature/issue-854-epic-channel-montage branch June 28, 2026 21:50

This branch was previously deployed

1 inactive deployment
npm — 0b70fc33 Deployed Jun 28, 2026 by neuromechanist via publish #1614
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