SegRecTime#

class dpeeg.transforms.SegRecTime(samples: int, multiply: float = 1.0, only_train: bool = True, strict: bool = True, seed: int = 42)[source]#

Segmentation and reorganization in the time domain.

The S&R process involves segmenting the original eeg signals based on class along the temporal dimension, followed by randomly splicing them back [1]. By default, augmentation is performed on edata and label. Ensure the availability of the data.

Parameters:
  • samples (int) – The number of consecutive samples to segment the data. eg, 125 for 250Hz data is segmented by 0.5s.

  • multiply (float) – Data expansion multiple of relative metadata, 1 means doubled.

  • only_train (bool) – If True, data augmentation is performed only on the training set.

  • strict (bool) – If False, allow the input data to be unsplit. In this case, data augmentation will be applied to all data. Please ensure that this operation does not cause data leakage according to the method of data augmentation.

  • seed (int) – Seed to be used to instantiate numpy random number generator instance.

Returns:

data – Transformed eegdata.

Return type:

eegdata or dataset

References

Notes

Data augmentation is only applied to the edata and label within the eegdata, with other values remaining unchanged. If there are derived values based on the edata, attention should be paid to the order of transformations.

Examples

>>> eegdata = dpeeg.EEGData(edata=np.random.randn(16, 3, 10),
...                         label=np.random.randint(0, 3, 16))
>>> split_eegdata = dpeeg.SplitEEGData(eegdata.copy(), eegdata.copy())
>>> transforms.SegRecTime(2, 3)(split_eegdata, verbose=False)
Train: [edata=(64, 3, 10), label=(64,)]
Test : [edata=(16, 3, 10), label=(16,)]