braindecode.samplers.RelativePositioningSampler

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

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
metadatapd.DataFrame

See RecordingSampler.

tau_posint

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_negint

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_examplesint

Number of pairs to extract.

tau_maxint | None

See tau_neg.

same_rec_negbool

If True, sample negative pairs from within the same recording. If False, sample negative pairs from two different recordings.

random_stateNone | 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()

Presample examples.

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

Examples using braindecode.samplers.RelativePositioningSampler