## ----include = FALSE---------------------------------------------------------- knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.width = 6, fig.height = 4 ) ## ----setup-------------------------------------------------------------------- library(rsDCM) ## ----------------------------------------------------------------------------- data(toy_dcm) str(toy_dcm, max.level = 1) c(regions = toy_dcm$n, scans = toy_dcm$v) ## ----fig.alt = "Simulated BOLD response of two regions 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) P <- pri$pE P$C[1, 1] <- 1 # input drives region 1 P$A[2, 1] <- 0.4 # region 1 -> region 2 y <- dcm_int(P, M, U) matplot(y, type = "l", lty = 1, xlab = "scan", ylab = "BOLD", main = "Simulated response to a boxcar input") legend("topright", c("region 1", "region 2"), lty = 1, col = 1:2, bty = "n") ## ----eval = FALSE------------------------------------------------------------- # fit <- dcm_estimate(toy_dcm) ## ----eval = FALSE------------------------------------------------------------- # round(fit$Ep$A, 3) # estimated connectivity # fit$F # log-evidence ## ----eval = FALSE------------------------------------------------------------- # ev <- dcm_evidence(fit) # ev$aic_overall # ev$bic_overall ## ----------------------------------------------------------------------------- rsdcm_options()$GLOBAL_DX