- class braindecode.samplers.BalancedSequenceSampler(metadata, n_windows, n_sequences=10, random_state=None)¶
Balanced sampling of sequences of consecutive windows with categorical targets.
Balanced sampling of sequences inspired by the approach of [Perslev2021]: 1. Uniformly sample a recording out of the available ones. 2. Uniformly sample one of the classes. 3. Sample a window of the corresponding class in the selected recording. 4. Extract a sequence of windows around the sampled window.
See RecordingSampler. Must contain a column target with categorical targets.
Number of consecutive windows in a sequence.
Number of sequences to sample.
- random_statenp.random.RandomState | int | None
Perslev M, Darkner S, Kempfner L, Nikolic M, Jennum PJ, Igel C. U-Sleep: resilient high-frequency sleep staging. npj Digit. Med. 4, 72 (2021). https://github.com/perslev/U-Time/blob/master/utime/models/usleep.py
Return a random class.
- rec_indint | None
Index to the recording to sample from. If None, the recording will be uniformly sampled across available recordings.
Index to the recording the class was sampled from.