braindecode.augmentation.BandstopFilter

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

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
probabilityfloat

Float setting the probability of applying the operation.

bandwidthfloat

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

sfreqfloat, optional

Sampling frequency of the signals to be filtered. Defaults to 100 Hz.

max_freqfloat | 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_params(*batch)

Return transform parameters.

Parameters
Xtensor.Tensor

The data.

ytensor.Tensor

The labels.

Returns
paramsdict

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).

static operation(X, y, sfreq, bandwidth, freqs_to_notch)

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

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

Parameters
Xtorch.Tensor

EEG input example or batch.

ytorch.Tensor

EEG labels for the example or batch.

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).

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.