braindecode.augmentation.MaskEncoding#

class braindecode.augmentation.MaskEncoding(probability, max_mask_ratio=0.1, n_segments=1, random_state=None)[source]#

MaskEncoding from [1].

Replaces randomly chosen contiguous part (or parts) of all channels by zeros (if more than one segment, it may overlap).

Implementation based on [1]

Parameters:
  • probability (float) – Float setting the probability of applying the operation.

  • max_mask_ratio (float, optional) – Signal ratio to zero out. Defaults to 0.1.

  • n_segments (int, optional) – Number of segments to zero out in each example. Defaults to 1.

  • random_state (int | numpy.random.Generator, optional) – Seed to be used to instantiate numpy random number generator instance. Defaults to None.

References

[1] (1,2)

Ding, Wenlong, et al. “A Novel Data Augmentation Approach Using Mask Encoding for Deep Learning-Based Asynchronous SSVEP-BCI.” IEEE Transactions on Neural Systems and Rehabilitation Engineering 32 (2024): 875-886.

Methods

get_augmentation_params(*batch)[source]#

Return transform parameters.

Parameters:
  • X (tensor.Tensor) – The data.

  • y (tensor.Tensor) – The labels.

Returns:

params – Contains …

Return type:

dict

static operation(X, y, time_start, segment_length, n_segments)[source]#

Mark encoding from Ding et al. (2024) from [ding2024].

Replaces a contiguous part (or parts) of all channels by zeros (if more than one segment, it may overlap).

Implementation based on [ding2024]

Parameters:
  • X (torch.Tensor) – EEG input example or batch.

  • y (torch.Tensor) – EEG labels for the example or batch.

  • time_start (torch.Tensor) – Tensor of integers containing the position (in last dimension) where to start masking the signal. Should have “n_segments” times the size of the first dimension of X (i.e. “n_segments” start positions per example in the batch).

  • segment_length (int) – Length of each segment to zero out.

  • n_segments (int) – Number of segments to zero out in each example.

Returns:

  • torch.Tensor – Transformed inputs.

  • torch.Tensor – Transformed labels.

References

[ding2024] (1,2)

Ding, Wenlong, et al. A Novel Data Augmentation Approach Using Mask Encoding for Deep Learning-Based Asynchronous SSVEP-BCI. IEEE Transactions on Neural Systems and Rehabilitation Engineering 32 (2024): 875-886.