RandomPCANoise¶
- class torcheeg.transforms.RandomPCANoise(mean: float = 0.0, std: float = 1.0, n_components: int = 2, series_dim: int = -1, p: float = 0.5, apply_to_baseline: bool = False)[source][source]¶
Add noise with a given probability, where the noise is added to the principal components of each channel of the EEG signal. In particular, the noise added by each channel is different.
transform = RandomPCANoise() transform(eeg=torch.randn(32, 128))['eeg'].shape >>> (32, 128) transform = RandomPCANoise(mean=0.5, std=2.0, n_components=4) transform(eeg=torch.randn(1, 32, 128))['eeg'].shape >>> (1, 32, 128) transform = RandomPCANoise(p=1.0, series_dim=0) transform(eeg=torch.randn(128, 9, 9))['eeg'].shape >>> (128, 9, 9)
- Parameters:
mean (float) – The mean of the normal distribution of noise. (default:
0.0
)std (float) – The standard deviation of the normal distribution of noise. (default:
0.0
)series_dim (int) – Dimension of the time series in the input tensor. (default:
-1
)n_components (int) – Number of components to add noise. if n_components is not set, the first two components are used to add noise.
p (float) – Probability of applying random mask on EEG signal samples. Should be between 0.0 and 1.0, where 0.0 means no mask is applied to every sample and 1.0 means that masks are applied to every sample. (default:
0.5
)apply_to_baseline – (bool): Whether to act on the baseline signal at the same time, if the baseline is passed in when calling. (default:
False
)
- __call__(*args, eeg: Tensor, baseline: Tensor | None = None, **kwargs) Dict[str, Tensor] [source][source]¶
- Parameters:
eeg (torch.Tensor) – The input EEG signal.
baseline (torch.Tensor, 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 output EEG signal after applying a random PCA noise.
- Return type:
torch.Tensor