API reference
RegressionDynamicCausalModeling
— ModuleRegressionDynamicCausalModeling
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.
DCMs
RegressionDynamicCausalModeling.DCM
— TypeDCM
Abstract supertype for a DCM.
RegressionDynamicCausalModeling.LinearDCM
— Typemutable struct LinearDCM <: DCM
Representation of a linear DCM.
Fields
a::BitMatrix
: Binary indicator matrix for endogenous connectivityc::BitMatrix
: Binary indicator matrix for driving inputsscans::Int64
: number of data points per regionnr::Int64
U::Union{Nothing, InputU}
: input structure with information about driving inputY::Union{Nothing, BoldY}
: data structure containing BOLD signalEp::RegressionDynamicCausalModeling.TrueParamLinear
: connectivity parameters (A and C matrix)Conf::Union{Nothing, Confound}
: confound structure
RegressionDynamicCausalModeling.LinearDCM
— MethodLinearDCM(a, c, scans, nr, U, Y, Ep, Conf)
Constructor with sanity checks for LinearDCM
. See type description for information about arguments.
RegressionDynamicCausalModeling.LinearDCM
— MethodLinearDCM(
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 connectivityc::Matrix
: Binary indicator matrix for driving inputsscans::Int64
: Number of data points per regionnr::Int64
: Number of regionsU::InputU
: Input structureY::Union{BoldY,Nothing}
: Data structure containing BOLD signal, can be nothingEP::TrueParamLinear
: Connectivity parameters containing A and C matrix
RegressionDynamicCausalModeling.LinearDCM
— MethodLinearDCM(dcm::DCM) -> LinearDCM
Create linear DCM from a bilinear or nonlinear DCM dcm
.
RegressionDynamicCausalModeling.LinearDCM
— MethodLinearDCM(
rdcm::RDCM,
output::RegressionDynamicCausalModeling.ModelOutput
) -> LinearDCM
Create linear DCM from an rDCM structure rdcm
and output from model inversion output
.
RegressionDynamicCausalModeling.BiLinearDCM
— Typemutable struct BiLinearDCM <: DCM
Represenetation of a bi-linear DCM.
Fields
a::BitMatrix
: Binary indicator matrix for endogenous connectivityb::BitArray{3}
: Binary indicator matrix for bi-linear dynamics.c::BitMatrix
: Binary indicator matrix for driving inputsscans::Int64
: number of data points per regionnr::Int64
U::Union{Nothing, InputU}
: input structure with information about driving inputY::Union{Nothing, BoldY}
: data structure containing BOLD signalEp::RegressionDynamicCausalModeling.TrueParamBiLinear
: connectivity parameters (A, B and C matrix)Conf::Union{Nothing, Confound}
: confound structure
While this package allows to simulate data for bi-linear DCMs, the current rDCM implementation can only invert linear DCMs.
RegressionDynamicCausalModeling.BiLinearDCM
— MethodBiLinearDCM(a, b, c, scans, nr, U, Y, Ep, Conf)
Constructor with sanity checks for BiLinearDCM
. See type description for information about arguments.
RegressionDynamicCausalModeling.NonLinearDCM
— Typemutable struct NonLinearDCM <: DCM
Representation of a non-linear DCM.
Fields
a::BitMatrix
: Binary indicator matrix for endogenous connectivityb::BitArray{3}
: Binary indicator matrix for bi-linear dynamics.c::BitMatrix
: Binary indicator matrix for driving inputsd::BitArray{3}
: Binary indicator matrix for non-linear dynamicsscans::Int64
: number of data points per regionnr::Int64
U::Union{Nothing, InputU}
: input structure with information about driving inputY::Union{Nothing, BoldY}
: data structure containing BOLD signalEp::RegressionDynamicCausalModeling.TrueParamNonLinear
: connectivity parameters (A, B, C and D matrix)Conf::Union{Nothing, Confound}
: confound structure
While this package allows to simulate data for non-linear DCMs, the current rDCM implementation can only invert linear DCMs.
RegressionDynamicCausalModeling.NonLinearDCM
— MethodNonLinearDCM(a, b, c, d, scans, nr, U, Y, Ep, Conf)
Constructor with sanity checks for NonLinearDCM
. See type description for information about arguments.
RegressionDynamicCausalModeling.InputU
— Typestruct InputU
Input structure for a DCM.
Fields
u::Matrix{Float64}
: Driving inputdt::Float64
: Sampling intervalname::Vector{String}
: Input names
RegressionDynamicCausalModeling.BoldY
— Typemutable struct BoldY
Struct for BOLD signal.
Fields
y::Union{Nothing, Matrix{Float64}}
: BOLD signaldt::Float64
: Sampling intervalname::Union{Nothing, Vector{String}}
: Brain region names
RegressionDynamicCausalModeling.Confound
— Typestruct Confound
Information about confounds.
Fields
X0::VecOrMat{Float64}
: Confound matrix of size number of datapoints times number of confounds.name::Vector{String}
: Confound names
rDCMs
RegressionDynamicCausalModeling.RDCM
— TypeRDCM
Abstract supertype for a rigid or sparse rDCM.
RegressionDynamicCausalModeling.RigidRdcm
— Typemutable struct RigidRdcm <: RDCM
Representation of an rDCM with fixed network architecture.
Fields
a::BitMatrix
: Binary indicator matrix for endogenous connectivityc::BitMatrix
: Binary indicator matrix for driving inputsscans::Int64
: Number of data points per regionnr::Int64
U::InputU
: Input structure with information about driving inputY::BoldY
: Data structure containing BOLD signalEp::RegressionDynamicCausalModeling.TrueParamLinear
: Connectivity parameters (A and C matrix)Conf::Confound
: Confound structurehrf::Vector{Float64}
: Hemodynamic response function
RegressionDynamicCausalModeling.RigidRdcm
— MethodRigidRdcm(a, c, scans, nr, U, Y, Ep, Conf, hrf)
Constructor with sanity checks for RigidRdcm
. See type description for information about arguments.
RegressionDynamicCausalModeling.RigidRdcm
— MethodRigidRdcm(dcm::LinearDCM) -> RigidRdcm
Construct a RigidRdcm
based on a linear DCM.
RegressionDynamicCausalModeling.RigidOutput
— Typestruct RigidOutput <: RegressionDynamicCausalModeling.ModelOutput
Ouput after inversion of RigidRdcm
.
Fields
F::Float64
: Negative free energy of the whole modelF_r::Vector{Float64}
: Region specific negative free energyiter_all::Vector{Int64}
: Number of iterations per region until convergencea_all::Vector{Float64}
: Posterior shape parameter for noiseb_all::Vector{Float64}
: Posterior rate parameter for noisem_all::Matrix{Float64}
: Posterior mean for connectivity parametersΣ_all::Vector{SparseArrays.SparseMatrixCSC{Float64, Int64}}
: Posterior covariance for connectivity parametersinversion::String
: Inversion method
RegressionDynamicCausalModeling.SparseRdcm
— Typemutable struct SparseRdcm <: RDCM
Representation of a sparse rDCM (sparsity constraints on network architecture).
Fields
a::BitMatrix
: Binary indicator matrix for endogenous connectivityc::BitMatrix
: Binary indicator matrix for driving inputsscans::Int64
: Number of data points per regionnr::Int64
U::InputU
: Input structure with information about driving inputY::BoldY
: Data structure containing BOLD signalEp::RegressionDynamicCausalModeling.TrueParamLinear
: Connectivity parameters (A and C matrix)Conf::Confound
: Confound structurehrf::Vector{Float64}
: Hemodynamic response functioninform_p0::Bool
: Inform region specific sparseness (e.g., by anatomical information)p0::Float64
: Prior belief about network sparseness
RegressionDynamicCausalModeling.SparseRdcm
— MethodSparseRdcm(
a,
c,
scans,
nr,
U,
Y,
Ep,
Conf,
hrf,
inform_p0,
p0
)
Constructor with sanity checks for SparseRdcm
. See type description for information about arguments.
RegressionDynamicCausalModeling.SparseRdcm
— MethodSparseRdcm(dcm::LinearDCM; inform_p0, p0) -> SparseRdcm
Construct a SparseRdcm
based on a linear DCM.
Arguments
dcm
: DCM modelinform_p0::Bool
: Inform region specific sparseness (e.g., by anatomical information)p0::Float64
: Prior belief about network sparseness
RegressionDynamicCausalModeling.SparseOutput
— Typestruct SparseOutput <: RegressionDynamicCausalModeling.ModelOutput
Ouput after inversion of SparseRdcm
.
Fields
F::Float64
: Negative free energy of the whole modelF_r::Vector{Float64}
: Region specific negative free energyiter_all::Vector{Int64}
: Number of iterations per region until convergencea_all::Vector{Float64}
: Posterior shape parameter for noiseb_all::Vector{Float64}
: Posterior rate parameter for noisem_all::Matrix{Float64}
: Posterior mean for connectivity parametersΣ_all::Vector{SparseArrays.SparseMatrixCSC{Float64, Int64}}
: Posterior covariance for connectivity parametersz_all::Matrix{Float64}
: Posterior for binary indicator variablesinversion::String
: Inversion method
Load and export DCMs
RegressionDynamicCausalModeling.load_DCM
— Functionload_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)
RegressionDynamicCausalModeling.save_DCM
— Functionsave_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)
RegressionDynamicCausalModeling.export_to_SPM
— Functionexport_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 .matrdcm::RigidRdcm
: An rDCM model.output::RigidOutput
: Output after model inversion.
Examples
julia> export_to_SPM("DCM.mat",rdcm,output)
See SPM compatibility for limitations of this functionality.
RegressionDynamicCausalModeling.load_example_DCM
— Functionload_example_DCM()
Loads an example DCM (linear DCM with 50 regions). The network architecture is based on the S50 structure introduced in Smith et al. (2011). Network modelling methods for FMRI. NeuroImage. This DCM can be used to generate synthetic data.
Examples
julia> dcm = load_example_DCM()
julia> y_noise, _, _, _ = generate_BOLD(dcm;SNR=10)
Data generation
RegressionDynamicCausalModeling.generate_BOLD
— Functiongenerate_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 ratioTR::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 noisey::Matrix{Float64}
: BOLD signal timeseries without noisex::Matrix{Float64}
: Neuronal signalh::Vector{Float64}
: Hemodynamic response function
Examples
julia> y_noise, y, x, h = generate_BOLD(load_example_DCM();SNR=10)
RegressionDynamicCausalModeling.predict
— Functionpredict(
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
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.
Model inversion
RegressionDynamicCausalModeling.RigidInversionParams
— Typestruct RigidInversionParams <: RegressionDynamicCausalModeling.AbstractInvParam
Settings for model inversion specific to rigid rDCM (fixed network architecture).
Fields
maxIter::Int64
: Maximum number of iterations per regiontol::Float64
: Tolerance for convergence
RegressionDynamicCausalModeling.RigidInversionParams
— MethodRigidInversionParams(; maxIter=500, tol=1.0e-5)
Constructor for RigidInversionParams
. See type description for information about arguments.
RegressionDynamicCausalModeling.SparseInversionParams
— Typestruct SparseInversionParams <: RegressionDynamicCausalModeling.AbstractInvParam
Settings for model inversion specific to sparse rDCM.
Fields
maxIter::Int64
: Maximum number of iterations per regiontol::Float64
: Tolerance for convergencereruns::Int64
: Number of rerunsrestrictInputs::Bool
: Whether or not to estimate sparsity for C matrix. If true, the Bernoulli posteriors for the C matrix are not pruned.
RegressionDynamicCausalModeling.SparseInversionParams
— MethodSparseInversionParams(; maxIter=500, tol=1.0e-5, reruns=100, restrictInputs=true)
Constructor for SparseInversionParams
. See type description for information about arguments.
RegressionDynamicCausalModeling.Options
— Typestruct 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 testingrng::Random.AbstractRNG
: Random number generator
RegressionDynamicCausalModeling.Options
— MethodOptions(invParams::T;synthetic::Bool,verbose=1,testing=false,rng=Xoshiro())
Constructor for Options
. See type description for information about arguments.
RegressionDynamicCausalModeling.invert
— Functioninvert(rdcm::RigidRdcm, opt::Options) -> RigidOutput
Invert an rDCM model specified by rdcm
with fixed network architecture using specific inversion settings defined in opt
.
invert(rdcm::SparseRdcm, opt::Options) -> SparseOutput
Invert a sparse rDCM model specified by rdcm
using specific inversion settings defined in opt
.
Index
RegressionDynamicCausalModeling
RegressionDynamicCausalModeling.BiLinearDCM
RegressionDynamicCausalModeling.BiLinearDCM
RegressionDynamicCausalModeling.BoldY
RegressionDynamicCausalModeling.Confound
RegressionDynamicCausalModeling.DCM
RegressionDynamicCausalModeling.InputU
RegressionDynamicCausalModeling.LinearDCM
RegressionDynamicCausalModeling.LinearDCM
RegressionDynamicCausalModeling.LinearDCM
RegressionDynamicCausalModeling.LinearDCM
RegressionDynamicCausalModeling.LinearDCM
RegressionDynamicCausalModeling.NonLinearDCM
RegressionDynamicCausalModeling.NonLinearDCM
RegressionDynamicCausalModeling.Options
RegressionDynamicCausalModeling.Options
RegressionDynamicCausalModeling.RDCM
RegressionDynamicCausalModeling.RigidInversionParams
RegressionDynamicCausalModeling.RigidInversionParams
RegressionDynamicCausalModeling.RigidOutput
RegressionDynamicCausalModeling.RigidRdcm
RegressionDynamicCausalModeling.RigidRdcm
RegressionDynamicCausalModeling.RigidRdcm
RegressionDynamicCausalModeling.SparseInversionParams
RegressionDynamicCausalModeling.SparseInversionParams
RegressionDynamicCausalModeling.SparseOutput
RegressionDynamicCausalModeling.SparseRdcm
RegressionDynamicCausalModeling.SparseRdcm
RegressionDynamicCausalModeling.SparseRdcm
RegressionDynamicCausalModeling.export_to_SPM
RegressionDynamicCausalModeling.generate_BOLD
RegressionDynamicCausalModeling.invert
RegressionDynamicCausalModeling.load_DCM
RegressionDynamicCausalModeling.load_example_DCM
RegressionDynamicCausalModeling.predict
RegressionDynamicCausalModeling.save_DCM