Skip to content

Commit

Permalink
Merge pull request #296 from Neuroblox/adding-input-current-to-neurons
Browse files Browse the repository at this point in the history
added I_bg (background current) as a parameter for neurons
  • Loading branch information
anandpathak31 authored Oct 24, 2023
2 parents a6f8773 + 5130106 commit d554b27
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/blox/connections.jl
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ function (bc::BloxConnector)(
sys_neuron = get_namespaced_sys(neuron)
# Large negative current added to shut down the Striatum spiking neurons.
# Value is hardcoded for now, as it's more of a hack, not user option.
cb_neuron = [t_event] => [sys_neuron.I_in ~ IfElse.ifelse(sys_matr_out.ρ > sys_matr_in.ρ, -1000, 0)]
cb_neuron = [t_event] => [sys_neuron.I_bg ~ IfElse.ifelse(sys_matr_out.ρ > sys_matr_in.ρ, -2, 0)]
push!(bc.events, cb_neuron)
end
end
Expand Down
2 changes: 1 addition & 1 deletion src/blox/cortical_blox.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ struct CorticalBlox{P} <: AbstractComponent
E_syn_inhib,
G_syn_exci,
G_syn_inhib,
I_in = rand(N_exci),
I_bg = rand(N_exci),
freq,
phase,
τ_exci,
Expand Down
21 changes: 14 additions & 7 deletions src/blox/neuron_models.jl
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ struct HHNeuronExciBlox <: AbstractExciNeuronBlox
θ_spike=0.0,
E_syn=0.0,
G_syn=3,
I_in=0,
I_bg=0,
freq=0,
phase=0,
τ=5
Expand All @@ -171,8 +171,10 @@ struct HHNeuronExciBlox <: AbstractExciNeuronBlox
h(t)=0.59
I_syn(t)=0.0
[input=true]
I_in(t)=I_in
I_in(t)=0.0
[input=true]
I_asc(t)=0.0
[input=true]
G(t)=0.0
z(t)=0.0
Gₛₜₚ(t)=0.0
Expand All @@ -194,6 +196,7 @@ struct HHNeuronExciBlox <: AbstractExciNeuronBlox
τ₁ = 0.1
τ₂ = τ
τ₃ = 2000
I_bg=I_bg
kₛₜₚ = 0.5
freq = freq
phase = phase
Expand All @@ -209,7 +212,7 @@ struct HHNeuronExciBlox <: AbstractExciNeuronBlox
ϕ = 5
G_asymp(v,G_syn) = (G_syn/(1 + exp(-4.394*((v-V_shift)/V_range))))
eqs = [
D(V)~-G_Na*m^3*h*(V-E_Na)-G_K*n^4*(V-E_K)-G_L*(V-E_L)+I_in*(sin(t*freq*2*pi/1000)+1)+I_syn,
D(V)~-G_Na*m^3*h*(V-E_Na)-G_K*n^4*(V-E_K)-G_L*(V-E_L)+I_bg*(sin(t*freq*2*pi/1000)+1)+I_syn+I_asc+I_in,
D(n)~ϕ*(αₙ(V)*(1-n)-βₙ(V)*n),
D(m)~ϕ*(αₘ(V)*(1-m)-βₘ(V)*m),
D(h)~ϕ*(αₕ(V)*(1-h)-βₕ(V)*h),
Expand Down Expand Up @@ -245,7 +248,7 @@ struct HHNeuronInhibBlox <: AbstractInhNeuronBlox
θ_spike=0.0,
E_syn=-70.0,
G_syn=11.5,
I_in=0,
I_bg=0,
freq=0,
phase=0,
τ=70
Expand All @@ -257,7 +260,11 @@ struct HHNeuronInhibBlox <: AbstractInhNeuronBlox
h(t)=0.59
I_syn(t)=0.0
[input=true]
G(t)=0.0
I_asc(t)=0.0
[input=true]
I_in(t)=0.0
[input=true]
G(t)=0.0
[output = true]
z(t)=0.0
spikes_cumulative(t)=0.0
Expand All @@ -278,7 +285,7 @@ struct HHNeuronInhibBlox <: AbstractInhNeuronBlox
τ₁ = 0.1
τ₂ = τ
τ₃ = 2000
I_in=I_in
I_bg=I_bg
freq = freq
phase = phase
end
Expand All @@ -292,7 +299,7 @@ struct HHNeuronInhibBlox <: AbstractInhNeuronBlox
ϕ = 5
G_asymp(v,G_syn) = (G_syn/(1 + exp(-4.394*((v-V_shift)/V_range))))
eqs = [
D(V)~-G_Na*m^3*h*(V-E_Na)-G_K*n^4*(V-E_K)-G_L*(V-E_L)+I_in*(sin(t*freq*2*pi/1000)+1)+I_syn,
D(V)~-G_Na*m^3*h*(V-E_Na)-G_K*n^4*(V-E_K)-G_L*(V-E_L)+I_bg*(sin(t*freq*2*pi/1000)+1)+I_syn+I_asc+I_in,
D(n)~ϕ*(αₙ(V)*(1-n)-βₙ(V)*n),
D(m)~ϕ*(αₘ(V)*(1-m)-βₘ(V)*m),
D(h)~ϕ*(αₕ(V)*(1-h)-βₕ(V)*h),
Expand Down
20 changes: 10 additions & 10 deletions src/blox/subcortical_blox.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ struct Striatum <: AbstractComponent
N_inhib = 25,
E_syn_inhib=-70,
G_syn_inhib=1.2,
I_in=zeros(N_inhib),
I_bg=zeros(N_inhib),
freq=zeros(N_inhib),
phase=zeros(N_inhib),
τ_inhib=70
Expand All @@ -28,7 +28,7 @@ struct Striatum <: AbstractComponent
E_syn = E_syn_inhib,
G_syn = G_syn_inhib,
τ = τ_inhib,
I_in = I_in[i],
I_bg = I_bg[i],
freq = freq[i],
phase = phase[i]
)
Expand Down Expand Up @@ -94,7 +94,7 @@ struct GPi <: AbstractComponent
N_inhib = 25,
E_syn_inhib=-70,
G_syn_inhib=8,
I_in=4*ones(N_inhib),
I_bg=4*ones(N_inhib),
freq=zeros(N_inhib),
phase=zeros(N_inhib),
τ_inhib=70
Expand All @@ -106,7 +106,7 @@ struct GPi <: AbstractComponent
E_syn = E_syn_inhib,
G_syn = G_syn_inhib,
τ = τ_inhib,
I_in = I_in[i],
I_bg = I_bg[i],
freq = freq[i],
phase = phase[i]
)
Expand Down Expand Up @@ -151,7 +151,7 @@ struct GPe <: AbstractComponent
N_inhib = 15,
E_syn_inhib=-70,
G_syn_inhib=3,
I_in=2*ones(N_inhib),
I_bg=2*ones(N_inhib),
freq=zeros(N_inhib),
phase=zeros(N_inhib),
τ_inhib=70
Expand All @@ -163,7 +163,7 @@ struct GPe <: AbstractComponent
E_syn = E_syn_inhib,
G_syn = G_syn_inhib,
τ = τ_inhib,
I_in = I_in[i],
I_bg = I_bg[i],
freq = freq[i],
phase = phase[i]
)
Expand Down Expand Up @@ -209,7 +209,7 @@ struct Thalamus <: AbstractComponent
N_exci = 25,
E_syn_exci=0,
G_syn_exci=3,
I_in=3*ones(N_exci),
I_bg=3*ones(N_exci),
freq=zeros(N_exci),
phase=zeros(N_exci),
τ_exci=5
Expand All @@ -221,7 +221,7 @@ struct Thalamus <: AbstractComponent
E_syn = E_syn_exci,
G_syn = G_syn_exci,
τ = τ_exci,
I_in = I_in[i],
I_bg = I_bg[i],
freq = freq[i],
phase = phase[i]
)
Expand Down Expand Up @@ -266,7 +266,7 @@ struct STN <: AbstractComponent
N_exci = 25,
E_syn_exci=0,
G_syn_exci=3,
I_in=3*ones(N_exci),
I_bg=3*ones(N_exci),
freq=zeros(N_exci),
phase=zeros(N_exci),
τ_exci=5
Expand All @@ -278,7 +278,7 @@ struct STN <: AbstractComponent
E_syn = E_syn_exci,
G_syn = G_syn_exci,
τ = τ_exci,
I_in = I_in[i],
I_bg = I_bg[i],
freq = freq[i],
phase = phase[i]
)
Expand Down
4 changes: 2 additions & 2 deletions src/blox/winnertakeall.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ struct WinnerTakeAllBlox{P} <: AbstractComponent
E_syn_inhib=-70,
G_syn_exci=3.0,
G_syn_inhib=3.0,
I_in=zeros(N_exci),
I_bg=zeros(N_exci),
freq=zeros(N_exci),
phase=zeros(N_exci),
τ_exci=5,
Expand All @@ -39,7 +39,7 @@ struct WinnerTakeAllBlox{P} <: AbstractComponent
E_syn = E_syn_exci,
G_syn = G_syn_exci,
τ = τ_exci,
I_in = I_in[i],
I_bg = I_bg[i],
freq = freq[i],
phase = phase[i]
)
Expand Down
12 changes: 6 additions & 6 deletions test/components.jl
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,9 @@ end
end

@testset "HH Neuron excitatory & inhibitory network" begin
nn1 = HHNeuronExciBlox(name=Symbol("nrn1"), I_in=3, freq=4; t_spike_window=0.1)
nn2 = HHNeuronExciBlox(name=Symbol("nrn2"), I_in=2, freq=6; t_spike_window=0.1)
nn3 = HHNeuronInhibBlox(name=Symbol("nrn3"), I_in=2, freq=3)
nn1 = HHNeuronExciBlox(name=Symbol("nrn1"), I_bg=3, freq=4; t_spike_window=0.1)
nn2 = HHNeuronExciBlox(name=Symbol("nrn2"), I_bg=2, freq=6; t_spike_window=0.1)
nn3 = HHNeuronInhibBlox(name=Symbol("nrn3"), I_bg=2, freq=3)
assembly = [nn1, nn2, nn3]

# Adjacency matrix :
Expand All @@ -453,7 +453,7 @@ end

@testset "WinnerTakeAll" begin
N_exci = 5
@named wta= WinnerTakeAllBlox(;I_in=5*rand(N_exci), N_exci)
@named wta= WinnerTakeAllBlox(;I_bg=5*rand(N_exci), N_exci)
sys = wta.odesystem
wta_simp=structural_simplify(sys)
prob = ODEProblem(wta_simp,[],(0,10))
Expand All @@ -466,8 +466,8 @@ end
@testset "WinnerTakeAll network" begin
global_ns = :g # global namespace
N_exci = 5
@named wta1 = WinnerTakeAllBlox(;I_in=5*rand(N_exci), N_exci, namespace=global_ns)
@named wta2 = WinnerTakeAllBlox(;I_in=5*rand(N_exci), N_exci, namespace=global_ns)
@named wta1 = WinnerTakeAllBlox(;I_bg=5*rand(N_exci), N_exci, namespace=global_ns)
@named wta2 = WinnerTakeAllBlox(;I_bg=5*rand(N_exci), N_exci, namespace=global_ns)
g = MetaDiGraph()
add_blox!.(Ref(g), [wta1, wta2])
add_edge!(g, 1, 2, Dict(:weight => 1, :density => 0.5))
Expand Down

0 comments on commit d554b27

Please sign in to comment.