sframe <- sampling_frame(blocklens = c(100, 100), TR = 2)
emod <- event_model(onset ~ hrf(condition, basis = "spmg1"), data = design_table, block = ~ run, sampling_frame = sframe)
bmod <- baseline_model(basis = "bs", degree = 5, sframe = sframe)
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](https://github.com/bbuchsbaum/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:
- [Package Overview](https://bbuchsbaum.github.io/fmrireg/articles/fmrireg.html)
- [Statistical Contrasts](https://bbuchsbaum.github.io/fmrireg/articles/a_05_contrasts.html)
- [Simulation](https://bbuchsbaum.github.io/fmrireg/articles/a_08_simulation.html)
- [Linear Modeling](https://bbuchsbaum.github.io/fmrireg/articles/a_09_linear_model.html)
- [Dataset Management](https://bbuchsbaum.github.io/fmrireg/articles/a_10_dataset.html)
- [Group Analysis](https://bbuchsbaum.github.io/fmrireg/articles/group_analysis.html)
- [Functional Connectivity](https://bbuchsbaum.github.io/fmrireg/articles/functional_connectivity.html)
- [Sketched GLM](https://bbuchsbaum.github.io/fmrireg/articles/sketched-ar.html)
- [Benchmark Datasets](https://bbuchsbaum.github.io/fmrireg/articles/benchmark_datasets.html)
## Command line
Install the package:
```r
remotes::install_github("bbuchsbaum/fmrireg")
Install the command wrapper:
fmrireg::install_cli("~/.local/bin", overwrite = TRUE)If needed, add the directory to PATH:
export PATH="$HOME/.local/bin:$PATH"Check the command:
fmrireg --helpInspect bundled benchmark datasets:
fmrireg benchmark list
fmrireg benchmark summary --dataset BM_Canonical_HighSNR --jsonPDF report generation for fmri_lm fits is provided by the separate
fmrireport package:
fmrireport::report(fit, output_dir = "results")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.
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
MIT
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.