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 (
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.
From GitHub (development version):
# install.packages("remotes")
remotes::install_github("Kay202/rsDCM")
From CRAN, once published:
install.packages("rsDCM")
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")
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.
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.
GPL-2.