Skip to content

Commit e49afab

Browse files
committed
decay times in freq
1 parent b5f9e67 commit e49afab

File tree

2 files changed

+48
-5
lines changed

2 files changed

+48
-5
lines changed

docs/bcl-duration.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@ using CaMKIIModel
1010
using CaMKIIModel: second
1111
Plots.default(lw=1.5)
1212

13-
# ### Experiments
13+
# ## Experiments
1414
# 30 seconds resting + N seconds 1Hz pacing + resting.
15-
1615
durationdf = CSV.read(joinpath(@__DIR__, "data/CaMKAR-duration.csv"), DataFrame)
1716
ts = durationdf[!, "Time(sec)"]
1817
fifteen = durationdf[!, "1Hz 15sec (Mean)"]

docs/bcl-freq.jl

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ using CurveFit
88
using CaMKIIModel
99
using CaMKIIModel: second
1010
Plots.default(lw=1.5)
11-
1211
# ## Experiments
1312
freqdf = CSV.read(joinpath(@__DIR__, "data/CaMKAR-freq.csv"), DataFrame)
1413
ts = 0:5:205
@@ -23,7 +22,6 @@ plot!(title="Experiment", xlabel="Time (s)", ylabel="CaMKII activity (AU)")
2322

2423
#---
2524
savefig("pacing-frequency-exp.pdf")
26-
2725
# ## Simulations
2826
@time "Build system" @mtkcompile sys = build_neonatal_ecc_sys()
2927
tend = 205.0second
@@ -47,7 +45,6 @@ plot!(title="Simulation", xlabel="Time (s)", ylabel="CaMKII activity (%)")
4745

4846
#---
4947
savefig("pacing-frequency-sim.pdf")
50-
5148
# ## Phosphorylated fraction
5249
idxs = (sys.t / 1000, (sys.CaMKP + sys.CaMKA + sys.CaMKA2) * 100)
5350
plot(sol1, idxs=idxs, lab="1 Hz", color=:blue)
@@ -56,3 +53,50 @@ plot!(title="Simulation", xlabel="Time (s)", ylabel="Phosphorylated CaMKII (%)")
5653

5754
#---
5855
savefig("pacing-frequency-phos.pdf")
56+
57+
# ## Decay rates
58+
# Fit against an exponential decay model.
59+
decay_model(p, x) = @. p[1] * exp(-x / p[2]) + p[3]
60+
61+
# Data from experiments
62+
# Record 50 seconds after pacing ends
63+
ts = collect(range(0.0, stop=50.0, step=5.0))
64+
ydata_1hz = onehz[24:34]
65+
ydata_2hz = twohz[24:34]
66+
67+
# Simulation points
68+
ysim_1hz = sol1(stimend:5second:stimend+50second ; idxs=sys.CaMKAct * 100).u
69+
ysim_2hz = sol2(stimend:5second:stimend+50second ; idxs=sys.CaMKAct * 100).u
70+
71+
# Fit data to an exponential decay model
72+
fit_1hz = solve(CurveFitProblem(ts, ydata_1hz), ExpSumFitAlgorithm(n=1, withconst=true))
73+
fit_2hz = solve(CurveFitProblem(ts, ydata_2hz), ExpSumFitAlgorithm(n=1, withconst=true))
74+
fit_1hz_sim = solve(CurveFitProblem(ts, ysim_1hz), ExpSumFitAlgorithm(n=1, withconst=true))
75+
fit_2hz_sim = solve(CurveFitProblem(ts, ysim_2hz), ExpSumFitAlgorithm(n=1, withconst=true))
76+
77+
# Fitting results (experiments)
78+
p1 = plot(ts, ydata_1hz, label="Exp 1 Hz")
79+
plot!(p1, ts, predict(fit_1hz), label="Fit", linestyle=:dash)
80+
p2 = plot(ts, ydata_2hz, label="Exp 2 Hz")
81+
plot!(p2, ts, predict(fit_2hz), label="Fit", linestyle=:dash)
82+
p3 = plot(ts, ysim_1hz, label="Sim 1 Hz")
83+
plot!(p3, ts, predict(fit_1hz_sim), label="Fit", linestyle=:dash)
84+
p4 = plot(ts, ysim_2hz, label="Sim 2 Hz")
85+
plot!(p4, ts, predict(fit_2hz_sim), label="Fit", linestyle=:dash)
86+
plot(p1, p2, p3, p4, layout=(2,2), xlabel="Time (s)", ylabel="CaMKII activity (AU)")
87+
88+
89+
# Calculate time scales (tau) from fit parameters
90+
tau_exp_1hz = inv(-fit_1hz.u.λ[])
91+
tau_exp_2hz = inv(-fit_2hz.u.λ[])
92+
tau_sim_1hz = inv(-fit_1hz_sim.u.λ[])
93+
tau_sim_2hz = inv(-fit_2hz_sim.u.λ[])
94+
95+
println("The time scales for experiments: ")
96+
for (tau, freq) in zip((tau_exp_1hz, tau_exp_2hz), (1, 2))
97+
println("$freq Hz pacing is $(round(tau; digits=2)) seconds.")
98+
end
99+
println("The time scales for simulations: ")
100+
for (tau, freq) in zip((tau_sim_1hz, tau_sim_2hz), (1, 2))
101+
println("$freq Hz pacing is $(round(tau; digits=2)) seconds.")
102+
end

0 commit comments

Comments
 (0)