Transforms#
This is used to transform the data within dpeeg. The transformation is applied
to the data using the __call__ function, supporting input data types of
EEG Data and EEG Dataset.
Usage can be referenced from the following examples:
- Transforms.__call__(eegdata: BaseData, verbose=None)[source]#
- Transforms.__call__(eegdata: BaseDataset, iter: Literal[False] = False, verbose=None)
- Transforms.__call__(eegdata: BaseDataset, iter: Literal[True] = True, verbose=None)
Apply data transformation to eegdata or eegdataset.
- Parameters:
eegdata (EEG Data, EEG Dataset) – Apply data transformation to eegdata or eegdataset.
iter (bool) – Valid when the input type is eegdataset.
Falsemeans directly returning the entire transformed dataset,Truemeans iteratively returning the transformed data of each subject.
Examples
Allows transformation of data of type eegdata:
>>> eegdata = dpeeg.EEGData(edata=np.random.randn(16, 3, 10), ... label=np.random.randint(0, 3, 16)) >>> transforms.Unsqueeze()(eegdata, verbose=False) [edata=(16, 1, 3, 10), label=(16,)]
Also allows input type eegdataset:
>>> eegdataset = dpeeg.datasets.EEGDataset([ ... eegdata.copy(), eegdata.copy(), eegdata.copy() ... ]) >>> transforms.Squeeze()(eegdataset, iter=False, verbose=False) [EEGDataset: [eegdataset]: Subjects=3, type=EEGData [event_id]: None ]
setting iter can iteratively obtain the eegdata of each subject after transformation:
>>> tran = transforms.Unsqueeze() >>> for subject, eegdata in tran(eegdataset, iter=True, verbose=False): ... print(subject, eegdata) 0 [edata=(16, 1, 3, 10), label=(16,)] 1 [edata=(16, 1, 3, 10), label=(16,)] 2 [edata=(16, 1, 3, 10), label=(16,)]
Important
When the input type is EEG Dataset, the transformation will be
applied to all subject data within the dataset. By default, all subject
data will be read into memory for processing and returned. The
transformation can be made subject-wise by specifying the iter
parameter to save memory overhead.
Core#
A sequential container. |
|
Split the data into training and testing sets. |
|
Convert different types of eegdata to |
|
Split the dataset by subjects. |
Commonly#
Placeholder identity operator. |
|
Crop a time interval. |
|
Apply a sliding window to the dataset. |
|
Insert a dimension on the data. |
|
Remove a dimension on the data. |
|
Data dims transposed. |
|
Filter Bank. |
|
Apply a custom function to data. |
|
Update the original label according to mapping rules. |
|
Pick a subset of data. |
Normalization#
Z-score normalization per subject. |
|
Min-max normalization per subject. |
Data Augmentation#
Segmentation and reorganization in the time domain. |
|
Sliding window data augmentation. |
|
Randomly add white noise to all channels. |