Skip to content

Phase 2: channel count + electrode-system compute (#858) - #861

Merged
neuromechanist merged 1 commit into
feature/issue-854-epic-channel-montagefrom
feature/issue-858-phase2-compute
Jun 28, 2026
Merged

neuromechanist merged 1 commit into
feature/issue-854-epic-channel-montagefrom
feature/issue-858-phase2-compute

Conversation

@neuromechanist

Copy link
Copy Markdown
Contributor

Summary

Populates the Phase 1 columns (n_channels, electrode_system) during enrichment.

  • channel-montage.ts (pure, unit-tested) — parseChannelsTsv, parseEegChannelCount,
    resolveNChannels (the measured channels.tsv EEG count wins over a disagreeing EEGChannelCount
    sidecar, per the data-source decision), and classifyElectrodeSystem
    (egi-geodesic / biosemi / 10-20 / 10-10 / 10-05 / other). Tier detection is grounded in
    MNE-derived label sets (montage-label-sets.ts, auto-generated): BioSemi A-bank and EGI pure-E
    numbering are matched first (their labels overlap the standard set), then the finest standard tier present.
  • getBidsTreeStats captures an exemplar EEG *_channels.tsv + *_eeg.json from the subjects it
    already walks and runs the classifiers in a best-effort probe (probeChannelMontage): any failure
    (annex pointer, fetch error, parse miss) leaves the columns NULL and never disturbs the existing
    modality/subject/task walk.
  • writeDatasetMetadataColumns COALESCE-writes the two new columns; the reindex caller threads them
    through computeDatasetMetadataColumns.

EEG-only for now (channel count + scalp montage are EEG concepts). Populated via the reindex/walk path;
the LLM-enrich path omits them (COALESCE-safe — it has the tree but not file content). Backfill of the
existing ~646 rows is Phase 3 (#859).

Testing

  • test/channel-montage.unit.test.ts — 18 tests with real-shape inputs: HBN E1..E128+Cz → egi-geodesic/129;
    BioSemi A1..D32 → biosemi; classic + legacy-T3/T4 → 10-20; intermediate → 10-10; fine/h-suffixed → 10-05;
    measured-wins-on-disagreement; pointer/garbled → null.
  • root + backend tsc --noEmit green; metadata-columns + reindex suites unchanged.
  • D1 end-to-end verified post-deploy via api-test / a reindex of nm099999 (no-mock D1 policy).

Regenerating the label sets

import mne
mne.channels.make_standard_montage("standard_1020").ch_names  # 10-10 superset (94)
mne.channels.make_standard_montage("standard_1005").ch_names  # 10-05 finest (343)

Closes #858. Part of epic #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.
@github-actions

Copy link
Copy Markdown

📦 Package Preview

Your package is ready to test!

bun install -g nemar-cli@PR861

Version: 0.8.71-PR861.ffecc2f
Commit: ffecc2f


🤖 Updated on each push.

@neuromechanist
neuromechanist merged commit 2152018 into feature/issue-854-epic-channel-montage Jun 28, 2026
1 check passed
@neuromechanist
neuromechanist deleted the feature/issue-858-phase2-compute branch June 28, 2026 21:16

This branch was previously deployed

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