Robust and Sparse Dynamic Causal Modelling for Functional MRI

Provides a robust and sparse method for group-level Dynamic Causal Modelling (DCM) of functional magnetic resonance imaging (fMRI) data: Student-t weighting of subjects for robustness, combined with a nonlocal product-moment (pMOM) spike-and-slab prior for sparse selection of group-level effects (). The package also provides an R implementation of single-subject DCM for fMRI using variational Laplace inversion (Friston et al., 2003 ), including the bilinear neural state equation and the Buxton-Friston hemodynamic response model, ported from the 'SPM25' (version 25.01.02) toolbox for 'MATLAB'.


rsDCM

R-CMD-check

rsDCM is an R package for Dynamic Causal Modelling (DCM) of functional MRI data. It is an R port of the corresponding routines in the MATLAB SPM25 toolbox, with optimizations for the integration and Gauss-Newton inner loops.

Installation

From GitHub (development version):

# install.packages("remotes")
remotes::install_github("Kay202/rsDCM")

From CRAN, once published:

install.packages("rsDCM")

Quick start

library(rsDCM)

# Three-region toy DCM shipped with the package (482 scans, one input)
data(toy_dcm)

# Invert. Takes roughly 75 seconds on this dataset.
fit <- dcm_estimate(toy_dcm)

# Posterior connectivity
round(fit$Ep$A, 3)

# Variational free energy (log-evidence proxy)
fit$F

The introductory vignette has more detail:

vignette("introduction", package = "rsDCM")

What's exported

User-facing entry points:

  • dcm_estimate(): full DCM inversion.
  • dcm_fmri_priors(): build priors from adjacency arrays.
  • dcm_nlsi_GN(): variational Laplace optimisation (lower-level).
  • dcm_int(): bilinear-system integrator (lower-level).
  • dcm_fx_fmri(), dcm_gx_fmri(): neural and BOLD equations.
  • dcm_evidence(): AIC / BIC summary of a fit.
  • rsdcm_options(): adjust runtime options (e.g. FD step).

Group-level (Parametric Empirical Bayes):

  • dcm_peb_prepare(), dcm_peb_run(): fit a second- or third-level PEB.
  • dcm_peb_of_pebs(): third-level PEB-of-PEBs over a directory of subject PEBs.
  • dcm_peb_design(): build the between-subject design matrix.
  • dcm_peb_files(), dcm_peb_load(): locate/load subject PEBs (.rds or MATLAB .mat).

Group-level (robust and sparse, Student-t + pMOM):

  • rsdcm(): robust, sparse group DCM using Student-t subject weighting, a nonlocal product-moment (pMOM) spike-and-slab prior (inclusion probabilities), and ReML variance components.
  • rsdcm_fit(): wrapper that assembles the group model from a list of dcm_estimate() fits.

The narps_dcm dataset (48 subjects, from the openly shared NARPS data) is the runnable real-data example for rsdcm().

Lower-level utilities (dcm_vec, dcm_inv, dcm_logdet, ...) are also exported and have their own help pages, so you can call them directly as dcm_vec(). They are marked @keywords internal, which only keeps them out of the package index. Access is not restricted, and the ::: operator is not needed for them.

Acknowledgment

rsDCM is a derivative work of the MATLAB SPM25 toolbox, distributed under GPL-2 by the Wellcome Centre for Human Neuroimaging. See LICENSE.note for the list of ported routines and the references.

License

GPL-2.

References

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("rsDCM")

0.1.0 by Godfred Arhin, 7 hours ago


https://github.com/Kay202/rsDCM


Report a bug at https://github.com/Kay202/rsDCM/issues


Browse source code at https://github.com/cran/rsDCM


Authors: Godfred Arhin [aut, cre, trl] , Nilotpal Sanyal [aut] , SPM25 Authors [ctb, cph] (Original MATLAB SPM25 (v25.01.02) implementation; see LICENSE.note)


Documentation:   PDF Manual  


GPL-2 license


Imports Matrix, expm, MASS, methods, stats, utils

Suggests testthat, knitr, rmarkdown, R.matlab, withr


See at CRAN