Skip to contents

Estimates an autoregressive whitener for a single NeuroVec run using the global mean (optionally restricted to WM) and Yule–Walker AR fitting. Returns the inverse Cholesky Q, the covariance Sigma, and AR coefficients phi.

Usage

estimate_ar_whitener(nv_run, wm_mask = NULL, p = 1L)

Arguments

nv_run

A neuroim2::NeuroVec (single run) with dimensions V x T.

wm_mask

Optional NeuroVol to restrict the mean to WM voxels.

p

Integer AR order (default 1). Use 0 to skip AR modeling.

Value

A list with components Q (inverse Cholesky), Sigma (covariance), and phi (AR coefficients of length p).

Details

The time series is formed as the mean across voxels, optionally within a provided white-matter mask. It is standardized, and AR(p) coefficients are estimated via stats::ar.yw. The implied Toeplitz covariance Sigma is regularized to positive definiteness (via a ridge and Matrix::nearPD if needed). The whitener Q = chol(Sigma)^{-1} is returned for use in the row metric. If p = 0, an identity whitener is returned.

Examples

# \donttest{
nv_run <- neuroim2::simulate_fmri(mask, n_time = 50, seed = 1)
#> Error: object 'mask' not found
arw   <- estimate_ar_whitener(nv_run, p = 1L)
#> Error: object 'nv_run' not found
# }