braindecode.functional.pack_channels#

braindecode.functional.pack_channels(x, ch_mask=None)[source]#

Merge the batch and channel axes and drop the padded channels.

For a stage that encodes each channel on its own, so that no compute is spent on padding. unpack_channels() puts the channels back.

Parameters:
  • x (Tensor) – Tensor of shape (batch, n_chans, ...).

  • ch_mask (Optional[Tensor]) – Boolean mask of shape (batch, n_chans), True for real channels. None keeps every channel.

Returns:

Shape (n_real, ...): the real channels, sample by sample, in the order of the input ((batch * n_chans, ...) without ch_mask).

Return type:

Tensor