Installation
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
Albers theme
This package uses the albersdown theme. Existing vignette theme hooks are replaced so albers.css and local albers.js render consistently on CRAN and GitHub Pages. The defaults are configured via params$family and params$preset (family = ‘red’, preset = ‘homage’). The pkgdown site uses template: { package: albersdown } together with generated pkgdown/extra.css and pkgdown/extra.js so the theme is linked and activated on site pages.