braindecode.modules.ChannelInterpolationLayer#

class braindecode.modules.ChannelInterpolationLayer(src_chs_info, tgt_chs_info, mode='always', method='spline', trainable=False)[source]#

Projects an input from one channel set to another via a fixed (or learnable) matrix.

Warning

Experimental. Public API may change without a deprecation cycle.

Parameters:
  • src_chs_info (list[dict]) – Source (user) channel info; each dict must have "ch_name" and "loc" keys (MNE-style).

  • tgt_chs_info (list[dict]) – Target channel info; same structure.

  • mode (Literal['always', 'name_match']) –

    How the matrix is built. Default "always".

    • "always": every row of W is computed via mne.io.Raw.interpolate_to() using the 3D positions.

    • "name_match": for each target channel whose ch_name (case-insensitive) also appears in src_chs_info, the corresponding row of W is a one-hot vector selecting that source channel (its 3D position is ignored). Remaining rows, if any, are filled via MNE. If every target name has a source match, MNE is not invoked and no "loc" is required.

  • method (str) – Forwarded to mne.Raw.interpolate_to method argument when an MNE-based matrix is needed. Default "spline".

  • trainable (bool) – If True the matrix is an nn.Parameter (stored in state_dict). If False it is a non-persistent buffer (recomputed from chs_info at every __init__).

Methods

forward(x)[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

Return type:

Tensor

Examples using braindecode.modules.ChannelInterpolationLayer#

Loading Pretrained Foundation Models on Arbitrary Channel Sets

Loading Pretrained Foundation Models on Arbitrary Channel Sets