torch_zscore
- selfeeg.utils.utils.torch_zscore(x: Tensor, axis: int = -2, correction: int = 1) Tensor[source]
zscore operator for torch tensors.
It is heavily based on scipy’s zscore in order to provide identical results when using numpy arrays. The analogous command in scipy is:
x_zscore = scipy.stats.zscore(x, axis=axis, ddof=correction)
- Parameters:
x (torch.Tensor) – The tensor to standardize.
axis (int) –
The axis along which to operate. By default, it assumes that the EEG channel dimension is the second to last. If the tensor has only one dimension, default value is changed to 0.
Default = -2
correction (int) –
difference between the sample size and sample degrees of freedom. It is applied during the calculation of the standard deviation. It is equivalent to the Scipy’s zscore ddof argument. Default is Bessel’s correction as used in Pytorch’s std function.
Default = 1
- Returns:
xz (torch.Tensor) – The tensor standardized along the given dimension.