From c8e90f8dd006aa8b531c0c5695400627fbec3b47 Mon Sep 17 00:00:00 2001 From: Helmut Strey Date: Tue, 20 Aug 2024 19:02:14 -0600 Subject: [PATCH] created script to create a QIF neuron movie --- docs/src/tutorials/QIF_movie.jl | 36 +++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 docs/src/tutorials/QIF_movie.jl diff --git a/docs/src/tutorials/QIF_movie.jl b/docs/src/tutorials/QIF_movie.jl new file mode 100644 index 0000000..b05574e --- /dev/null +++ b/docs/src/tutorials/QIF_movie.jl @@ -0,0 +1,36 @@ +using Neuroblox +using MetaGraphs +using DifferentialEquations +using Random +using Plots +using Statistics + +qif1 = QIFNeuron(name=Symbol("qif1"), I_in=0.5) +g = MetaDiGraph() +add_blox!.(Ref(g), [qif1]) + +@named sys = system_from_graph(g) +sys = structural_simplify(sys) +length(unknowns(sys)) + +prob = ODEProblem(sys, [], (0.0, 1000), []) +sol = solve(prob, Vern7(), saveat=0.1) +plot(sol.t,sol[1,:],xlims=(0,1000),xlabel="time (ms)",ylabel="mV") +p_old = prob.p[1] +p_old[10] = 0.5 # I_in +prob2 = remake(prob, p = p_old) +sol = solve(prob2, Vern7(), saveat=0.1) +I = 0:0.01:0.1 +anim = @animate for i in I + @show i + qif1 = QIFNeuron(name=Symbol("qif1"), I_in=i) + g = MetaDiGraph() + add_blox!.(Ref(g), [qif1]) + + @named sys = system_from_graph(g) + sys = structural_simplify(sys) + prob_new = ODEProblem(sys, [], (0.0, 1000), []) + sol_new = solve(prob_new, Vern7(), saveat=0.1) + plot_qif = plot(sol_new.t,sol_new[1,:],xlims=(0,1000),xlabel="time (ms)",ylabel="mV",label="I_in=$(i)",legend=:top) +end +gif(anim, "anim_fps5.gif", fps = 5) \ No newline at end of file