Extract Images/Volumes for Multiple Coefficients
Source:R/fmri_lm_methods.R, R/fmri_meta_methods.R
coef_images.RdA plural companion to coef_image. Returns a named list of
volumes (or numeric vectors for non-spatial datasets), one per coefficient,
so callers can iterate over or write out every coefficient without
reimplementing the loop over coef_names.
Arguments
- object
A fitted model object.
- statistic
For
fmri_lmobjects: one of"estimate","se","tstat", or"prob".- type
For
fmri_lmobjects: which coefficient set to extract:"estimates"(default),"contrasts", or"F".- coefs
Optional character vector of coefficient names (a subset of
coef_names(object, type = type)) to extract. Defaults to all coefficients of the requestedtype.- ...
Additional arguments passed to methods (and on to
coef_image).
Value
A named list of NeuroVol objects (or numeric vectors when the
dataset is non-spatial), named by coefficient.
Examples
# Create a small example
X <- matrix(rnorm(50 * 4), 50, 4)
edata <- data.frame(
condition = factor(c("A", "B", "A", "B")),
onsets = c(1, 12, 25, 38),
run = c(1, 1, 1, 1)
)
dset <- fmridataset::matrix_dataset(X, TR = 2, run_length = 50,
event_table = edata)
fit <- fmri_lm(onsets ~ hrf(condition), block = ~run, dataset = dset)
# Named list of one volume per event regressor
imgs <- coef_images(fit, statistic = "estimate", type = "estimates")
names(imgs)
#> [1] "condition_condition.A" "condition_condition.B"