API reference

RegressionDynamicCausalModelingModule
RegressionDynamicCausalModeling

A Julia package for estimating whole-brain effective connectivity using the regression dynamic causal modeling (rDCM) framework.

The alias rDCM is exported for the package name.

source

DCMs

RegressionDynamicCausalModeling.LinearDCMType
mutable struct LinearDCM <: DCM

Representation of a linear DCM.

Fields

  • a::BitMatrix: Binary indicator matrix for endogenous connectivity

  • c::BitMatrix: Binary indicator matrix for driving inputs

  • scans::Int64: number of data points per region

  • nr::Int64

  • U::Union{Nothing, InputU}: input structure with information about driving input

  • Y::Union{Nothing, BoldY}: data structure containing BOLD signal

  • Ep::RegressionDynamicCausalModeling.TrueParamLinear: connectivity parameters (A and C matrix)

  • Conf::Union{Nothing, Confound}: confound structure

source
RegressionDynamicCausalModeling.LinearDCMMethod
LinearDCM(
    a::Array{T1<:Number, 2},
    c::Array{T2<:Number, 2},
    scans::Int64,
    nr::Int64,
    U::Union{Nothing, InputU},
    Y::Union{Nothing, BoldY},
    Ep::RegressionDynamicCausalModeling.TrueParamLinear
) -> LinearDCM

Create linear DCM.

Arguments

  • a::Matrix: Binary indicator matrix for endogenous connectivity
  • c::Matrix: Binary indicator matrix for driving inputs
  • scans::Int64: Number of data points per region
  • nr::Int64: Number of regions
  • U::InputU: Input structure
  • Y::Union{BoldY,Nothing}: Data structure containing BOLD signal, can be nothing
  • EP::TrueParamLinear: Connectivity parameters containing A and C matrix
source
RegressionDynamicCausalModeling.BiLinearDCMType
mutable struct BiLinearDCM <: DCM

Represenetation of a bi-linear DCM.

Fields

  • a::BitMatrix: Binary indicator matrix for endogenous connectivity

  • b::BitArray{3}: Binary indicator matrix for bi-linear dynamics.

  • c::BitMatrix: Binary indicator matrix for driving inputs

  • scans::Int64: number of data points per region

  • nr::Int64

  • U::Union{Nothing, InputU}: input structure with information about driving input

  • Y::Union{Nothing, BoldY}: data structure containing BOLD signal

  • Ep::RegressionDynamicCausalModeling.TrueParamBiLinear: connectivity parameters (A, B and C matrix)

  • Conf::Union{Nothing, Confound}: confound structure

Warning

While this package allows to simulate data for bi-linear DCMs, the current rDCM implementation can only invert linear DCMs.

source
RegressionDynamicCausalModeling.NonLinearDCMType
mutable struct NonLinearDCM <: DCM

Representation of a non-linear DCM.

Fields

  • a::BitMatrix: Binary indicator matrix for endogenous connectivity

  • b::BitArray{3}: Binary indicator matrix for bi-linear dynamics.

  • c::BitMatrix: Binary indicator matrix for driving inputs

  • d::BitArray{3}: Binary indicator matrix for non-linear dynamics

  • scans::Int64: number of data points per region

  • nr::Int64

  • U::Union{Nothing, InputU}: input structure with information about driving input

  • Y::Union{Nothing, BoldY}: data structure containing BOLD signal

  • Ep::RegressionDynamicCausalModeling.TrueParamNonLinear: connectivity parameters (A, B, C and D matrix)

  • Conf::Union{Nothing, Confound}: confound structure

Warning

While this package allows to simulate data for non-linear DCMs, the current rDCM implementation can only invert linear DCMs.

source
RegressionDynamicCausalModeling.BoldYType
mutable struct BoldY

Struct for BOLD signal.

Fields

  • y::Union{Nothing, Matrix{Float64}}: BOLD signal

  • dt::Float64: Sampling interval

  • name::Union{Nothing, Vector{String}}: Brain region names

source
RegressionDynamicCausalModeling.ConfoundType
struct Confound

Information about confounds.

Fields

  • X0::VecOrMat{Float64}: Confound matrix of size number of datapoints times number of confounds.

  • name::Vector{String}: Confound names

source

rDCMs

RegressionDynamicCausalModeling.RigidRdcmType
mutable struct RigidRdcm <: RDCM

Representation of an rDCM with fixed network architecture.

Fields

  • a::BitMatrix: Binary indicator matrix for endogenous connectivity

  • c::BitMatrix: Binary indicator matrix for driving inputs

  • scans::Int64: Number of data points per region

  • nr::Int64

  • U::InputU: Input structure with information about driving input

  • Y::BoldY: Data structure containing BOLD signal

  • Ep::RegressionDynamicCausalModeling.TrueParamLinear: Connectivity parameters (A and C matrix)

  • Conf::Confound: Confound structure

  • hrf::Vector{Float64}: Hemodynamic response function

source
RegressionDynamicCausalModeling.RigidOutputType
struct RigidOutput <: RegressionDynamicCausalModeling.ModelOutput

Ouput after inversion of RigidRdcm.

Fields

  • F::Float64: Negative free energy of the whole model

  • F_r::Vector{Float64}: Region specific negative free energy

  • iter_all::Vector{Int64}: Number of iterations per region until convergence

  • a_all::Vector{Float64}: Posterior shape parameter for noise

  • b_all::Vector{Float64}: Posterior rate parameter for noise

  • m_all::Matrix{Float64}: Posterior mean for connectivity parameters

  • Σ_all::Vector{SparseArrays.SparseMatrixCSC{Float64, Int64}}: Posterior covariance for connectivity parameters

  • inversion::String: Inversion method

source
RegressionDynamicCausalModeling.SparseRdcmType
mutable struct SparseRdcm <: RDCM

Representation of a sparse rDCM (sparsity constraints on network architecture).

Fields

  • a::BitMatrix: Binary indicator matrix for endogenous connectivity

  • c::BitMatrix: Binary indicator matrix for driving inputs

  • scans::Int64: Number of data points per region

  • nr::Int64

  • U::InputU: Input structure with information about driving input

  • Y::BoldY: Data structure containing BOLD signal

  • Ep::RegressionDynamicCausalModeling.TrueParamLinear: Connectivity parameters (A and C matrix)

  • Conf::Confound: Confound structure

  • hrf::Vector{Float64}: Hemodynamic response function

  • inform_p0::Bool: Inform region specific sparseness (e.g., by anatomical information)

  • p0::Float64: Prior belief about network sparseness

source
RegressionDynamicCausalModeling.SparseRdcmMethod
SparseRdcm(dcm::LinearDCM; inform_p0, p0) -> SparseRdcm

Construct a SparseRdcm based on a linear DCM.

Arguments

  • dcm: DCM model
  • inform_p0::Bool: Inform region specific sparseness (e.g., by anatomical information)
  • p0::Float64: Prior belief about network sparseness
source
RegressionDynamicCausalModeling.SparseOutputType
struct SparseOutput <: RegressionDynamicCausalModeling.ModelOutput

Ouput after inversion of SparseRdcm.

Fields

  • F::Float64: Negative free energy of the whole model

  • F_r::Vector{Float64}: Region specific negative free energy

  • iter_all::Vector{Int64}: Number of iterations per region until convergence

  • a_all::Vector{Float64}: Posterior shape parameter for noise

  • b_all::Vector{Float64}: Posterior rate parameter for noise

  • m_all::Matrix{Float64}: Posterior mean for connectivity parameters

  • Σ_all::Vector{SparseArrays.SparseMatrixCSC{Float64, Int64}}: Posterior covariance for connectivity parameters

  • z_all::Matrix{Float64}: Posterior for binary indicator variables

  • inversion::String: Inversion method

source

Load and export DCMs

RegressionDynamicCausalModeling.load_DCMFunction
load_DCM(path::String;verbose=true)

Load a DCM from a specified path and return either a linear, bilinear or nonlinear DCM based on the contents of the file.

Arguments

  • path::String: Path to the file to load. Can end with .mat for Matlab files or .jls for data serialized by Julia.
  • verbose::Bool: Verbosity

Output

  • dcm: DCM struct (can be a linear, bilinear on nonlinear DCM)

Examples

julia> dcm = load_DCM("myDCM.jls";verbose=false)
source
RegressionDynamicCausalModeling.save_DCMFunction
save_DCM(path, dcm)

Save a DCM struct either as .mat or .jls file.

Arguments

  • path::String: Path defining where to save file. If ends with .mat -> saves as Matlab file. If ends with .jls -> Serializes using Julias Serialization.
  • dcm<:DCM: DCM struct (can be a linear, bilinear on nonlinear DCM)

Examples

julia> save_DCM("./myDCM.mat",dcm)
source
RegressionDynamicCausalModeling.export_to_SPMFunction
export_to_SPM(path, rdcm, output)

Export a DCM with output after model inversion as an SPM compatible .mat file.

Arguments

  • path::String: Path defining where to save file. Needs to end with .mat
  • rdcm::RigidRdcm: An rDCM model.
  • output::RigidOutput: Output after model inversion.

Examples

julia> export_to_SPM("DCM.mat",rdcm,output)
Info

See SPM compatibility for limitations of this functionality.

source

Data generation

RegressionDynamicCausalModeling.generate_BOLDFunction
generate_BOLD(dcm; SNR, TR=NaN, rng=Xoshiro())

Generate synthetic BOLD signal timeseries based on a DCM.

Arguments

  • dcm::T where T <: DCM: DCM structure (can be a linear, bilinear on nonlinear DCM)
  • SNR::Real: Signal to noise ratio
  • TR::Real: Sampling interval in seconds (can be omitted if dt is specified in dcm.Y)
  • rng::AbstractRNG: Random number generator for noise sampling.

Output

  • y_noise::Matrix{Float64}: BOLD signal timeseries with noise
  • y::Matrix{Float64}: BOLD signal timeseries without noise
  • x::Matrix{Float64}: Neuronal signal
  • h::Vector{Float64}: Hemodynamic response function

Examples

julia> y_noise, y, x, h = generate_BOLD(load_example_DCM();SNR=10)
source
RegressionDynamicCausalModeling.predictFunction
predict(
    rdcm::RDCM,
    output::RegressionDynamicCausalModeling.ModelOutput
) -> Any

Predict BOLD signal based on parameter estimates after model inversion.

Arguments

  • rdcm: rDCM struct that was used to estimate parameters.
  • output: Output of model inversion.

Output

  • y_pred::Matrix{Float64}: predicted BOLD signal
Warning

The predicted signal is generated by integrating a linear DCM based on the estimated parameters. Therefore, it is not possible to generate predictions for resting-state fMRI since there is no driving input that would elicit activity.

source

Model inversion

RegressionDynamicCausalModeling.RigidInversionParamsType
struct RigidInversionParams <: RegressionDynamicCausalModeling.AbstractInvParam

Settings for model inversion specific to rigid rDCM (fixed network architecture).

Fields

  • maxIter::Int64: Maximum number of iterations per region

  • tol::Float64: Tolerance for convergence

source
RegressionDynamicCausalModeling.SparseInversionParamsType
struct SparseInversionParams <: RegressionDynamicCausalModeling.AbstractInvParam

Settings for model inversion specific to sparse rDCM.

Fields

  • maxIter::Int64: Maximum number of iterations per region

  • tol::Float64: Tolerance for convergence

  • reruns::Int64: Number of reruns

  • restrictInputs::Bool: Whether or not to estimate sparsity for C matrix. If true, the Bernoulli posteriors for the C matrix are not pruned.

source
RegressionDynamicCausalModeling.OptionsType
struct Options{T<:RegressionDynamicCausalModeling.AbstractInvParam}

Settings for model inversion.

Fields

  • invParams::RegressionDynamicCausalModeling.AbstractInvParam: Model specific inversion settings.

  • verbose::Int64: Verbosity during inversion (0,1 or 2)

  • synthetic::Bool: Whether or not synthetic data is used.

  • testing::Bool: Used for testing

  • rng::Random.AbstractRNG: Random number generator

source
RegressionDynamicCausalModeling.invertFunction
invert(rdcm::RigidRdcm, opt::Options) -> RigidOutput

Invert an rDCM model specified by rdcm with fixed network architecture using specific inversion settings defined in opt.

source
invert(rdcm::SparseRdcm, opt::Options) -> SparseOutput

Invert a sparse rDCM model specified by rdcm using specific inversion settings defined in opt.

source

Index