braintools.analysis.spectral.analytic_signal

braintools.analysis.spectral.analytic_signal#

braintools.analysis.spectral.analytic_signal(x, axis=0)#

Compute the analytic signal by the FFT Hilbert transform.

The analytic signal is \(x_a = x + i\,\mathcal{H}[x]\) [1]. It is obtained by zeroing the negative-frequency half of the spectrum and doubling the positive half (DC and, for even length, the Nyquist bin are kept as is), exactly as scipy.signal.hilbert.

Parameters:
  • x (Array | ndarray | bool | number | bool | int | float | complex | Quantity) – Real signal. A brainunit.Quantity is accepted.

  • axis (int) – Axis along which to transform (time). Static.

Returns:

xa – Complex analytic signal of the same shape (and unit) as x; abs(xa) is the amplitude envelope and angle(xa) the instantaneous phase.

Return type:

Array | Quantity

Raises:

ValueError – If x is complex or the transform axis has length 0.

See also

bandpass

Zero-phase Butterworth band-pass filter.

plv

Phase-locking value between two signals.

Notes

The function is jittable, vmappable and (being linear) differentiable with respect to x.

References

Examples

>>> import jax.numpy as jnp
>>> from braintools.analysis.spectral import analytic_signal
>>> t = jnp.arange(1000) * 1e-3
>>> z = analytic_signal(jnp.cos(2 * jnp.pi * 10 * t))
>>> bool(jnp.allclose(jnp.abs(z), 1.0, atol=1e-4))
True