pybispectra.utils.ResultsCFC#

class pybispectra.utils.ResultsCFC(data: ndarray, indices: tuple[tuple[int]], f1s: ndarray, f2s: ndarray, times: ndarray | None = None, name: str = 'CFC')[source]#

Class for storing cross-frequency coupling (CFC) results.

Parameters:
datandarray, shape of [nodes, low frequencies, high frequencies (, times)]

Results to store.

indicestuple of tuple of int, length of 2

Indices of the channels for each connection of the results. Should contain two tuples of equal length for the seed and target indices, respectively.

f1sndarray, shape of [low frequencies]

Low frequencies (in Hz) in the results.

f2sndarray, shape of [high frequencies]

High frequencies (in Hz) in the results.

timesndarray, shape of [times] | None (default None)

Timepoints in the results (in seconds). Must be provided if data has a times dimension.

Added in version 1.3.

namestr (default "CFC")

Name of the results being stored.

Attributes:
namestr

Name of the results.

indicestuple of tuple of int, length of 2

Indices of the channels for each connection of the results. Contains two tuples of equal length for the seed and target indices, respectively.

shapetuple of int

Shape of the results i.e., [nodes, low frequencies, high frequencies (, times)].

n_nodesint

Number of connections in the the results.

f1sndarray, shape of [low frequencies]

Low frequencies (in Hz) in the results.

f2sndarray, shape of [high frequencies]

High frequencies (in Hz) in the results.

timesndarray, shape of [times] | None

Timepoints (in seconds) in the results.

Methods

get_results([form, copy])

Return the results.

plot([nodes, f1s, f2s, times, n_rows, ...])

Plot the results.

get_results(form: str = 'raveled', copy: bool = True) ndarray | tuple[ndarray, tuple[tuple[int]]][source]#

Return the results.

Parameters:
form"raveled" | "compact" (default "raveled")

How the results should be returned: "raveled" - results have shape [nodes, ...]; "compact" - results have shape [seeds, targets, ...], where ... represents the data dimensions (e.g., frequencies, times).

copybool (default True)

Whether or not to return a copy of the results.

Added in version 1.2.

Returns:
resultsndarray

The results.

indicestuple of tuple of int, length of 2

Channel indices of the seeds and targets in results, according to the node order in the original data indices. Only returned if form is "compact".

plot(nodes: int | tuple[int] | None = None, f1s: tuple[int | float] | None = None, f2s: tuple[int | float] | None = None, times: tuple[int | float] | None = None, n_rows: int = 1, n_cols: int = 1, major_tick_intervals: int | float = 5.0, minor_tick_intervals: int | float = 1.0, cbar_range: tuple[float] | list[tuple[float]] | None = None, show: bool = True) tuple[list[Figure], list[ndarray]][source]#

Plot the results.

Parameters:
nodesint | tuple of int | None (default None)

Indices of connections to plot. If None, plot all connections.

f1stuple of int or float | None (default None)

Start and end low frequencies (in Hz) of the results to plot, respectively. If None, all low frequencies are plotted.

f2stuple of int or float | None (default None)

Start and end high frequencies (in Hz) of the results to plot, respectively. If None, all high frequencies are plotted.

timestuple of int or float, length of 2 | None (default None)

Start and end times (in seconds) of the results to plot, respectively. If None, all timepoints are used. Time-resolved results are aggregated by averaging over the selected timepoints.

Added in version 1.3.

n_rowsint (default 1)

Number of rows of subplots per figure.

n_colsint (default 1)

Number of columns of subplots per figure.

major_tick_intervalsint | float (default 5.0)

Intervals (in Hz) at which the major ticks of the x- and y-axes should occur.

minor_tick_intervalsint | float (default 1.0)

Intervals (in Hz) at which the minor ticks of the x- and y-axes should occur.

cbar_rangetuple of float | list of tuple of float | None (default None)

Range (in units of the data) for the colourbars, consisting of the lower and upper limits, respectively. If None, the range is computed automatically. If a tuple of float, this range is used for all plots. If a list of tuple of float, the ranges are used for each individual plot.

showbool (default True)

Whether or not to show the plotted results.

Returns:
figureslist of matplotlib Figure

Figures of the results in a list of length ceil(n_nodes / (n_rows * n_cols)).

axeslist of ndarray of matplotlib pyplot Axes

Subplot axes for the results in a list of length ceil(n_nodes / (n_rows * n_cols)) where each entry is a 1D ~numpy.ndarray of length (n_rows * n_cols).

Notes

n_rows and n_cols of 1 will plot the results for each connection on a new figure.