osl_dynamics.analysis.spectral.partial_directed_coherence_spectra#

osl_dynamics.analysis.spectral.partial_directed_coherence_spectra(f, cpsd, sampling_frequency, n_iterations=50, tol=1e-07, keepdims=False)#

Calculate partial directed coherence from cross power spectra.

We calculate the partial directed coherence as:

\[PDC_{ij}(f) = \frac{|A_{ij}(f)|}{\sqrt{\sum_m |A_{mj}(f)|^2}}\]

where \(i,j\) are different channels and \(A(f) = H^{-1}(f)\) is the inverse of the transfer function, which is calculated by factorizing the cross spectral density matrix.

By default this function will use all cores available.

Parameters:
fnp.ndarray

Frequency axis. Shape is (n_freq,).

cpsdnp.ndarray

Cross power spectra. Shape is (…, n_channels, n_channels, n_freq).

sampling_frequencyfloat

Sampling frequency (Hz).

n_iterationsint, optional

Number of iterations in the Wilson factorization of the cross spectra.

tolfloat, optional

Tolerance for the Wilson factorization of the cross spectra.

keepdimsbool, optional

Should we squeeze any axis of length 1?

Returns:
pdcnp.ndarray

Partial directed coherence spectra. Shape is (…, n_channels, n_channels, n_freq).