braindecode.augmentation.BandstopFilter#

class braindecode.augmentation.BandstopFilter(probability, sfreq, bandwidth=1, max_freq=None, random_state=None)[source]#

Apply a band-stop filter with desired bandwidth at a randomly selected frequency position between 0 and max_freq.

Suggested e.g. in [1] and [2]

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

  • bandwidth (float) – Bandwidth of the filter, i.e. distance between the low and high cut frequencies.

  • sfreq (float, optional) – Sampling frequency of the signals to be filtered. Defaults to 100 Hz.

  • max_freq (float | None, optional) – Maximal admissible frequency. The low cut frequency will be sampled so that the corresponding high cut frequency + transition (=1Hz) are below max_freq. If omitted or None, will default to the Nyquist frequency (sfreq / 2).

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

References

[1]

Cheng, J. Y., Goh, H., Dogrusoz, K., Tuzel, O., & Azemi, E. (2020). Subject-aware contrastive learning for biosignals. arXiv preprint arXiv:2007.04871.

[2]

Mohsenvand, M. N., Izadi, M. R., & Maes, P. (2020). Contrastive Representation Learning for Electroencephalogram Classification. In Machine Learning for Health (pp. 238-253). PMLR.

Methods

get_augmentation_params(*batch)[source]#

Return transform parameters.

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

  • y (tensor.Tensor) – The labels.

Returns:

params – Contains

  • sfreqfloat

    Sampling frequency of the signals to be filtered.

  • bandwidthfloat

    Bandwidth of the filter, i.e. distance between the low and high cut frequencies.

  • freqs_to_notcharray-like | None

    Array of floats of size (batch_size,) containing the center of the frequency band to filter out for each sample in the batch. Frequencies should be greater than bandwidth/2 + transition and lower than sfreq/2 - bandwidth/2 - transition (where transition = 1 Hz).

Return type:

dict

static operation(X, y, sfreq, bandwidth, freqs_to_notch)[source]#

Apply a band-stop filter with desired bandwidth at the desired frequency position.

Suggested e.g. in [1] and [2]

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

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

  • sfreq (float) – Sampling frequency of the signals to be filtered.

  • bandwidth (float) – Bandwidth of the filter, i.e. distance between the low and high cut frequencies.

  • freqs_to_notch (array-like | None) – Array of floats of size (batch_size,) containing the center of the frequency band to filter out for each sample in the batch. Frequencies should be greater than bandwidth/2 + transition and lower than sfreq/2 - bandwidth/2 - transition (where transition = 1 Hz).

Returns:

  • torch.Tensor – Transformed inputs.

  • torch.Tensor – Transformed labels.

References

[1]

Cheng, J. Y., Goh, H., Dogrusoz, K., Tuzel, O., & Azemi, E. (2020). Subject-aware contrastive learning for biosignals. arXiv preprint arXiv:2007.04871.

[2]

Mohsenvand, M. N., Izadi, M. R., & Maes, P. (2020). Contrastive Representation Learning for Electroencephalogram Classification. In Machine Learning for Health (pp. 238-253). PMLR.