forked from lukaribar/telluride-21
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nd_fit.py
63 lines (49 loc) · 1.54 KB
/
nd_fit.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
"""
Fit NeuroDyn model
"""
#%% Initial fit
from fitting_utilities import FitND
from cb_models import NeuroDynModel, HHModel
import matplotlib.pyplot as plt
# Voltage scaling (important: assumes that HH is already written in SI units)
scl_v = 3
#ND = NeuroDynModel()
HH = HHModel(scl_v=scl_v, SI_units=True)
fit = FitND(HH)
#%% Fit gating variables individually and compute quantized parameters
c = fit.fitHH(plot_alpha_beta=True)
g0 = [120e-3,36e-3,0.3e-3]
E0 = [120e-3,-12e-3,10.6e-3]
dIb = fit.get_digital_Ib(c)
dg = fit.get_digital_g(g0)
dE = fit.get_digital_E(E0)
dIb[2][1] = dIb[2][1]*15 # This parameter is too small for some reason!!!
#%% Calculate the NeuroDyn parameters and simulate
I0 = 0e-6
Iapp = lambda t : fit.convert_I(I0)
V_ref = 0.9
ND = NeuroDynModel(dg, dE, dIb, V_ref, fit.I_voltage, fit.I_master)
T = 0.02
trange = (0, T)
sol = ND.simulate(trange,[0.7,0,0,0],Iapp)
plt.figure()
plt.xlabel('t')
plt.ylabel('V')
plt.title('NeuroDyn simulation')
plt.plot(sol.t, sol.y[0])
plt.show()
#%% Print the parameter values
print('\nImaster = ', ND.I_master)
print('Ivoltage = ', ND.I_voltage)
print('Vref = ', V_ref, '\n')
print('Digital values for maximal conductances:')
print('[gna, gk, gl] = ', ND.dg, '\n')
print('Digital values for reversal potentials:')
print('[Ena, Ek, El] = ', dE, '\n')
print('Digital values for gating variable kinetics:')
print('alpha_m = ', dIb[0][0])
print('beta_m = ', dIb[0][1], '\n')
print('alpha_h = ', dIb[1][0])
print('beta_h = ', dIb[1][1], '\n')
print('alpha_n = ', dIb[2][0])
print('beta_n = ', dIb[2][1], '\n')