braintools.analysis.spectral.plv#
- braintools.analysis.spectral.plv(x, y, dt=None, band=None)#
Compute the phase-locking value between two continuous signals.
The instantaneous phases \(\phi_x, \phi_y\) are the angles of the analytic signals (
analytic_signal()) and [1]\[\mathrm{PLV} = \left| \frac{1}{T} \sum_{t} e^{i(\phi_x(t) - \phi_y(t))} \right|.\]- Parameters:
x (
Array|ndarray|bool|number|bool|int|float|complex|Quantity) – Real signals of identical shape(T, ...); time is axis 0. Quantities are accepted (phases are scale-invariant).y (
Array|ndarray|bool|number|bool|int|float|complex|Quantity) – Real signals of identical shape(T, ...); time is axis 0. Quantities are accepted (phases are scale-invariant).dt (
float|Quantity|None) – Sampling interval (seconds if a plain number). Required withband.band (
Tuple[float,float] |None) – If given, both signals are first filtered withbandpass()(order=4) inbandHz. Phase is only meaningful for narrow-band signals, so either passbandor pre-filter the inputs.
- Returns:
plv – Values in
[0, 1]of shapex.shape[1:]; 1 means a constant phase difference.- Return type:
Array- Raises:
ValueError – If the shapes differ,
bandis given withoutdt, orbandis invalid (seebandpass()).
See also
pliPhase-lag index (insensitive to zero-lag coupling).
wpliWeighted phase-lag index.
braintools.analysis.spike.phase_locking_valueSpike-field locking. That function measures how consistently the spikes of each neuron fall at the same phase of an external reference oscillation of a given frequency (vector strength of spike phases), whereas this function measures phase locking between two continuous signals sampled at every time step (Lachaux et al. 1999).
Notes
Jittable and vmappable. Differentiable with respect to the signals wherever the analytic amplitudes are non-zero and
PLV > 0.References
Examples
>>> import jax.numpy as jnp >>> from braintools.analysis.spectral import plv >>> t = jnp.arange(1000) * 1e-3 >>> x = jnp.cos(2 * jnp.pi * 10 * t) >>> y = jnp.cos(2 * jnp.pi * 10 * t - jnp.pi / 3) >>> round(float(plv(x, y)), 4) 1.0