spectral_connectivity.wrapper.fourier_connectivity#

fourier_connectivity(fourier_coefficients: NDArray[complexfloating] | DataArray, frequencies: NDArray[floating] | None = None, time: NDArray[floating] | None = None, method: str | list[str] | None = None, signal_names: Sequence[str | bytes | bool | int | float | integer | floating | bool | str_ | bytes_ | datetime64 | timedelta64] | None = None, *, squeeze: bool = False, connectivity_kwargs: dict[str, ~typing.Any] | None=None, is_one_sided: bool | None = None, group_labels: Sequence[Hashable] | NDArray[Any] | str | None = None, frequency_range: tuple[float, float] | None=None, frequency_decimation: int = 1, frequency_bands: Mapping[str, tuple[float, float]] | None=None, frequency_reduction: Literal['mean', 'integral']='mean', time_dim: Hashable | None = None, trial_dim: Hashable | None = None, taper_dim: Hashable | None = None, frequency_dim: Hashable | None = None, signal_dim: Hashable | None = None, dtype: DTypeLike = <class 'numpy.complex128'>, minimum_phase_tolerance: float = 1e-08, minimum_phase_max_iterations: int = 500) → DataArray | Dataset[source]#

Compute labeled connectivity from externally estimated FFT coefficients.

The labeled output has one time axis, so the expectation is always "trials_tapers"; use Connectivity directly for expectations that retain trial/taper axes or average over time.

Parameters:
  • fourier_coefficients (array or xarray.DataArray) – Complex coefficients in (n_observations, n_frequencies, n_signals), (n_trials, n_tapers, n_frequencies, n_signals), or the core’s full (n_time, n_trials, n_tapers, n_frequencies, n_signals) layout. A DataArray is transposed by semantic dimension names (or the explicit *_dim arguments) and its frequency, time, and signal coordinates and attributes are preserved.

  • frequencies (array, shape (n_frequencies,), optional) – Frequency of each bin in Hz. A two-sided coordinate must be in standard FFT order; a non-negative, strictly increasing coordinate is treated as one-sided when is_one_sided is omitted. Taken from the DataArray coordinate when not given; that coordinate may instead declare units="cycles/sample". Its units must be a spelling of Hz or cycles/sample (e.g. "Hertz", "1/s", "s-1", "cycles/s", ignoring case and whitespace) or empty; convert other units first. Without either, bins are labeled in normalized cycles/sample.

  • time (array, shape (n_time,), optional) – Center time of each window in seconds; defaults to window indices. Taken from the DataArray time coordinate when not given, including a numeric scalar coordinate named time or times on coefficients without a time dimension (as left by isel(time=0)), which is the time of the single window.

  • method (str or list of str, optional) – Measure name(s) from list_measures(). A single name returns a DataArray; a list (or None for DEFAULT_METHODS) returns a Dataset with one variable per measure.

  • signal_names (sequence, optional) – Labels for the source/target coordinates; defaults to the DataArray signal coordinate or "0", "1", ….

  • squeeze (bool, default=False) – Only honored when a single method (a string) is requested. If there are exactly 2 signals, reduce a pairwise measure to the single ordered pair (first source, last target), returning a (time, frequency) array that keeps the selected source and target as scalar coordinates. With more than 2 signals a warning is issued and the full matrix is returned; for power squeeze is a no-op. Length-one time is kept.

  • connectivity_kwargs (dict, optional) – Settings for the measure (a Connectivity method), e.g. pairs for subset_pairwise_spectral_granger_prediction or n_components for canonical_coherency; passed to every requested measure, so a key a requested measure does not take raises TypeError. Transform settings do not go here: they belong to the transform that produced fourier_coefficients.

  • is_one_sided (bool, optional) – Declare whether the coefficients cover only non-negative frequencies. When no frequency coordinate is available the sidedness cannot be inferred: pass True for one-sided input (e.g. rfft output) or False for a full FFT-order spectrum. False is honored as a declaration, so measures that require a two-sided spectrum run on the coefficients as given; they warn if the coefficients are not conjugate-symmetric, as the FFT of real-valued signals is, because mislabeled one-sided input makes those measures wrong. Leaving it unset in that case assumes two-sided, warns, and refuses those measures because the assumption cannot be checked. With a frequency coordinate it is inferred from frequencies.

  • group_labels (sequence or str, optional) – One label per signal naming the group it belongs to; labels are scalars such as integers or area names ("CA1"), and missing values (None, NaN) are rejected. Required by the group measures (canonical_coherence, canonical_coherency, maximized_imaginary_coherency, multivariate_interaction_measure, blockwise_spectral_granger_prediction and maximized_imaginary_coherency_components); an error is raised if no requested measure takes it (labels are passed only to the measures that do). A single string, rather than a sequence, names a coordinate along the input DataArray’s signal dimension whose values are the labels, e.g. group_labels="region" for a region coordinate on channel.

  • frequency_range ((float, float), optional) – (low, high) bounds, in the units of the frequency coordinate, to keep before any decimation or band reduction; both endpoints are included, to within one part in a million of the bin spacing plus rounding (see frequency_band_reduce()). delay, group_delay, and phase_slope_index consume only these bins; other measures are computed from every bin and cropped, as in multitaper_connectivity().

  • frequency_decimation (int, default=1) – Keep every frequency_decimation-th frequency bin of the frequency-resolved measures.

  • frequency_bands (mapping of str to (float, float), optional) – Named bands, both endpoints included, to reduce the frequency axis of the frequency-resolved measures into; see frequency_band_reduce() and multitaper_connectivity() for phase_slope_index and group_delay.

  • frequency_reduction ({"mean", "integral"}, default="mean") – Within-band reduction used with frequency_bands.

  • time_dim (hashable, optional) – DataArray dimension names for each axis role, when they cannot be inferred from common names.

  • trial_dim (hashable, optional) – DataArray dimension names for each axis role, when they cannot be inferred from common names.

  • taper_dim (hashable, optional) – DataArray dimension names for each axis role, when they cannot be inferred from common names.

  • frequency_dim (hashable, optional) – DataArray dimension names for each axis role, when they cannot be inferred from common names.

  • signal_dim (hashable, optional) – DataArray dimension names for each axis role, when they cannot be inferred from common names.

  • dtype (numpy.dtype, default=complex128) – Working precision for the connectivity computations.

  • minimum_phase_tolerance (float, default=1e-8) – Relative convergence tolerance of the Wilson factorization used by the directed measures.

  • minimum_phase_max_iterations (int, default=500) – Maximum Wilson iterations for the directed measures.

Returns:

Labeled result with time, frequency (or band), and measure-specific dimensions such as source/target; a DataArray for a single method name, otherwise a Dataset. Directed measures are oriented so sel(source=a, target=b) is the influence from a to b. One-sided coefficients support functional measures, but measures that need a full two-sided spectrum raise.

Return type:

xarray.DataArray or xarray.Dataset