moving_avg
- selfeeg.augmentation.functional.moving_avg(x: ArrayLike, order: int = 5) ArrayLike[source]
applies a moving average filter to the input ArrayLike object.
Filter is applied along its last dimension. The filter order can be given as function argument.
- Parameters:
x (ArrayLike) – The input Tensor or Array. The last two dimensions must refer to the EEG recording (Channels x Samples).
order (int, optional) –
The order of the filter.
Default = 5
- Returns:
x (ArrayLike) – The augmented version of the input Tensor or Array.
Example
>>> import torch >>> import selfeeg.augmentation as aug >>> x = torch.randn(16,32,1024) >>> xaug = aug.moving_avg(x, 5) >>> print( ... math.isclose( x[0,0,5:5+5].sum()/5, xaug[0,0,7], ... rel_tol=1e-8)) #Should output True