Add an 'array' field to the channel-map ch axis - #34
Merged
Conversation
Groups channels by physical electrode array rather than by 32-channel
connector bank, which is the grouping wanted for per-array rereferencing
(LRR/CAR): a bank is a wiring artifact, the array is the implant.
Two channels share an array iff they share a connector -- the label prefix
before the first '-', which the CMP assigns per 64-channel connector
('elec1' in 'elec1-m1-63') -- on the same headstage. The headstage prefix
keeps two identically labelled arrays distinct (the same .cmp loaded twice,
or a bilateral implant). This matches intent-pipelines' offline convention
(_array_ids_from_metadata), so weights fitted offline cluster the same way
when applied live.
Labels with no connector structure (chan1, or an auto-grid channel with no
label) fall back to the connector bank, so grouping by 'array' degrades to
bank-level grouping instead of collapsing the device into one cluster.
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.
Summary
Adds an
arrayfield to the structuredchaxis, so channels can be grouped by physical electrode array rather than by 32-channel connector bank. This is the grouping wanted for per-array rereferencing (LRR/CAR): a bank is a wiring artifact, the array is the implant.Two channels share an array iff they share a connector — the label prefix before the first
-, which the CMP assigns per 64-channel connector (elec1inelec1-m1-63) — on the same headstage.Why the headstage prefix
The connector label repeats across headstages. Without the prefix, the same
.cmploaded twice (a 256-ch device built from two 128-ch maps) or a bilateral implant would merge two physically distinct arrays into one cluster.Why the connector, not the whole label stem
The region token (
m1,aip) annotates where an array was implanted; a connector whose channels carry inconsistent region labels is still one array. Grouping on the connector also matches the convention already used offline in intent-pipelines (_array_ids_from_metadata), so weights fitted offline cluster the same way when applied live — verified directly on a real 256-ch Hub1 layout (two CMPs, two headstages): both produce an identical partition of 4 arrays x 64 channels.Fallback
Labels with no connector structure (
chan1, or an auto-grid channel with no label) fall back to the connector bank, e.g.("chan1", hs=1, bank="A")->"hs1-bankA". Without this, grouping byarraywould collapse every such channel into a single cluster spanning the whole device. This repo's own test CMP (128ChannelDefaultMapping.cmp) useschan<N>labels and exercises the fallback.Populated in three places
entry.label+entry.headstage(+ bank for the fallback)arrayjoins the copied fields when presentCereLinkSignalSource._build_ch_infoalso fills it, so a device that read its map from chaninfo carries the field too.Tests
Five new tests in
tests/test_channel_map.pycovering identity derivation, CMP population, array-vs-bank group sizes, the two-headstage disambiguation, and the auto-grid fallback. Full suite: 110 passed, 1 skipped.