API#

Spectral connectivity analysis for electrophysiological data.

This package provides tools for computing frequency-domain functional and directed connectivity measures from time series data using multitaper methods.

Start with multitaper_connectivity(), which takes a time series shaped (n_time_samples, n_trials, n_signals) and returns a labeled xarray result, and list_measures(), which lists every valid method with its units, value range, and interpretation. In the wrapper’s results, result.sel(source="a", target="b") is the influence of a on b. The lower-level Connectivity methods return plain arrays whose signal axes come in two orders; MeasureInfo.array_orientation names each measure’s.

Guide for AI coding assistants: https://spectral-connectivity.readthedocs.io/en/latest/llm_guide.html Machine-readable index of the documentation (llms.txt): https://spectral-connectivity.readthedocs.io/en/latest/llms.txt

Examples

>>> import numpy as np
>>> from spectral_connectivity import multitaper_connectivity
>>> time_series = np.random.default_rng(0).standard_normal((1000, 5, 2))
>>> coherence = multitaper_connectivity(
...     time_series, sampling_frequency=500, method="coherence_magnitude"
... )
>>> coherence.dims
('time', 'frequency', 'source', 'target')

spectral_connectivity.connectivity

Compute metrics for relating signals in the frequency domain.

spectral_connectivity.minimum_phase_decomposition

Minimum phase decomposition for spectral density matrices.

spectral_connectivity.simulate

Functions to simulate time series processes for connectivity analysis.

spectral_connectivity.statistics

Statistical procedures for connectivity analysis.

spectral_connectivity.transforms

Transforms time domain signals to the frequency domain.

spectral_connectivity.wrapper

Functions for getting connectivity measures in a labeled array format.