gastropy.phase_locking_value_complex

gastropy.phase_locking_value_complex#

gastropy.phase_locking_value_complex(phase_a, phase_b, mask=None)[source]#

Compute the complex phase-locking value.

Returns the complex mean of the phase difference, from which both the PLV magnitude and the preferred phase lag can be extracted.

Parameters:
  • phase_a (array_like, shape (n_timepoints,) or (n_timepoints, n_signals)) – Phase time series in radians.

  • phase_b (array_like, shape (n_timepoints,)) – Reference phase time series in radians.

  • mask (array_like of bool, shape (n_timepoints,), optional) – Boolean mask where True = include, False = exclude. Only the included timepoints contribute to the complex mean.

Returns:

cplv – Complex PLV. abs(cplv) gives the PLV magnitude, np.angle(cplv) gives the preferred phase lag.

Return type:

complex or np.ndarray

Examples

>>> import numpy as np
>>> phase_a = np.zeros(100)
>>> phase_b = np.full(100, 0.5)
>>> cplv = phase_locking_value_complex(phase_a, phase_b)
>>> round(abs(cplv), 2)
1.0
>>> round(np.angle(cplv), 2)  # phase lag ~ -0.5
-0.5