2023-05-27__synaptic_cond_example
2023-05-27__synaptic_cond_example¶
using Units
Δt = 0.01ms
T = 60ms
N = round(Int, T/Δt)
6000
ts = Δt .* (1:N);
function sim(syns = [(Δg = 1nS, spikes = [10ms, 20ms]), ])
t = 0
g = 0nS
τ = 7ms
gs = []
syns = deepcopy(syns)
for i in 1:N
t += Δt
for (Δg, spikes) in syns
if !isempty(spikes) && t ≥ first(spikes)
popfirst!(spikes)
g += Δg
end
end
dg = -g / τ
g += dg * Δt
push!(gs, g)
end
return gs
end;
using PyPlot
using Revise
using Sciplotlib
using PhDPlots
PhDPlots.set_Δt(Δt);
pl(x) = begin
fig, ax = plt.subplots(figsize=(2.2, 0.9))
plotsig(x / nS, nothing, ms; ax);
G = 1nS
set(ax, xtype=:range, ytype=:range, ylim=[0, G/nS], xlabel=nothing, xunit="ms", yunit="nS")
end;
s1 = (0.4nS, [10ms, 30ms])
g1 = sim([s1])
pl(g1);
plt.savefig("../thesis/figs/g2.pdf")
![../_images/2023-05-27__synaptic_cond_example_10_0.png](../_images/2023-05-27__synaptic_cond_example_10_0.png)
s2 = (1nS, [20ms])
g2 = sim([s2])
pl(g2);
plt.savefig("../thesis/figs/g1.pdf")
![../_images/2023-05-27__synaptic_cond_example_11_0.png](../_images/2023-05-27__synaptic_cond_example_11_0.png)
pl(g1 .+ g2);
![../_images/2023-05-27__synaptic_cond_example_12_0.png](../_images/2023-05-27__synaptic_cond_example_12_0.png)
g3 = sim([s1, s2])
pl(g3);
plt.savefig("../thesis/figs/g3.pdf")
![../_images/2023-05-27__synaptic_cond_example_13_0.png](../_images/2023-05-27__synaptic_cond_example_13_0.png)
pl(g3 .- (g1 .+ g2));
![../_images/2023-05-27__synaptic_cond_example_14_0.png](../_images/2023-05-27__synaptic_cond_example_14_0.png)
Sciplotlib.plot((g3 .- (g1 .+ g2)) / nS);
![../_images/2023-05-27__synaptic_cond_example_15_0.png](../_images/2023-05-27__synaptic_cond_example_15_0.png)
plotsig(g3 / nS, nothing, ms, lw=4)
plotsig((g1 .+ g2) / nS, nothing, ms, lw=1);
![../_images/2023-05-27__synaptic_cond_example_16_0.png](../_images/2023-05-27__synaptic_cond_example_16_0.png)