Function Documentation

Model Building

NeuralDynamics.initializeParamsFunction
initializeParams(model::String; args...)

Creates a dictionary of parameters for a defined model. In the absence of optional arguments the model will be initialized with default parameter values. If some optional arguments are passed they will replace those default values in the dictionary. Currently implemented models include:

  • "FHN": FitzHugh-Nagumo
  • "SFF": Simple Feed-forward
  • "WC": Wilson-Cowan

Examples

julia> params = initializeParams("FHN")
Dict{Symbol, Float64} with 7 entries:
 :R     => 1
 :tau1  => 1.0
 :tau2  => 2.0
 :I     => 0
 :b1    => 1.1
 :b0    => 0.9
	
julia> params = initializeParams("FHN", tau1 = 5.0, b1 = 2.0)
Dict{Symbol, Float64} with 7 entries:
 :R     => 1
 :tau1  => 5.0
 :tau2  => 2.0
 :I     => 0
 :b1    => 2.0
 :b0    => 0.9

Note

Check the documentation for a given model in the docs to see what parameters are required.

source
NeuralDynamics.modelEquationsType
modelEquations(name::String)
modelEquations(name::String, DEs, nullclines)

Generates a struct of type modelEquations containing the model name, differential equations, and nullcline equations. Custom models can be built by inputting your own equations. Some models are automatically implemented and the relevant struct will be returned just by calling these models by name. Currently implemented models include:

  • "FHN": FitzHugh-Nagumo
  • "WC": Wilson-Cowan

Examples

julia> mdl=modelEquations("FHN")
modelEquations("FHN", (NeuralDynamics.fhn_dudt, NeuralDynamics.fhn_dwdt), (NeuralDynamics.fhn_nullclinewu, NeuralDynamics.fhn_nullclineww))
	
julia> mdl=modelEquations("WC")
modelEquations("WC", (NeuralDynamics.wc_drₑ, NeuralDynamics.wc_drᵢ), (NeuralDynamics.wc_eNullcline, NeuralDynamics.wc_iNullcline))
source

Phase Analysis

NeuralDynamics.getNullclinesFunction
getNullclines(x, modelEqs, params::Dict)

getNullclines(x, y, modelEqs, params::Dict)

Determines the nullclines of the defined model over the sampled space using the dictionary of model parameters and struct containing the model equations.

The nullcine of $x$ with respect to some parameter $t$ is defined as the points along the phase plane were $\frac{dx}{dt} = 0$.

Example

julia> params = initializeParams("FHN")
Dict{Symbol, Float64} with 7 entries:
 :R     => 1
 :tau1  => 1.0
 :tau2  => 2.0
 :I     => 0
 :b1    => 1.1
 :b0    => 0.9

julia> mdl = modelEquations("FHN")
 modelEquations("FHN", (NeuralDynamics.fhn_dudt, NeuralDynamics.fhn_dwdt), (NeuralDynamics.fhn_nullclinewu, NeuralDynamics.fhn_nullclineww))

julia> ncls = getNullclines(-2.5:0.01:2.5, mdl, params)

julia> params = initializeParams("WC")
Dict{Symbol, Float64} with 12 entries:
  :tauE   => 1.0
  :wEE    => 9.0
  :wIE    => 13.0
  :thetaE => 2.8
  :wEI    => 4.0
  :wII    => 11.0
  :tauI   => 2.0
  :aE     => 1.2
  :aI     => 1.0
  :II     => 0.0
  :thetaI => 4.0
  :IE     => 0.0

julia> mdl = modelEquations("WC")
 modelEquations("WC", (NeuralDynamics.wc_drₑ, NeuralDynamics.wc_drᵢ), (NeuralDynamics.wc_eNullcline, NeuralDynamics.wc_iNullcline))

julia> ncls = getNullclines((-0.01:0.001:0.96, -0.01:0.001:0.8), mdl, params)
source
NeuralDynamics.getVectorFieldsFunction
getVectorFields(x, modelEqs ,params::Dict; subdivisions::Int64=10)

Given an array of x-indices (and optionally y-indices), a model, and a dictionary of model parameters a Vector of 2D arrays will be returned with the local x and y gradients at evenly sampled points across the defined space. The granularity of sampling is determined by the optional parameter subdivisions with a default sampling density of 10 resulting in a 10x10 grid of vector fields.

Examples

julia> params = initializeModel("FHN")
Dict{Symbol, Float64} with 7 entries:
 :R     => 1
 :tau1  => 1.0
 :tau2  => 2.0
 :I     => 0
 :b1    => 1.1
 :b0    => 0.9

julia> mdl = modelEquations("FHN")
 modelEquations("FHN", (NeuralDynamics.fhn_dudt, NeuralDynamics.fhn_dwdt), (NeuralDynamics.fhn_nullclinewu, NeuralDynamics.fhn_nullclineww))

julia> fields = getVectorFields(-2.5:0.01:2.5, mdl)
	
julia> fields = getVectorFields(-2.5:0.01:2.5, mdl, subdivisions=5)

julia> fields = getVectorFields(-2.5:0.01:2.5, -1:0.01:1, mdl, subdivisions=20)
source
NeuralDynamics.findFixedPointsFunction
findFixedPoints(xGuess::Vector, func, params)

Given an array xGuess giving initial guesses for fixed points, a helper function (see below) func to find the roots of, and a dictionary of model parameters, params this function will return a vector of fixed points determined using Newton's method. Helper functions have been defined for the "FHN" and "WC" models and follow the general convention fFHN! or fWC! respectively.

Examples

julia> params = initializeParams("WC")
Dict{Symbol, Float64} with 12 entries:
  :tauE   => 1.0
  :wEE    => 9.0
  :wIE    => 13.0
  :thetaE => 2.8
  :wEI    => 4.0
  :wII    => 11.0
  :tauI   => 2.0
  :aE     => 1.2
  :aI     => 1.0
  :II     => 0.0
  :thetaI => 4.0
  :IE     => 0.0

julia> guesses = [[0.0,0.0],[0.4,0.2],[0.9,0.6]]
3-element Vector{Vector{Float64}}:
 [0.0, 0.0]
 [0.4, 0.2]
 [0.9, 0.6]


julia> fps = findFixedPoints(guesses, fWC!, params)
3-element Vector{Vector{Float64}}:
 [0.0, 0.0]
 [0.33685240829408575, 0.168419676112977]
 [0.9384304716775121, 0.6724810433274886]
source
NeuralDynamics.getJacobianEigenvaluesFunction
getJacobianEigenvalues(fixedPoints, params)

Given an array of fixed points and model parameters this function will return the eigenvalues of the Jacobian matrix for the Wilson-Cowan model. Currently, only the Wilson- Cowan model equations have been implemented.

$J = \begin{bmatrix} \frac{\partial}{\partial r_E}G_E(r_E^*, r_I^*) & \frac{\partial}{\partial r_I}G_E(r_E^*, r_I^*) \\ \frac{\partial}{\partial r_E}G_I(r_E^*, r_I^*) & \frac{\partial}{\partial r_I}G_I(r_E^*, r_I^*) \end{bmatrix}$

Examples

julia> params = initializeParams("WC")
Dict{Symbol, Float64} with 12 entries:
  :tauE   => 1.0
  :wEE    => 9.0
  :wIE    => 13.0
  :thetaE => 2.8
  :wEI    => 4.0
  :wII    => 11.0
  :tauI   => 2.0
  :aE     => 1.2
  :aI     => 1.0
  :II     => 0.0
  :thetaI => 4.0
  :IE     => 0.0

julia> guesses = [[0.0,0.0],[0.4,0.2],[0.9,0.6]]
3-element Vector{Vector{Float64}}:
 [0.0, 0.0]
 [0.4, 0.2]
 [0.9, 0.6]


julia> fps = findFixedPoints(guesses, fWC!, params)
3-element Vector{Vector{Float64}}:
 [0.0, 0.0]
 [0.33685240829408575, 0.168419676112977]
 [0.9384304716775121, 0.6724810433274886]

 julia> eigenVals = getJacobianEigenvalues(fps, params)
 3-element Vector{Any}:
  ComplexF64[-0.6233838572258439 - 0.1311095729053099im, -0.6233838572258439 + 0.1311095729053099im]
  [-0.8726689790568727, 1.057207976436168]
  [-1.4219741349895596, -0.95956219494619]
 
source

Convenience Functions

NeuralDynamics.sigmoidFunction
sigmoid(x, a, θ)

The sigmoid activation function with input x, gain parameter a, and threshold parameter θ.

Examples

jldoctest julia> s = sigmoid(0.1:0.1:10, 1, 3) 100-element Vector{Float64}: 0.0047276899008509565 0.009898302721301974 ⋮ 0.9515673560023477 0.9516630756280327

source
NeuralDynamics.invSigmoidFunction
invSigmoid(x, a, θ)

The inverse sigmoid function with input x, gain parameter a, and threshold parameter θ.

Examples

```jldoctest julia> invSigmoid(0.4, 1, 3) 2.788923286876553

julia> invSigmoid.(0.1:0.1:0.9, 1, 3) 9-element Vector{Float64}: 1.2450653370666414 1.8876115356593868 2.369626590583188 2.788923286876553 3.190275495162158 3.6077434164384417 4.084930356824196 4.71455281467788 5.891524586559516 ```

source
NeuralDynamics.dSigmoidFunction
dSigmoid(x, a, θ)

The derivative of the sigmoid function with input x, gain parameter a, and threshold parameter θ.

Examples

```jldoctest julia> dSigmoid(0.4, 1, 3) 0.0643582991757735

julia> dSigmoid.(0.1:0.1:0.9, 1, 3) 9-element Vector{Float64}: 0.04943356893664324 0.05403811475638431 0.05900771248391522 0.0643582991757735 0.07010371654510816 0.07625499905185225 0.08281956699074117 0.08980032904006871 0.0971947048006254 ```

source

Simulation

NeuralDynamics.simulateFunction
simulate(t, model::String, params::Dict, init)

Given a timecourse of t passed as a Vector or StepRange this function will simulate the model defined by model (String) with parameters params (Dict) with initial conditions defined in the init (Vector or Float). The results are returned as a Vector. Currently implemented models are:

  • "FHN": FitzHugh-Nagumo
  • "SFF": Simple Feed-forward
  • "WC": Wilson-Cowan

Examples

julia> mdl = initializeModel("FHN")
Dict{Symbol, Float64} with 7 entries:
 :R     => 1
 :tau1  => 1.0
 :tau2  => 2.0
 :I     => 0
 :b1    => 1.1
 :b0    => 0.9
	
julia> ru, rw = simulate(0:0.1:50, "FHN", mdl, (-2.0, 1.0))
source

Plotting

NeuralDynamics.plotVectorFields!Function
plotVectorFields!(x, fields::Tuple; arrowScale=0.2, kwargs...)

Convenient plotting function to add vector fields to an existing phase plot. It takes a single vector x as input (for symmetrical axes) or two vectors x and y for unique axis ranges. The fields should be passed as a vector of 2D arrays giving the x and y gradients respectively.

The arrowScale defaults to 0.2 but can be passed as an optional argument. Additional plotting arguments can also be passed as kwargs....

Check Plots.jl for additional information on plot arguments.

Examples

julia> plotVectorFields!(-1:0.1:1, ([3 2 3; 2 1 2; 3 2 3], [3 2 3; 2 1 2; 3 2 3]))

julia> plotVectorFields!(-1:0.1:1, ([3 2 3; 2 1 2; 3 2 3], [3 2 3; 2 1 2; 3 2 3]), arrowSize = 0.5)

julia> plotVectorFields!(-1:0.1:1, ([3 2 3; 2 1 2; 3 2 3], [3 2 3; 2 1 2; 3 2 3]), color="red", alpha=0.3)
source
NeuralDynamics.plotTrajectory!Function

plotTrajectory!(x, y; kwargs...)

Convenient plotting function to add results of a simulation to an existing phase plot. It takes the simulation output along the abscissa and ordinate as arguments in the form of two Vectors or StepRanges x and y.

Additional plotting arguments can also be passed as kwargs....

Check Plots.jl for additional information on plot arguments.

Examples

julia> plotTrajectory!(-1:0.1:1, -1:0.1:1)

julia> plotTrajectory!(-1:0.1:1, -1:0.1:1, color=red, label="simulation", xlab="x", ylab="y")

For similar functionality see plotTrajectories!

source
NeuralDynamics.plotTrajectories!Function

plotTrajectories!(t, x, y, model::String, params::Dict; kwargs...)

Convenient plotting function to add results of multiple simulations to an existing phase plot. It takes the simulation timecourse t (Vector or StepRange), and x and y Vectors or StepRanges defining the sampling in each direction in phase space respectively. The model is defined as a String and the model parameters param as a Dict. Currently implemented models are:

  • "FHN": FitzHughNagumo

Additional plotting arguments can also be passed as kwargs....

Check Plots.jl for additional information on plot arguments.

Examples

julia> mdl = initializeModel("FHN")
Dict{Symbol, Float64} with 7 entries:
 :R     => 1
 :tau1  => 1.0
 :tau2  => 2.0
 :I     => 0
 :b1    => 1.1
 :b0    => 0.9

julia> plotTrajectories!(0:0.1:50, -2.5:1:2.5, -2.5:1:2.5, "FHN", mdl)

julia> plotTrajectories!(0:0.1:50, -2.5:1:2.5, -2.5:1:2.5, "FHN", mdl, color=:gray, label="simulations")

For similar functionality see plotTrajectory!

source