cogpy.plot.hv.channel_grid_widget

channel_grid_widget.py

Panel widget wrapping ChannelGrid with an interactive Bokeh grid display.

Fixes vs previous version

  • Manual selection now sticks: uses source.patch() instead of replacing source.data wholesale (which was resetting Bokeh’s selection state and causing the toggle to fight itself).

  • Sparse mode replaces the old subgrid mode.

  • Optional atlas background image support (modes: “crop” or “full”).

Usage

import panel as pn from channel_grid import ChannelGrid from channel_grid_widget import ChannelGridWidget

pn.extension()

w = ChannelGridWidget(n_ap=16, n_ml=16) w.panel().servable()

# With signal background (per-electrode scalar, e.g. RMS) rms = sig.std(dim=”time”).transpose(“AP”, “ML”).values # (n_ap, n_ml) w = ChannelGridWidget(n_ap=16, n_ml=16, cell_values=rms)

# With atlas image import numpy as np atlas_img = np.array(…) # (H, W, 3) or (H, W, 4) uint8 w = ChannelGridWidget(

n_ap=16, n_ml=16, ap_coords=np.linspace(-4, 1, 16), # physical mm, bregma-relative ml_coords=np.linspace(-4, 4, 16), atlas_image=atlas_img, atlas_mode=”crop”, # or “full” bl_distance=7.5, # bregma-lambda distance in mm, default scale

)

Classes

ChannelGridWidget([n_ap, n_ml, cell_size, ...])

Interactive Panel widget wrapping a ChannelGrid.