Scaled cross-correlation as functional connectivity

class braindynamics_starprotocol.sca.crosscorrelogram.CrossCorrelogram(max_shift_size: int, scale_size: int = None)[source]

Bases: object

Cross-correlogram object, can be either classical Pearson, or SCA.

max_shift_size

Maximum shift (time lag) of time series for which correlation will be computed.

Type:

int

scale_size

Scale size parameter of SCA (length of the average short term window of correlation). Defaults to None.

Type:

int, optional

corr_coeff_arr

Array of correlogram values (correlation coefficients) for each shift (time lag).

Type:

np.ndarray

_interpolator

Interpolator object used to smoothen correlogram.

_maxabs_shift

Shift (time lag) value of the correlogram’s MaxAbs (absolute peak).

Type:

int

_maxabs_value

Correlogram value of MaxAbs (absolute peak).

Type:

float

_maxabs_is_min

Whether or not MaxAbs (absolute peak) is a minimum or maximum of the correlogram.

Type:

bool

clear() None[source]

Clear the correlogram object.

compute(x: ndarray, y: ndarray, use_fisher: bool = True, cc_method: str = 'C') None[source]

Compute CC using one of the implementations (cython or python).

Parameters:
  • x (np.ndarray) – first array of data points

  • y (np.ndarray) – second array of data points

  • use_fisher (bool, optional) – Whether or not use Fisher transformation during SCA. Defaults to True.

  • cc_method (str, optional) – Which implementation to use for the computation. Defaults to “C”.

Raises:
  • ValueError – Input arrays are of uneven length

  • ValueError – Length of input arrays at maximal shift during SCA is less than the scale size

  • ValueError – Wrong implementation method is given

get_maxabs() tuple[source]

Function that determines & saves MaxAbs (absolute peak) of the interpolated correlogram.

Raises:

ValueError – Correlogram is not computed.

Returns:

MaxAbs shift, correlation value

Return type:

tuple

plot(show_interp: bool = False, show_maxabs: bool = False, interp_shift_res: float = 0.1)[source]

Plot correlogram.

Parameters:
  • show_interp (bool, optional) – Show interpolated version. Defaults to False.

  • show_maxabs (bool, optional) – Show maxabs on the plot. Defaults to False.

  • interp_shift_res (float, optional) – Resolution of the interpolated correlogram. Defaults to 0.1.

Raises:

Warning – MaxAbs was not determined.