Skip to content

bbuchsbaum/fmrireg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

927 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fmrireg

R-CMD-check Codecov test coverage License: GPL v2 Lifecycle: experimental

fmrireg provides tools for the analysis of functional magnetic resonance imaging (fMRI) data in R. It supports flexible hemodynamic response functions, experimental regressor construction, and univariate fMRI regression using a formula-based interface inspired by lm() and glm().

Installation

Install the development version from GitHub:

# install.packages("remotes")
remotes::install_github("bbuchsbaum/fmrireg")

Quick start

library(fmrireg)

# Define the temporal structure: 2 runs, 100 scans each, TR = 2s
sframe <- sampling_frame(blocklens = c(100, 100), TR = 2)

# Build an event model from an experimental design table
emod <- event_model(onset ~ hrf(condition, basis = "spmg1"),
                    data = design_table,
                    block = ~ run,
                    sampling_frame = sframe)

# Add a baseline model with polynomial drift
bmod <- baseline_model(basis = "bs", degree = 5, sframe = sframe)

# Combine into a full fMRI model and fit
fmod <- fmri_model(emod, bmod)
fit  <- fmri_lm(fmod, dataset = dset)

Key features

  • HRF library -- SPM canonical, gamma, Gaussian, B-spline, and custom basis sets, with decorators for lag, block, and normalization.
  • Formula interface -- Specify event models with onset ~ hrf(...) syntax; supports categorical events, continuous modulators, and multi-basis expansions.
  • Contrast system -- Flexible contrasts via formulas, including pairwise, polynomial, and F-contrasts.
  • Robust estimation -- OLS, iteratively reweighted least squares (IWLS), and sandwich variance estimators.
  • AR correction -- Autoregressive noise modeling via the fmriAR package.
  • Performance -- C++ solvers (Rcpp/RcppArmadillo) with optional multithreading via RcppParallel.

Documentation

Full documentation and tutorials are available at https://bbuchsbaum.github.io/fmrireg/. Vignettes include:

Reporting

PDF report generation for fmri_lm fits is provided by the separate fmrireport package:

fmrireport::report(fit, output_dir = "results")

Performance configuration

The internal C++ routines use RcppParallel. Control the thread count with:

options(fmrireg.num_threads = 4)

or set the environment variable FMRIREG_NUM_THREADS before loading the package.

Citation

If you use fmrireg in your research, please cite:

Buchsbaum, B. R. (2025). fmrireg: Regression Analysis of Functional
Magnetic Resonance Imaging Data. R package version 0.1.2.
https://github.com/bbuchsbaum/fmrireg

License

GPL (>= 2)

About

R package for regression-based analysis of fMRI data

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages