Torch-based Transforms
transforms.ToTensor
transforms.Resize
- class torcheeg.transforms.Resize(size: Union[Sequence[int], int], interpolation: str = 'bilinear')[source]
Bases:
object
Use an interpolation algorithm to scale a grid-like EEG signal at the spatial dimension.
transform = ToTensor(size=(64, 64)) transform(torch.randn(128, 9, 9)).shape >>> (128, 64, 64)
- Parameters
size (tuple) – The output spatial size.
interpolation (str) – The interpolation algorithm used for upsampling, can be nearest, linear, bilinear, bicubic, trilinear, and area. (defualt:
'nearest'
)
transforms.RandomNoise
- class torcheeg.transforms.RandomNoise(mean: float = 0.0, std: float = 1.0, p: float = 0.5)[source]
Bases:
object
Add random noise conforming to the normal distribution on the EEG signal.
transform = RandomNoise(p=0.5) transform(torch.randn(32, 128)).shape >>> (32, 128)
- Parameters
mean (float) – The mean of the normal distribution of noise. (defualt:
0.0
)std (float) – The standard deviation of the normal distribution of noise. (defualt:
0.0
)p (float) – Probability of adding noise to EEG signal samples. Should be between 0.0 and 1.0, where 0.0 means no noise is added to every sample and 1.0 means that noise is added to every sample. (defualt:
0.5
)
transforms.RandomMask
- class torcheeg.transforms.RandomMask(ratio: float = 0.5, p: float = 0.5)[source]
Bases:
object
Overlay the EEG signal using a random mask, and the value of the overlaid data points was set to 0.0.
transform = RandomMask() transform(torch.randn(32, 128)).shape >>> (32, 128)
- Parameters
ratio (float) – The proportion of data points covered by the mask out of all data points for each EEG signal sample. (defualt:
0.5
)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. (defualt:
0.5
)