estimate_betas: Estimate Beta Coefficients for fMRI Data

View source: R/all_generic.R

estimate_betasR Documentation

Estimate Beta Coefficients for fMRI Data

Description

Estimate beta coefficients (regression parameters) from fMRI data using various methods. This function supports different estimation approaches for:

single

Single-trial beta estimation

effects

Fixed and random effects

regularization

Various regularization techniques

hrf

Optional HRF estimation

This function estimates betas (regression coefficients) for fixed and random effects in a matrix dataset using various methods.

Usage

estimate_betas(x, ...)

## S3 method for class 'latent_dataset'
estimate_betas(
  x,
  fixed = NULL,
  ran,
  block,
  method = c("mixed", "pls", "pls_global", "ols"),
  basemod = NULL,
  ncomp = 4,
  lambda = 0.01,
  prewhiten = FALSE,
  ...
)

Arguments

x

An object of class matrix_dataset representing the matrix dataset

...

Additional arguments passed to the estimation method

fixed

A formula specifying the fixed regressors that model constant effects (i.e., non-varying over trials)

ran

A formula specifying the random (trialwise) regressors that model single trial effects

block

A formula specifying the block factor

method

The regression method for estimating trialwise betas; one of "mixed", "pls", "pls_global", or "ols" (default: "mixed")

basemod

A baseline_model instance to regress out of data before beta estimation (default: NULL)

ncomp

Number of PLS components for the "pls" and "pls_global" methods (default: 4)

lambda

Lambda parameter (not currently used; default: 0.01)

prewhiten

currently experimental, default to FALSE.

Details

This is a generic function with methods for different dataset types:

fmri_dataset

For volumetric fMRI data

matrix_dataset

For matrix-format data

latent_dataset

For dimensionality-reduced data

Available estimation methods include:

mixed

Mixed-effects model using rrBLUP

r1

Rank-1 GLM with joint HRF estimation

lss

Least-squares separate estimation

pls

Partial least squares regression

ols

Ordinary least squares

fracridge

Fractional ridge regression

Value

A list of class "fmri_betas" containing:

betas_fixed

Fixed effect coefficients

betas_ran

Random (trial-wise) coefficients

design_ran

Design matrix for random effects

design_fixed

Design matrix for fixed effects

design_base

Design matrix for baseline model

method_specific

Additional components specific to the estimation method used

A list of class "fmri_betas" containing the following components:

  • betas_fixed: Matrix representing the fixed effect betas

  • betas_ran: Matrix representing the random effect betas

  • design_ran: Design matrix for random effects

  • design_fixed: Design matrix for fixed effects

  • design_base: Design matrix for baseline model

References

Mumford, J. A., et al. (2012). Deconvolving BOLD activation in event-related designs for multivoxel pattern classification analyses. NeuroImage, 59(3), 2636-2643.

Pedregosa, F., et al. (2015). Data-driven HRF estimation for encoding and decoding models. NeuroImage, 104, 209-220.

See Also

fmri_dataset, matrix_dataset, latent_dataset

matrix_dataset, baseline_model

Other estimate_betas: estimate_betas.matrix_dataset()

Examples

# Create example data
event_data <- data.frame(
  condition = factor(c("A", "B", "A", "B")),
  onsets = c(1, 10, 20, 30),
  run = c(1, 1, 1, 1)
)

# Create sampling frame and dataset
sframe <- sampling_frame(blocklens = 50, TR = 2)
dset <- matrix_dataset(
  matrix(rnorm(100 * 2), 100, 2),
  TR = 2,
  run_length = 50,
  event_table = event_data
)

# Estimate betas using mixed-effects model
betas <- estimate_betas(
  dset,
  fixed = onset ~ hrf(condition),
  ran = onset ~ trialwise(),
  block = ~run,
  method = "mixed"
)


bbuchsbaum/fmrireg documentation built on March 1, 2025, 11:20 a.m.