Model Graphs

At the highest level, a Neuroblox model consists of a weighted directed graph (represented as a MetaDiGraph) whose nodes are Blox representing neurons and populations of neurons, and whose edges are connectors dictating how the dynamics of the Blox affect each other. The weights of the edges represent the strengths of synaptic connections. The model graph is used to generate a system of ordinary differential equations that can be solved using Julia's differential equations solvers.

Users can also save/load a graph model and/or an ODE problem that contains the model in addition to simulation parameters like a timespan, initial conditions, etc.

Building a model from a graph

NeurobloxBase.@graphMacro
@graph

Helper macro that returns a GraphSystem whose nodes are Blox and whose edges are connections. Nodes should be declared within the block starting with @nodes, and connections should be declared within the block starting with @connections. Connections should be declared as Pairs, with an optional vector of keyword arguments coming after.

Example:

cortical = @graph name begin
    @nodes begin
        ASC1 = NextGenerationEI(; ...)
        Layer_2_3_A = Cortical(; density = 0.03) 
    end

    @connections begin
        ASC1 => Layer_2_3_A, [weight = 20]
    end
end
NeurobloxBase.@graph!Macro
@graph! g expr

Like the @graph macro, except it takes an existing graph g as its first argument and mutates it by adding additional nodes and connections.

Saving/loading a model

NeurobloxBase.save_graphFunction
save_graph(path::String, g::GraphSystem; save_manifest = true)

Save a GraphSystem as a jld2 file. If save_manifest is set, then the current Manifest.toml of the active project will also be saved as a string.

NeurobloxBase.load_graphFunction
load_graph(path::String)

Load a GraphSystem from a saved GraphSystem or ODEProblem as a jld2 file.

NeurobloxBase.@save_graphMacro
@save_graph "file_name.jld2" @graph g begin
    ...
end

Insert this macrocall before the DSL definition of a graph to save both the graph, as well as the DSL code used to generate it. This is useful to ensure that the model is reproducible between versions.

IMPORTANT: the reconstructed graph may have slightly different connections if random numbers are used when flattening a composite (like a Cortical blox). Do not rely on the topology being the exact same.

NeurobloxBase.save_problemFunction
save_problem(path::String, prob::ODEProblem)

Save an ODEProblem as a jld2 file. This saves the graph, initial condition, tspan, and parameters.