fmri_lm: Fit a Linear Regression Model for fMRI Data Analysis

View source: R/fmrilm.R

fmri_lmR Documentation

Fit a Linear Regression Model for fMRI Data Analysis

Description

This function fits a linear regression model for fMRI data analysis using the specified model formula, block structure, and dataset. The model can be fit using either a runwise or chunkwise data splitting strategy, and robust fitting can be enabled if desired.

Usage

fmri_lm(
  formula,
  block,
  baseline_model = NULL,
  dataset,
  durations = 0,
  drop_empty = TRUE,
  robust = FALSE,
  strategy = c("runwise", "chunkwise"),
  nchunks = 10,
  ...
)

Arguments

formula

The model formula for experimental events.

block

The model formula for block structure.

baseline_model

(Optional) A baseline_model object. Default is NULL.

dataset

An fmri_dataset object containing the time-series data.

durations

A vector of event durations. Default is 0.

drop_empty

Logical. Whether to remove factor levels with zero size. Default is TRUE.

robust

Logical. Whether to use robust fitting. Default is FALSE.

strategy

The data splitting strategy, either "runwise" or "chunkwise". Default is "runwise".

nchunks

Number of data chunks when strategy is "chunkwise". Default is 10.

...

Additional arguments.

Value

A fitted linear regression model for fMRI data analysis.

See Also

fmri_dataset, fmri_lm_fit

Examples


facedes <- subset(read.table(system.file("extdata", "face_design.txt", package = "fmrireg"), 
header=TRUE), face_gen != "n/a")
facedes$face_gen <- droplevels(factor(facedes$face_gen))
sframe <- sampling_frame(rep(430/2,6), TR=2)
ev <- event_model(onset ~ hrf(face_gen, basis="gaussian"), data=facedes, 
block= ~ run, sampling_frame=sframe)
globonsets <- global_onsets(sframe, facedes$onset, blockids(ev))
reg1_signal <- regressor(globonsets[facedes$face_gen == "male"], hrf=HRF_GAUSSIAN)
reg2_signal <- regressor(globonsets[facedes$face_gen == "female"], hrf=HRF_GAUSSIAN)
time <- samples(sframe, global=TRUE)
y1 <- evaluate(reg1_signal, time)*1.5
y2 <- evaluate(reg2_signal, time)*3.0
y <- y1+y2
ys1 <- y + rnorm(length(y), sd=.02)
ys2 <- y + rnorm(length(y), sd=.02)

h <<- gen_hrf(hrf_bspline, N=7, span=25)
dset <- matrix_dataset(cbind(ys1,ys2), TR=2, run_length=sframe$blocklens, event_table=facedes)
flm <- fmri_lm(onset ~ hrf(face_gen, basis=gen_hrf(hrf_bspline, N=7, span=25)), block = ~ run, 
strategy="chunkwise", nchunks=1, dataset=dset)


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