Skip to content

Commit

Permalink
Add connections for PING neurons
Browse files Browse the repository at this point in the history
  • Loading branch information
agchesebro committed Aug 9, 2024
1 parent d2a1766 commit 0282417
Showing 1 changed file with 66 additions and 13 deletions.
79 changes: 66 additions & 13 deletions src/blox/ping_neuron_examples.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# First, create an abstract neuron that we'll extend to create the neurons for this tutorial.
abstract type AbstractPINGNeuron <: AbstractNeuronBlox end

# Create an excitatory neuron that inherits from this neuron blox.
struct PINGNeuronExci <: AbstractPINGNeuron
params
output
jcn
voltage
odesystem
namespace
function PINGNeuronExci(;name,
Expand All @@ -15,10 +18,12 @@ struct PINGNeuronExci <: AbstractPINGNeuron
V_K=-100.0,
g_L=0.1,
V_L=-67.0,
I_ext=0.0)
p = paramscoping(C=C, g_Na=g_Na, V_Na=V_Na, g_K=g_K, V_K=V_K, g_L=g_L, V_L=V_L, I_ext=I_ext)
C, g_Na, V_Na, g_K, V_K, g_L, V_L, I_ext = p
sts = @variables V(t)=0.0 [output=true] n(t)=0.0 h(t)=0.0 jcn(t)=0.0 [input=true]
I_ext=0.0,
τ_R=0.2,
τ_D=2.0)
p = paramscoping(C=C, g_Na=g_Na, V_Na=V_Na, g_K=g_K, V_K=V_K, g_L=g_L, V_L=V_L, I_ext=I_ext, τ_R=τ_R, τ_D=τ_D)
C, g_Na, V_Na, g_K, V_K, g_L, V_L, I_ext, τ_R, τ_D = p
sts = @variables V(t)=0.0 [output=true] n(t)=0.0 h(t)=0.0 s(t)=0.0 jcn(t)=0.0 [input=true]

a_m(v) = 0.32*(v+54.0)/(1.0 - exp(-(v+54.0)/4.0))
b_m(v) = 0.28*(v+27.0)/(exp((v+27.0)/5.0) - 1.0)
Expand All @@ -28,19 +33,22 @@ struct PINGNeuronExci <: AbstractPINGNeuron
b_h(v) = 4.0/(1.0 + exp(-(v+27.0)/5.0))

m∞(v) = a_m(v)/(a_m(v) + b_m(v))
eqs = [D(V) ~ g_Na*m∞(V)^3*h*(V_Na - V) + g_K*(n^4)*(V_K - V) + g_L*(V_L - V) + I_ext,
eqs = [D(V) ~ g_Na*m∞(V)^3*h*(V_Na - V) + g_K*(n^4)*(V_K - V) + g_L*(V_L - V) + I_ext + jcn,
D(n) ~ (a_n(V)*(1.0 - n) - b_n(V)*n),
D(h) ~ (a_h(V)*(1.0 - h) - b_h(V)*h)
D(h) ~ (a_h(V)*(1.0 - h) - b_h(V)*h),
D(s) ~ ((1+tanh(V/10.0))/2.0)*((1.0 - s)/τ_R) - s/τ_D
]
sys = ODESystem(eqs, t, sts, p; name=name)
new(p, sts[1], sts[4], sys, namespace)
new(p, sts[4], sts[5], sts[1], sys, namespace)
end
end

# Create an inhibitory neuron that inherits from the same neuron blox.
struct PINGNeuronInhib <: AbstractPINGNeuron
params
output
jcn
voltage
odesystem
namespace
function PINGNeuronInhib(;name,
Expand All @@ -52,10 +60,12 @@ struct PINGNeuronInhib <: AbstractPINGNeuron
V_K=-90.0,
g_L=0.1,
V_L=-65.0,
I_ext=0.0)
p = paramscoping(C=C, g_Na=g_Na, V_Na=V_Na, g_K=g_K, V_K=V_K, g_L=g_L, V_L=V_L, I_ext=I_ext)
C, g_Na, V_Na, g_K, V_K, g_L, V_L, I_ext = p
sts = @variables V(t)=0.0 [output=true] n(t)=0.0 h(t)=0.0 jcn(t)=0.0 [input=true]
I_ext=0.0,
τ_R=0.5,
τ_D=10.0)
p = paramscoping(C=C, g_Na=g_Na, V_Na=V_Na, g_K=g_K, V_K=V_K, g_L=g_L, V_L=V_L, I_ext=I_ext, τ_R=τ_R, τ_D=τ_D)
C, g_Na, V_Na, g_K, V_K, g_L, V_L, I_ext, τ_R, τ_D = p
sts = @variables V(t)=0.0 [output=true] n(t)=0.0 h(t)=0.0 s(t)=0.0 jcn(t)=0.0 [input=true]

a_m(v) = 0.1*(v+35.0)/(1.0 - exp(-(v+35.0)/10.0))
b_m(v) = 4*exp(-(v+60.0)/18.0)
Expand All @@ -67,9 +77,52 @@ struct PINGNeuronInhib <: AbstractPINGNeuron
m∞(v) = a_m(v)/(a_m(v) + b_m(v))
eqs = [D(V) ~ g_Na*m∞(V)^3*h*(V_Na - V) + g_K*(n^4)*(V_K - V) + g_L*(V_L - V) + I_ext,
D(n) ~ (a_n(V)*(1.0 - n) - b_n(V)*n),
D(h) ~ (a_h(V)*(1.0 - h) - b_h(V)*h)
D(h) ~ (a_h(V)*(1.0 - h) - b_h(V)*h),
D(s) ~ ((1+tanh(V/10.0))/2.0)*((1.0 - s)/τ_R) - s/τ_D
]
sys = ODESystem(eqs, t, sts, p; name=name)
new(p, sts[1], sts[4], sys, namespace)
new(p, sts[4], sts[5], sts[1], sys, namespace)
end
end

# Create excitatory -> inhibitory AMPA receptor conenction
function (bc::BloxConnector)(
bloxout::PINGNeuronExci,
bloxin::PINGNeuronInhib;
kwargs...
)
sys_out = get_namespaced_sys(bloxout)
sys_in = get_namespaced_sys(bloxin)

w = generate_weight_param(bloxout, bloxin; kwargs...)
push!(bc.weights, w)

V_E = haskey(kwargs, :V_E) ? kwargs[:V_E] : 0.0

s = namespace_expr(bloxout.output, sys_out)
v_in = namespace_expr(bloxin.voltage, sys_in)
eq = sys_in.jcn ~ w*s*(V_E-v_in)

accumulate_equation!(bc, eq)
end

# Create inhibitory -> inhibitory/excitatory GABA_A receptor connection
function (bc::BloxConnector)(
bloxout::PINGNeuronInhib,
bloxin::AbstractPINGNeuron;
kwargs...
)
sys_out = get_namespaced_sys(bloxout)
sys_in = get_namespaced_sys(bloxin)

w = generate_weight_param(bloxout, bloxin; kwargs...)
push!(bc.weights, w)

V_I = haskey(kwargs, :V_I) ? kwargs[:V_I] : -80.0

s = namespace_expr(bloxout.output, sys_out)
v_in = namespace_expr(bloxin.voltage, sys_in)
eq = sys_in.jcn ~ w*s*(V_I-v_in)

accumulate_equation!(bc, eq)
end

0 comments on commit 0282417

Please sign in to comment.