braindecode.samplers.RelativePositioningSampler#

class braindecode.samplers.RelativePositioningSampler(metadata, tau_pos, tau_neg, n_examples, tau_max=None, same_rec_neg=True, random_state=None)[source]#

Sample examples for the relative positioning task from [Banville2020].

Sample examples as tuples of two window indices, with a label indicating whether the windows are close or far, as defined by tau_pos and tau_neg.

Parameters
  • metadata (pd.DataFrame) – See RecordingSampler.

  • tau_pos (int) – Size of the positive context, in samples. A positive pair contains two windows x1 and x2 which are separated by at most tau_pos samples.

  • tau_neg (int) – Size of the negative context, in samples. A negative pair contains two windows x1 and x2 which are separated by at least tau_neg samples and at most tau_max samples. Ignored if same_rec_neg is False.

  • n_examples (int) – Number of pairs to extract.

  • tau_max (int | None) – See tau_neg.

  • same_rec_neg (bool) – If True, sample negative pairs from within the same recording. If False, sample negative pairs from two different recordings.

  • random_state (None | np.RandomState | int) – Random state.

References

Banville2020

Banville, H., Chehab, O., Hyvärinen, A., Engemann, D. A., & Gramfort, A. (2020). Uncovering the structure of clinical EEG signals with self-supervised learning. arXiv preprint arXiv:2007.16104.

Methods

presample()[source]#

Presample examples.

Once presampled, the examples are the same from one epoch to another.

Examples using braindecode.samplers.RelativePositioningSampler#

Self-supervised learning on EEG with relative positioning

Self-supervised learning on EEG with relative positioning

Self-supervised learning on EEG with relative positioning