braindecode.modules.ChannelLayer#

class braindecode.modules.ChannelLayer(target, strategy, chs_info=None, *, drop_non_eeg=False, trainable=False, **kwargs)[source]#

Map any montage onto target with one matrix per montage.

Warning

Experimental. Public API may change without a deprecation cycle.

Parameters:
  • target (list of dict) – Channels the backbone consumes (ch_name, optional loc).

  • strategy (str) – "exact" (a missing target is an error), "zero", "nearest", "idw" (p), "spline" (reg=1e-3), "field" (reg=0) or "source" (n_parcels=64, lam=0.1, grid_mm=15, trainable: a zero-initialised parcel mixing on top of the physics). "wiener" (noise=0.01; call fit() first), "region" (mean within radius, default 1.5 x the median input spacing) or "latent" (d_model=64, n_freqs=8: learned cross-attention from each missing target’s position over the inputs’ positions and statistics).

  • chs_info (list of dict, optional) – Montage used when forward() gets none.

  • drop_non_eeg (bool) – Ignore input channels that are not electrodes instead of raising.

Methods

fit(X, chs_info_dense)[source]#

wiener: fit the spatial covariance on X (n_samples, n_dense) recorded with chs_info_dense (matched to the montages by position).

Return type:

ChannelLayer

forward(x, chs_info=None)[source]#

Map x (B, C, T) recorded with chs_info; return (x, observed).

Return type:

tuple[Tensor, Tensor]

Examples using braindecode.modules.ChannelLayer#

Running a Pretrained Model on Any Channel Set with the Channel Layer

Running a Pretrained Model on Any Channel Set with the Channel Layer