match_covariance#

hypercoil.neuro.synth.match_covariance(signal: Tensor, reference: Tensor, cov: bool = False) Tensor[source]#

Project a multivariate signal so that its covariance matches a reference covariance.

This uses the procedure described in Laumann et al. (2017), “On the Stability of BOLD fMRI Correlations”. Specifically, given an input multivariate time series \(\mathbf{T}\) and a reference covariance matrix \(\Sigma\), the procedure first computes the eigendecomposition of the real symmetric \(\Sigma\) and then forms a projected time series \(\widetilde{\mathbf{T}}\).

\[ \begin{align}\begin{aligned}\begin{aligned} \Sigma &= Q \Lambda Q^\intercal\\\widetilde{\mathbf{T}} &= Q \Lambda^{\frac{1}{2}} \mathbf{T} \end{aligned}\end{aligned}\end{align} \]

The basic assumption of the procedure is that the input time series \(\mathbf{T}\) (containing \(n\) observations) is drawn from a process such that in expectation

\(\frac{1}{n} \mathbf{E}[\mathbf{T} \mathbf{T}^\intercal] = \mathbf{I}\)

where \(\mathbf{I}\) is the identity matrix. This assumption holds inter alia when \(\mathbf{T}\) is drawn i.i.d. from a standard normal distribution.

\[ \begin{align}\begin{aligned}\begin{aligned} \frac{1}{n} \mathbf{E}[\widetilde{\mathbf{T}} \widetilde{\mathbf{T}}^\intercal] &= \frac{1}{n} \mathbf{E}[Q \Lambda^{\frac{1}{2}} \mathbf{T} \mathbf{T}^\intercal \Lambda^{\frac{1}{2}} Q^\intercal]\\&= Q \Lambda^{\frac{1}{2}} \left(\frac{1}{n} \mathbf{E}[\mathbf{T} \mathbf{T}^\intercal] \right) \Lambda^{\frac{1}{2}} Q^\intercal\\&= Q \Lambda Q^\intercal = \Sigma \end{aligned}\end{aligned}\end{align} \]
Dimension:
signal : \((D, N)\)

D denotes dimension of the multivariate signal and N denotes the number of observations per channel.

reference : \((D, N)\) or \((D, D)\)

As above. Depends on the Boolean value passed to cov.

Parameters:
signaltensor

Input signal \(\mathbf{T}\) to project so that its covariance is matched to the reference.

referencetensor

Either a reference signal whose covariance \(\Sigma\) is to be matched, or the covariance matrix itself. See cov.

covbool (default False)

If True, indicates that the reference provided is a covariance matrix. Otherwise, the covariance matrix is computed from the provided reference.

Returns:
tensor

\(\widetilde{\mathbf{T}}\), signal projected to match the reference covariance.