| Title: | Robust and Sparse Dynamic Causal Modelling for Functional MRI |
|---|---|
| Description: | 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 (<doi:10.48550/arXiv.2609.06379>). The package also provides an R implementation of single-subject DCM for fMRI using variational Laplace inversion (Friston et al., 2003 <doi:10.1016/S1053-8119(03)00202-7>), including the bilinear neural state equation and the Buxton-Friston hemodynamic response model, ported from the 'SPM25' (version 25.01.02) toolbox for 'MATLAB'. |
| Authors: | Godfred Arhin [aut, cre, trl], Nilotpal Sanyal [aut], SPM25 Authors [ctb, cph] (Original MATLAB SPM25 (v25.01.02) implementation; see LICENSE.note) |
| Maintainer: | Godfred Arhin <[email protected]> |
| License: | GPL-2 |
| Version: | 0.1.0 |
| Built: | 2026-10-11 12:30:23 UTC |
| Source: | https://github.com/kay202/rsdcm |
rsDCM provides a robust and sparse method for group-level Dynamic Causal Modelling (DCM) of fMRI data, together with an R implementation of single-subject DCM ported from the MATLAB SPM25 toolbox.
The package's main method is rsdcm (with the convenience
wrapper rsdcm_fit): a group-level model that weights subjects
by a Student-t likelihood (robustness to outliers) and selects group-level
effects with a nonlocal product-moment (pMOM) spike-and-slab prior
(sparsity), with ReML-estimated between-subject variance components. The
“rs” is
robust and sparse; it does not denote resting-state fMRI.
For single-subject inversion, the main entry point is
dcm_estimate.
rsdcmRobust, sparse group DCM (Student-t + pMOM).
rsdcm_fitAssemble rsdcm inputs from a list of fitted DCMs.
rsdcm_optionsGet or set package numerical options.
dcm_estimateFull DCM inversion (main entry point).
dcm_nlsi_GNVariational Laplace / Gauss-Newton inversion.
dcm_intBilinear-system integrator (forward model).
dcm_fmri_priorsConstruct fMRI DCM priors.
dcm_fx_fmri, dcm_gx_fmri
Neural-state and BOLD observation equations.
dcm_bireduce, dcm_kernels
Bilinear reduction and Volterra kernels.
dcm_evidence, dcm_log_evidence, dcm_log_evidence_reduce
Model evidence and Bayesian model reduction.
dcm_peb_prepare, dcm_peb_run
Prepare and fit a second- or third-level PEB.
dcm_peb_of_pebsThird-level PEB-of-PEBs over a directory of subject PEBs.
dcm_peb_design, dcm_peb_files, dcm_peb_load
Design-matrix and subject-PEB loading helpers.
toy_dcmThree-region single-subject DCM specification.
narps_dcm48-subject NARPS DCM summaries used by rsdcm.
Lower-level numerical helpers (matrix and vector utilities, numerical
differentiation, matrix exponentials, and error-covariance bases) are also
exported and documented; see, for example, dcm_vec,
dcm_inv, dcm_diff, and dcm_Ce.
The single-subject DCM routines are a derivative work of the MATLAB SPM25
(version 25.01.02) toolbox, distributed under GPL-2 by the Wellcome Centre
for Human
Neuroimaging. See the LICENSE.note file in the package source for
the list of ported routines.
Maintainer: Godfred Arhin [email protected] [translator]
Authors:
Godfred Arhin [email protected] [translator]
Nilotpal Sanyal [email protected]
Other contributors:
SPM25 Authors (Original MATLAB SPM25 (v25.01.02) implementation; see LICENSE.note) [contributor, copyright holder]
Arhin, G., Sanyal, N. (2026). Robust and Sparse Group Dynamic Causal Modeling via Student-t Parametric Empirical Bayes and Nonlocal Priors. arXiv:2609.06379. doi:10.48550/arXiv.2609.06379
Botvinik-Nezer, R., Holzmeister, F., Camerer, C.F., et al. (2020). Variability in the analysis of a single neuroimaging dataset by many teams. Nature, 582(7810), 84-88. doi:10.1038/s41586-020-2314-9
Friston, K.J., Harrison, L., Penny, W. (2003). Dynamic causal modelling. NeuroImage, 19(4), 1273-1302. doi:10.1016/S1053-8119(03)00202-7
Friston, K.J., Mattout, J., Trujillo-Barreto, N., Ashburner, J., Penny, W. (2007). Variational free energy and the Laplace approximation. NeuroImage, 34(1), 220-234. doi:10.1016/j.neuroimage.2006.08.035
Valerio, D., Peres, A., Bergstrom, F., Seidel, P., Almeida, J. (2025). Neural and behavioral similarity-driven tuning curves for manipulable objects. Imaging Neuroscience, 3. doi:10.1162/imag_a_00482
Useful links:
Inverts a fully-specified DCM using variational Laplace inversion. This
is the main user-facing entry point of the package. Mirrors SPM25's
dcm_estimate. Progress is reported via message() and can be
silenced with suppressMessages().
dcm_estimate(P, save = FALSE)dcm_estimate(P, save = FALSE)
P |
A DCM list, or a path to an |
save |
Logical. If |
The estimated DCM (a list) with posterior fields populated. The
main fields of interest are Ep (posterior expectations, with
Ep$A, Ep$B, Ep$C the connectivity estimates),
Cp (posterior covariance), Pp (posterior probabilities),
and F (the negative free energy, used for model comparison).
This release implements only the deterministic, single-state fMRI
DCM. The two-state (options$two_state), stochastic
(options$stochastic) and spectral / cross-spectral-density
(options$induced) variants are not yet implemented: switching
any of them on causes dcm_estimate to stop with an informative error.
These variants are planned for a future update. Non-linear DCM (a non-empty
d array) is supported.
dcm_nlsi_GN for the underlying inversion,
dcm_fmri_priors for the priors it constructs.
data(toy_dcm) str(toy_dcm, max.level = 1) # Full inversion of the bundled three-region model (takes about a minute). # Progress reporting goes through message(), so it can be silenced. fit <- suppressMessages(dcm_estimate(toy_dcm)) round(fit$Ep$A, 3) # posterior connectivity estimates round(fit$Pp$A, 3) # posterior probability each connection is non-zero fit$F # negative free energy, for model comparisondata(toy_dcm) str(toy_dcm, max.level = 1) # Full inversion of the bundled three-region model (takes about a minute). # Progress reporting goes through message(), so it can be silenced. fit <- suppressMessages(dcm_estimate(toy_dcm)) round(fit$Ep$A, 3) # posterior connectivity estimates round(fit$Pp$A, 3) # posterior probability each connection is non-zero fit$F # negative free energy, for model comparison
AIC and BIC penalties for an estimated DCM, plus per-region cost terms.
Mirrors SPM25's spm_dcm_evidence.
dcm_evidence(DCM)dcm_evidence(DCM)
DCM |
An estimated DCM. |
List with per-region cost, AIC penalty, BIC penalty, and overall AIC and BIC.
Builds the prior expectations pE and prior covariance pC
for a deterministic fMRI DCM. Mirrors SPM25's dcm_fmri_priors.
dcm_fmri_priors(A, B, C, D, options = list())dcm_fmri_priors(A, B, C, D, options = list())
A |
Connectivity adjacency matrix. |
B |
Modulatory adjacency array. |
C |
Driving-input adjacency matrix. |
D |
Non-linear adjacency array. |
options |
List of model options ( |
List with pE (prior expectation), x (initial state
template), and pC (prior covariance).
Only the deterministic, single-state model is supported end-to-end in this
release. Branches for the two-state (options$two_state) and spectral
(options$induced) variants exist but are experimental and are not
wired through dcm_estimate, which rejects them. They are
planned for a future update.
dcm_estimate, which builds these priors for you.
# Priors for the bundled three-region (deterministic) model data(toy_dcm) pr <- dcm_fmri_priors(toy_dcm$a, toy_dcm$b, toy_dcm$c, D = NULL, options = toy_dcm$options) names(pr) pr$pE$A # prior expectation of the endogenous connections dim(pr$x) # 3 regions x 5 hemodynamic states# Priors for the bundled three-region (deterministic) model data(toy_dcm) pr <- dcm_fmri_priors(toy_dcm$a, toy_dcm$b, toy_dcm$c, D = NULL, options = toy_dcm$options) names(pr) pr$pE$A # prior expectation of the endogenous connections dim(pr$x) # 3 regions x 5 hemodynamic states
Computes dx/dt for the bilinear neural state equation coupled to
the Buxton-Friston hemodynamic model. Mirrors SPM25's spm_fx_fmri.
dcm_fx_fmri(x, u, P, M)dcm_fx_fmri(x, u, P, M)
x |
State matrix (rows = regions, cols = state variables). |
u |
Driving inputs at the current time. |
P |
List of model parameters ( |
M |
Model structure list (optional). |
Matrix dx/dt of the same shape as x.
Computes the BOLD signal from the hemodynamic state variables. Mirrors
SPM25's spm_gx_fmri.
dcm_gx_fmri(x, u, P, M)dcm_gx_fmri(x, u, P, M)
x |
State matrix (rows = regions, cols = state variables). |
u |
Driving inputs at the current time. |
P |
List of model parameters ( |
M |
Model structure list (optional). |
List with the BOLD prediction g and Jacobian dgdx.
Forward-integrates the model defined by M$f (state equation) and
M$g (observation equation) under the input U, returning the
predicted observations at the requested sample points.
dcm_int(P, M, U)dcm_int(P, M, U)
P |
Parameter structure. |
M |
Model list. Required fields: |
U |
List with input matrix |
M$f and M$g may be given as functions or as the names of
functions. M$n must be the length of the flattened state
(length(dcm_vec(M$x)), i.e. regions x hidden states), while
M$l is the number of observed outputs (regions) and M$m
the number of inputs.
Numeric matrix of predicted observations (rows = samples).
dcm_estimate, which calls this as its forward model.
# Simulate the BOLD response of a two-region model to a boxcar input. n <- 2L pri <- dcm_fmri_priors(A = matrix(1, n, n), B = array(0, c(n, n, 1)), C = matrix(c(1, 0), n, 1), D = array(0, c(n, n, 0)), options = list()) U <- list(u = matrix(c(rep(1, 16), rep(0, 16)), ncol = 1), dt = 1) M <- list(f = "dcm_fx_fmri", g = "dcm_gx_fmri", x = pri$x, m = ncol(U$u), n = length(pri$x), l = nrow(pri$x), ns = 32) # The priors put C at zero, so start from them and switch on a driving # input to region 1 and a connection from region 1 to region 2. P <- pri$pE P$C[1, 1] <- 1 P$A[2, 1] <- 0.4 y <- dcm_int(P, M, U) dim(y) # 32 samples x 2 regions round(y[seq(1, 32, 4), ], 3)# Simulate the BOLD response of a two-region model to a boxcar input. n <- 2L pri <- dcm_fmri_priors(A = matrix(1, n, n), B = array(0, c(n, n, 1)), C = matrix(c(1, 0), n, 1), D = array(0, c(n, n, 0)), options = list()) U <- list(u = matrix(c(rep(1, 16), rep(0, 16)), ncol = 1), dt = 1) M <- list(f = "dcm_fx_fmri", g = "dcm_gx_fmri", x = pri$x, m = ncol(U$u), n = length(pri$x), l = nrow(pri$x), ns = 32) # The priors put C at zero, so start from them and switch on a driving # input to region 1 and a connection from region 1 to region 2. P <- pri$pE P$C[1, 1] <- 1 P$A[2, 1] <- 0.4 y <- dcm_int(P, M, U) dim(y) # 32 samples x 2 regions round(y[seq(1, 32, 4), ], 3)
Performs Gauss-Newton optimisation of the variational free energy for a
non-linear forward model with Gaussian priors. Mirrors SPM25's
dcm_nlsi_GN.
dcm_nlsi_GN(M, U, Y)dcm_nlsi_GN(M, U, Y)
M |
Model specification (list with |
U |
Input structure passed through to |
Y |
Data (or list with |
Most users should call dcm_estimate instead, which assembles
M, U and Y from a DCM specification and calls this
function. Use dcm_nlsi_GN directly only to invert a non-linear
model that is not an fMRI DCM.
Progress is reported per Gauss-Newton iteration as
EM:(+) k F: ..., where (+) marks an accepted step and
(-) a rejected one. Set M$noprint <- 1 to silence it.
List with posterior expectation Ep, covariance Cp,
log-precision estimate Eh, free energy F, and components.
dcm_estimate for the user-facing entry point.
# dcm_nlsi_GN is the Gauss-Newton optimiser that dcm_estimate() calls after # assembling M, U and Y from a DCM specification. For a runnable inversion # see the example in ?dcm_estimate; dcm_nlsi_GN returns the same posterior # fields (Ep, Cp, Eh, F).# dcm_nlsi_GN is the Gauss-Newton optimiser that dcm_estimate() calls after # assembling M, U and Y from a DCM specification. For a runnable inversion # see the example in ?dcm_estimate; dcm_nlsi_GN returns the same posterior # fields (Ep, Cp, Eh, F).
Loads subject PEBs (.rds or .mat), builds the third-level
design, runs the PEB-of-PEBs, and returns a tidy summary. Optionally saves
the group PEB.
dcm_peb_of_pebs( peb_dir, subjects = NULL, covariates = NULL, Xnames = NULL, save_path = NULL, M = list(Q = "single", alpha = 1, beta = 16, maxit = 64), field = "all", verbose = TRUE )dcm_peb_of_pebs( peb_dir, subjects = NULL, covariates = NULL, Xnames = NULL, save_path = NULL, M = list(Q = "single", alpha = 1, beta = 16, maxit = 64), field = "all", verbose = TRUE )
peb_dir |
Directory containing the subject PEB files. |
subjects |
Optional integer vector; restrict to these subject numbers. |
covariates |
Optional data frame of between-subject covariates, one row
per subject in the order returned by |
Xnames |
Optional custom design column names. |
save_path |
Optional path to save the group PEB to, as |
M |
Third-level model options passed to |
field |
Parameter blocks to model; |
verbose |
Logical. Report progress via |
Nothing is written to disk unless save_path is supplied.
List with group_PEB, save_path (NULL if not
saved), subjects, X (the design), and summary (a tidy
data frame of parameter estimates).
Gathers the first-level posterior densities, selects the parameter indices
implied by field, projects them onto a rank-reduced subspace, and
builds the second-level priors, hyperpriors and precision components.
Mirrors the preparation half of SPM25's spm_dcm_peb.
dcm_peb_prepare(P, M = list(), field = c("A", "B"))dcm_peb_prepare(P, M = list(), field = c("A", "B"))
P |
List of estimated DCMs (or, for a PEB-of-PEBs, a list of PEBs).
Each element must carry |
M |
Second-level model specification. Recognised fields: |
field |
Character vector of parameter blocks to model (e.g.
|
M$Q selects the form of the second-level precision components:
"single" (one component, the default), "fields" (one per
requested field), "all" (one per parameter), "none" (no
components), or a list of numeric matrices for manual specification.
A list ("prep") consumed by dcm_peb_run, holding the
projected densities, design, priors, precision components and sizes.
dcm_peb_run to fit the prepared model.
Runs the variational Laplace (Fisher scoring) loop on the structure built by
dcm_peb_prepare, and returns the group-level PEB together with
the first-level DCMs updated under the empirical priors. Mirrors the
estimation half of SPM25's spm_dcm_peb.
dcm_peb_run(prep, verbose = TRUE)dcm_peb_run(prep, verbose = TRUE)
prep |
The list returned by |
verbose |
Logical. Report free energy per iteration via
|
Progress is reported as VL Iter k: F=... dF=... [t=...], where
t is the log step size of the Fisher scoring update. The loop stops
when the step size collapses or the free-energy increase falls below 1e-4.
List with two elements: PEB, the group-level result
(Ep group parameter expectations, Cp their covariance,
Eh/Ch log-precision estimates, F free energy, and the
Pnames/Xnames/Snames labels), and P, the input
DCMs with Ep, Cp, M$pE, M$pC and F
updated under the empirical priors.
dcm_peb_prepare, dcm_peb_of_pebs.
Subject-level DCM posterior summaries for 48 subjects, used to demonstrate
the robust and sparse group-level model rsdcm. The summaries
are the inputs a group analysis needs: a posterior mean and covariance per
subject.
narps_dcmnarps_dcm
A list with:
48 x 22 matrix of subject-level posterior means (subjects in rows, parameters in columns).
Length-48 list of 22 x 22 posterior covariance matrices.
Length-22 character vector, e.g. "A(1,1)",
"B(2,1,1)".
Length-48 character vector of de-identified subject ids.
Data frame of between-subject covariates: group,
gender, age.
The four region labels, in order.
Each subject has 22 parameters: the 16 intrinsic connections of a four-region DCM (A) plus 6 task-modulatory connections (B), across the regions vmPFC, vStr (ventral striatum), amygdala, and anterior insula.
Subject-level Dynamic Causal Modelling summaries computed by the
package author from the openly shared NARPS dataset: Botvinik-Nezer, R.,
Holzmeister, F., Camerer, C. F., et al. (2020), "Variability in the
analysis of a single neuroimaging dataset by many teams", Nature,
582(7810), 84-88, doi:10.1038/s41586-020-2314-9. The build script that
prepared the shipped object is in data-raw/make-narps-dcm.R.
rsdcm, which this dataset is the example
input for.
data(narps_dcm) dim(narps_dcm$eta) # 48 subjects x 22 parameters length(narps_dcm$Cp) # one posterior covariance per subject table(narps_dcm$covariates$group)data(narps_dcm) dim(narps_dcm$eta) # 48 subjects x 22 parameters length(narps_dcm$Cp) # one posterior covariance per subject table(narps_dcm$covariates$group)
Fits a group-level model to subject-level DCM parameter estimates that is robust to outlier subjects and performs Bayesian variable selection on the group effects. The model combines three ingredients: Student-t weighting of subjects (robustness), a nonlocal product-moment (pMOM) spike-and-slab prior on the group effects (sparsity / inclusion probabilities), and ReML-estimated between-subject variance components. Estimation is by EM.
rsdcm( eta_theta_y, C_theta_y_list, X_G, V_list, nu = 3, tau0 = 0.05, tau1 = 1, pi = 0.5, a0 = 2, b0 = 0.01, a1 = 2, b1 = 1, min_slab_spike_ratio = 1, max_iter = 500, tol = 1e-06, inner_sweeps = 3, verbose = TRUE, max_beta_step = 1, min_alpha = 1e-08, max_alpha = 100 )rsdcm( eta_theta_y, C_theta_y_list, X_G, V_list, nu = 3, tau0 = 0.05, tau1 = 1, pi = 0.5, a0 = 2, b0 = 0.01, a1 = 2, b1 = 1, min_slab_spike_ratio = 1, max_iter = 500, tol = 1e-06, inner_sweeps = 3, verbose = TRUE, max_beta_step = 1, min_alpha = 1e-08, max_alpha = 100 )
eta_theta_y |
N x p matrix of subject-level posterior means (subjects in rows, parameters in columns). |
C_theta_y_list |
Length-N list of p x p subject-level posterior covariance matrices. |
X_G |
N x r group (between-subject) design matrix. |
V_list |
List of p x p basis matrices for the between-subject
covariance |
nu |
Student-t degrees of freedom (smaller = heavier-tailed, more robust). |
tau0, tau1
|
Initial spike and slab standard deviations. |
pi |
Prior inclusion probability (slab weight). |
a0, b0, a1, b1
|
Inverse-Gamma hyperprior parameters on |
min_slab_spike_ratio |
Identifiability guard: enforce
|
max_iter |
Maximum EM iterations. |
tol |
Convergence tolerance on the change in |
inner_sweeps |
Coordinate-Newton sweeps per M-step for |
verbose |
Logical. Report progress via |
max_beta_step |
Per-coordinate cap on the |
min_alpha, max_alpha
|
Bounds on the variance components. |
This is an alternative to the Gaussian Parametric Empirical Bayes layer
(dcm_peb_run); the numerics are original to the package, not a
port of SPM. Most users will call the convenience wrapper
rsdcm_fit, which assembles the arguments below from a
list of fitted DCMs.
A list with the group-level effects beta_mat (p x r) and
beta_vec, posterior inclusion probabilities inclusion
(p x r), Student-t weights, variance components alpha,
learned scales tau0/tau1, residual variance sigma2,
fitted means mu_hat (N x p), and the sizes N, p,
r.
Arhin, G., Sanyal, N. (2026). Robust and sparse group dynamic causal modeling via Student-t parametric empirical Bayes and nonlocal priors. arXiv:2609.06379. doi:10.48550/arXiv.2609.06379
rsdcm_fit for the wrapper over fitted DCMs,
dcm_peb_run for the Gaussian PEB alternative,
narps_dcm for the example dataset.
# Real 48-subject NARPS group analysis. The inputs are precomputed # subject-level DCM summaries (a posterior mean and covariance per subject). data(narps_dcm) N <- nrow(narps_dcm$eta) p <- ncol(narps_dcm$eta) # Per-parameter variance-component basis, and an intercept-only design. V_list <- lapply(seq_len(p), function(k) { V <- matrix(0, p, p); V[k, k] <- 1; V }) X_G <- matrix(1, N, 1, dimnames = list(NULL, "intercept")) fit <- rsdcm(narps_dcm$eta, narps_dcm$Cp, X_G, V_list, verbose = FALSE) rownames(fit$beta_mat) <- rownames(fit$inclusion) <- narps_dcm$parameter_names # Group-level connections selected by the spike-and-slab prior (PIP > 0.5) sel <- fit$inclusion[, 1] > 0.5 round(cbind(estimate = fit$beta_mat[sel, 1], PIP = fit$inclusion[sel, 1]), 3) # Subjects the Student-t weighting down-weights most w <- rowMeans(matrix(fit$weights, N, p, byrow = TRUE)) narps_dcm$subject[order(w)][1:5]# Real 48-subject NARPS group analysis. The inputs are precomputed # subject-level DCM summaries (a posterior mean and covariance per subject). data(narps_dcm) N <- nrow(narps_dcm$eta) p <- ncol(narps_dcm$eta) # Per-parameter variance-component basis, and an intercept-only design. V_list <- lapply(seq_len(p), function(k) { V <- matrix(0, p, p); V[k, k] <- 1; V }) X_G <- matrix(1, N, 1, dimnames = list(NULL, "intercept")) fit <- rsdcm(narps_dcm$eta, narps_dcm$Cp, X_G, V_list, verbose = FALSE) rownames(fit$beta_mat) <- rownames(fit$inclusion) <- narps_dcm$parameter_names # Group-level connections selected by the spike-and-slab prior (PIP > 0.5) sel <- fit$inclusion[, 1] > 0.5 round(cbind(estimate = fit$beta_mat[sel, 1], PIP = fit$inclusion[sel, 1]), 3) # Subjects the Student-t weighting down-weights most w <- rowMeans(matrix(fit$weights, N, p, byrow = TRUE)) narps_dcm$subject[order(w)][1:5]
Convenience wrapper around rsdcm that assembles its
inputs from a list of estimated DCMs (as returned by
dcm_estimate). For each subject it takes the posterior mean
Ep and covariance Cp restricted to the requested parameter
field, builds a between-subject design, and fits the robust + sparse group
model.
rsdcm_fit(P, field = "A", covariates = NULL, X_G = NULL, V_list = NULL, ...)rsdcm_fit(P, field = "A", covariates = NULL, X_G = NULL, V_list = NULL, ...)
P |
List of estimated DCMs; each must carry |
field |
Parameter block(s) to model at the group level, named as in the
DCM parameter structure |
covariates |
Optional data frame of between-subject covariates, one row
per subject; |
X_G |
Optional group design matrix (N x r); overrides |
V_list |
Optional list of p x p variance-component bases; defaults to a per-parameter diagonal basis. |
... |
Further arguments passed to |
All subjects must share the same parameterisation, so the selected field
indices are required to match across P.
The list returned by rsdcm, with the group
effects and inclusion probabilities labelled by the selected parameters and
design columns, plus the selected param_index.
rsdcm, dcm_estimate,
dcm_peb_design.
# rsdcm_fit() consumes a list of fitted DCMs (each from dcm_estimate), then # fits the group model on a chosen field: # fits <- lapply(dcm_files, function(f) dcm_estimate(readRDS(f))) # grp <- rsdcm_fit(fits, field = "A", covariates = my_covariates) # For a runnable group-level example on precomputed subject summaries, see # ?rsdcm and the narps_dcm dataset.# rsdcm_fit() consumes a list of fitted DCMs (each from dcm_estimate), then # fits the group model on a chosen field: # fits <- lapply(dcm_files, function(f) dcm_estimate(readRDS(f))) # grp <- rsdcm_fit(fits, field = "A", covariates = my_covariates) # For a runnable group-level example on precomputed subject summaries, see # ?rsdcm and the narps_dcm dataset.
Read or modify package-internal numerical options. Currently the only
option is GLOBAL_DX, the finite-difference step used by
dcm_diff when computing numerical Jacobians.
rsdcm_options(...)rsdcm_options(...)
... |
Named arguments to set. Call with no arguments to retrieve the current option list. |
The current option list (invisibly when setting).
rsdcm_options() # show current options rsdcm_options(GLOBAL_DX = 1e-4) # widen the FD step rsdcm_options(GLOBAL_DX = exp(-8)) # restore defaultrsdcm_options() # show current options rsdcm_options(GLOBAL_DX = 1e-4) # widen the FD step rsdcm_options(GLOBAL_DX = exp(-8)) # restore default
A three-region Dynamic Causal Model used in the documentation, vignette,
and tests. It is an input specification (no posterior fields), ready to
invert with dcm_estimate.
toy_dcmtoy_dcm
A list with the standard SPM-style DCM fields:
3 x 3 binary matrix of endogenous connections to estimate.
3 x 3 x 1 binary array of modulatory connections.
3 x 1 binary matrix of driving inputs; here the input enters region 3 only.
Observed BOLD data. Y$y is the 482 x 3 time-series
matrix (rows = scans, columns = regions); Y$dt is the
sampling interval in seconds; Y$X0 is the confound design;
Y$Q is the error-covariance component list; Y$name
holds the region names.
Input design. U$u is the 482 x 1 input matrix at the
microtime resolution; U$dt is the microtime step;
U$name holds the input names.
Number of regions (3) and number of scans (482).
Echo time in seconds.
Name of the model.
Region (VOI) structure carried over from the source DCM.
Estimation options: nonlinear, two_state,
stochastic, centre, mode, maxit,
induced, maxnodes, hE, hC.
The model has 3 regions and 482 scans, with a single driving input
entering region 3 and a single modulatory input. All entries of the
a matrix are enabled, so every directed connection between the
three regions is estimated.
Derived from the fMRI data of Valerio et al. (2025), "Neural and
behavioral similarity-driven tuning curves for manipulable objects",
Imaging Neuroscience, 3, doi:10.1162/imag_a_00482, via a Dynamic Causal
Modelling exercise carried out with that data during package development.
The build script that prepared the shipped object is in
data-raw/make-toy-dcm.R. See the package CITATION for the
full author list.
data(toy_dcm) str(toy_dcm, max.level = 1) # Invert it with dcm_estimate(toy_dcm); see ?dcm_estimate for a runnable # (donttest) inversion example.data(toy_dcm) str(toy_dcm, max.level = 1) # Invert it with dcm_estimate(toy_dcm); see ?dcm_estimate for a runnable # (donttest) inversion example.