braindecode.functional.hilbert_freq#
- braindecode.functional.hilbert_freq(x, forward_fourier=True)[source]#
Compute the Hilbert transform using PyTorch, separating the real and imaginary parts.
The analytic signal
of a real-valued signal is defined as:where: -
is the Fourier transform, - is the unit step function, - is the Hilbert transform of .- Parameters:
input (torch.Tensor) –
Input tensor. The expected shape depends on the forward_fourier parameter:
- If forward_fourier is True:
(…, seq_len)
- If forward_fourier is False:
(…, seq_len / 2 + 1, 2)
forward_fourier (bool, optional) – Determines the format of the input tensor. - If True, the input is in the forward Fourier domain. - If False, the input contains separate real and imaginary parts. Default is True.
- Returns:
Output tensor with shape (…, seq_len, 2), where the last dimension represents the real and imaginary parts of the Hilbert transform.
- Return type:
Examples
>>> import torch >>> input = torch.randn(10, 100) # Example input tensor >>> output = hilbert_transform(input) >>> print(output.shape) torch.Size([10, 100, 2])
Notes
The implementation is matching scipy implementation, but using torch. scipy/scipy