View source: R/fit_and_apply.R
| whiten_apply | R Documentation |
Apply a whitening plan to design and data matrices
whiten_apply(
plan,
X,
Y,
runs = NULL,
run_starts = NULL,
censor = NULL,
parcels = NULL,
inplace = FALSE,
parallel = TRUE
)
plan |
Whitening plan from |
X |
Numeric matrix of predictors (time x regressors). |
Y |
Numeric matrix of data (time x voxels). |
runs |
Optional run labels. |
run_starts |
Optional 0-based run start indices (alternative to |
censor |
Optional indices of censored TRs (1-based); filter resets after gaps. |
parcels |
Optional parcel labels (length = ncol(Y)) when using parcel plans. |
inplace |
Modify inputs in place (logical). |
parallel |
Use OpenMP parallelism if available. |
List with whitened data. Parcel plans return X_by per parcel; others return a single X matrix.
# Create example design matrix and data
n_time <- 200
n_pred <- 3
n_voxels <- 50
X <- matrix(rnorm(n_time * n_pred), n_time, n_pred)
Y <- X %*% matrix(rnorm(n_pred * n_voxels), n_pred, n_voxels) +
matrix(rnorm(n_time * n_voxels), n_time, n_voxels)
# Fit noise model from residuals
residuals <- Y - X %*% solve(crossprod(X), crossprod(X, Y))
plan <- fit_noise(residuals, method = "ar", p = 2)
# Apply whitening
whitened <- whiten_apply(plan, X, Y)
Xw <- whitened$X
Yw <- whitened$Y
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.