dirconn.Connectivity#

class dirconn.Connectivity(values: ndarray, source: tuple[str, ...], target: tuple[str, ...], freqs: ndarray, times: ndarray, provenance: Provenance)#

Directed connectivity with fixed dimensions (source, target, freq, time).

values[i, j] is the influence of source[i] on target[j]. All four dimensions are always present. A dimension a method does not resolve has length 1 and a NaN coordinate, so a result’s shape never depends on parameters. NaN values mark undefined entries (for example the diagonal); infinite values are rejected.

Use from_array() to build a result from fewer dimensions.

Parameters:
  • values (ndarray, shape (n_source, n_target, n_freq, n_time)) – Real or complex values; stored as a read-only float64 or complex128 array.

  • source (tuple of str) – Unique node names for the first two axes.

  • target (tuple of str) – Unique node names for the first two axes.

  • freqs (ndarray, shape (n_freq,)) – Frequencies in Hz, strictly increasing when n_freq > 1; [nan] when the result is not frequency-resolved.

  • times (ndarray, shape (n_time,)) – Times in seconds, strictly increasing when n_time > 1; [nan] when the result is not time-resolved.

  • provenance (Provenance) – Required: every result states how it was produced.

__init__(values: ndarray, source: tuple[str, ...], target: tuple[str, ...], freqs: ndarray, times: ndarray, provenance: Provenance) → None#

Methods

__init__(values, source, target, freqs, ...)

degree_imbalance([mask])

Return log(D_out) - log(D_in) of every node, the sum over its edges in and out.

from_array(values, *, source[, target, ...])

Build a result from an array with two to four dimensions.

from_netcdf(path)

Read a result written by to_netcdf().

net_direction()

Return the net direction of every pair: values[i, j] - values[j, i].

plot([kind])

Draw the result with matplotlib and return the axes.

reduce_freq(band[, how])

Reduce the frequency axis over a band.

reduce_time(segments[, how])

Reduce the time axis over segments, symmetric to reduce_freq().

to_netcdf(path)

Write the result to a NetCDF file, provenance included.

to_xarray()

Return a copy as an xarray.DataArray with named dimensions and coordinates.

with_provenance(provenance)

Return a copy that carries provenance and shares the same values.

Attributes

is_complex

Whether the values are complex.

is_frequency_resolved

Whether the frequency axis carries real frequencies.

is_time_resolved

Whether the time axis carries real times.

values

source

target

freqs

times

provenance