phys2cvr.stats.x_corr

phys2cvr.stats.x_corr(func, co2, n_shifts=None, offset=0, abs_xcorr=False)[source]

Compute cross correlation between func and co2.

Parameters:
funcnp.ndarray

Timeseries of functional data. Must be no longer than co2.

co2np.ndarray

Timeseries of CO2 (or physiological) data, can be longer than func.

n_shiftsint or None, optional

Number of shifts to test. One shift equals one step. If None, use all possible shifts. Default is None.

offsetint, optional

Number of initial co2 samples to skip. Default is 0.

abs_xcorrbool, optional

If True, return max absolute correlation. Otherwise return max correlation. Default is False.

Returns:
float

Strongest cross correlation.

int

Index of strongest correlation.

np.ndarray

Full correlation array.

Raises:
NotImplementedError

If offset < 0. If co2 length is smaller than func length.

ValueError

If offset is higher than the difference between the length of co2 and func.