MeanStdNormalize¶
- class torcheeg.transforms.MeanStdNormalize(mean: Optional[ndarray] = None, std: Optional[ndarray] = None, axis: Optional[int] = None, apply_to_baseline: bool = False)[source][source]¶
Perform z-score normalization on the input data. This class allows the user to define the dimension of normalization and the used statistic.
transform = MeanStdNormalize(axis=0) # normalize along the first dimension (electrode dimension) transform(eeg=np.random.randn(32, 128))['eeg'].shape >>> (32, 128) transform = MeanStdNormalize(axis=1) # normalize along the second dimension (temproal dimension) transform(eeg=np.random.randn(32, 128))['eeg'].shape >>> (32, 128)
- Parameters
mean (np.array, optional) – The mean used in the normalization process, allowing the user to provide mean statistics in
np.ndarrayformat. When statistics are not provided, use the statistics of the current sample for normalization.std (np.array, optional) – The standard deviation used in the normalization process, allowing the user to provide tandard deviation statistics in
np.ndarrayformat. When statistics are not provided, use the statistics of the current sample for normalization.axis (int, optional) – The dimension to normalize, when no dimension is specified, the entire data is normalized.
apply_to_baseline – (bool): Whether to act on the baseline signal at the same time, if the baseline is passed in when calling. (defualt:
False)
- __call__(*args, eeg: ndarray, baseline: Optional[ndarray] = None, **kwargs) Dict[str, ndarray][source][source]¶
- Parameters
eeg (np.ndarray) – The input EEG signals or features.
baseline (np.ndarray, optional) – The corresponding baseline signal, if apply_to_baseline is set to True and baseline is passed, the baseline signal will be transformed with the same way as the experimental signal.
- Returns
The normalized results.
- Return type
np.ndarray