cogpy.plot.hv.channel_grid
channel_grid.py
Grid-layout-aware channel selection primitive.
Works entirely in integer grid indices (0..N-1 for both AP and ML).
Physical coordinate mapping is the caller’s responsibility — use
normalize_coords_to_index before constructing a ChannelGrid.
Modes
row : all channels in one AP row column : all channels in one ML column sparse : strided subgrid covering the full extent (stride + offset) neighborhood : filled square (Chebyshev) around a center electrode manual : explicit toggle of individual cells
Usage
from channel_grid import ChannelGrid
grid = ChannelGrid(n_ap=16, n_ml=16)
grid.select_row(3) grid.select_column(7) grid.select_sparse(stride=2) # 8×8 covering full 16×16 grid.select_sparse(stride=4, offset=1) # offset phase grid.select_neighborhood(ap=8, ml=8, radius=2) grid.select_manual({(0,0), (1,1)})
# Watch output grid.param.watch(lambda e: print(e.new), “selected”)
# Downstream use grid.selected # frozenset of (ap, ml) int tuples grid.flat_indices # list[int] into row-major (n_ap*n_ml,) flat array grid.as_array # bool ndarray (n_ap, n_ml) grid.n_selected # int
Classes
|
Grid-layout-aware channel selection primitive. |