braindecode.modules.ChannelLayer#
- class braindecode.modules.ChannelLayer(target, strategy, chs_info=None, *, drop_non_eeg=False, trainable=False, reference=None, **kwargs)[source]#
Map any montage onto
targetwith 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, optionalloc).strategy (str or callable) –
"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; callfit()first),"region"(mean withinradius, 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). A callablekernel(pos_a, pos_b) -> (n_a, n_b)covariance of the potentials at two sets of positions (metres, from the centre of the sphere fitted to the inputs, as"spline"), e.g.spherical_spline_kernel(), fills them withlinear_channel_map()(reg: the noise variance, default 1e-3; the recording reference is left unknown).splineandwienerare that estimate with their own covariance;match_gain=Truegives each reconstructed target its prior variance.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.
reference (str, optional) – Reference of the backbone’s single-electrode targets:
None(the input’s), an electrode name ("Cz": targetAisV(A) - V(Cz), withCzcopied or reconstructed like any target) or"average"(minus their mean). Bipolar targets need none.
- variance#
Posterior variance of each target for the current montage: 0 when measured or exact, from the estimate (before
match_gain) for a single-electrode target ofspline,wieneror a kernel,nanwhen not computed (other strategies, or a target mixing several reconstructed channels, as withreference="average").- Type:
Notes
forwardalso takes one montage per sample (chs_infoa list of montages,xpadded to the largest andch_maskthe real channels), for the strategies without trained state (notlatentortrainable);observedis then(batch, n_targets)and the buffers (weight,variance) are those of the last sample. A model with achannel_strategybuilds these montages from theposandch_maskofpad_channels_collate(). A function strategy is not saved bysave_pretrained: pass it again when loading.Methods
Examples using braindecode.modules.ChannelLayer#
Running a Pretrained Model on Any Channel Set with the Channel Layer