braindecode.augmentation.SegmentationReconstruction#

class braindecode.augmentation.SegmentationReconstruction(probability, n_segments=None, random_state=None)[source]#

Segmentation Reconstruction from Lotte (2015) [Lotte2015].

Applies a segmentation-reconstruction transform to the input data, as proposed in [Lotte2015]. It segments each trial in the batch and randomly mix it to generate new synthetic trials by label, preserving the original order of the segments in time domain.

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

  • random_state (int | numpy.random.Generator, optional) – Seed to be used to instantiate numpy random number generator instance. Used to decide whether to transform given the probability argument and to sample the segments mixing. Defaults to None.

  • n_segments (int, optional) – Number of segments to use in the batch. If None, X will be automatically segmented, getting the last element in a list of factors of the number of samples’s square root. Defaults to None.

References

[Lotte2015] (1,2)

Lotte, F. (2015). Signal processing approaches to minimize or suppress calibration time in oscillatory activity-based brain–computer interfaces. Proceedings of the IEEE, 103(6), 871-890.

Methods

get_augmentation_params(*batch)[source]#

Return transform parameters.

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

  • y (tensor.Tensor) – The labels.

Returns:

params – Contains the number of segments to split the signal into.

Return type:

dict

static operation(X, y, n_segments, data_classes, rand_indices, idx_shuffle)[source]#

Segment and reconstruct EEG data from [1].

See [1] for details.

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

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

  • n_segments (int) – Number of segments to use in the batch.

  • rand_indices (array-like) – Array of indices that indicates which trial to use in each segment.

  • idx_shuffle (array-like) – Array of indices to shuffle the new generated trials.

Returns:

  • torch.Tensor – Transformed inputs.

  • torch.Tensor – Transformed labels.

References

[1] (1,2)

Lotte, F. (2015). Signal processing approaches to minimize or suppress calibration time in oscillatory activity-based brain–computer interfaces. Proceedings of the IEEE, 103(6), 871-890.