forked from ModelDBRepository/267187
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestXPP.py
228 lines (192 loc) · 5.22 KB
/
TestXPP.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
from pyneuroml.xppaut import parse_script, to_lems, to_xpp, run_xpp_file
from pprint import pprint
cell = "AWCon"
cell = "RMD"
parsed_data = parse_script("../%s.ode" % cell.replace("on", ""))
import sys
short_simulation = "-short" in sys.argv
if short_simulation:
parsed_data = parse_script("../XPP_tests/%s_edited.ode" % cell.replace("on", ""))
pprint(parsed_data)
all_g = [
"gleak",
"gshal",
"gkir",
"gshak",
"gegl36",
"gunc2",
"gegl19",
"gcca1",
"gslo1",
"gbk",
"gbk2",
"gslo2",
"gca",
"gnca",
"gkvs1",
"gkqt3",
"gegl2",
]
channels_to_include = ["leak", "nca"]
channels_to_include = ["leak", "shal", "egl36", "kir", "shak", "cca", "unc2"]
channels_to_include = ["leak", "unc2"]
channels_to_include = ["leak", "shal", "egl36", "kir", "shak", "cca", "unc2", "egl19"]
channels_to_include = ["leak", "kir"]
channels_to_include = ["leak", "kir", "cca"]
channels_to_include = ["leak", "kir", "cca", "ca"]
channels_to_include = ["leak", "bk"]
channels_to_include = ["leak", "unc2", "bk"]
channels_to_include = [
"leak",
"nca",
"shal",
"egl36",
"kir",
"shak",
"cca",
"unc2",
"egl19",
"ca",
]
channels_to_include = ["leak", "unc2"]
channels_to_include = ["leak", "unc2", "slo2"]
channels_to_include = ["leak", "unc2", "bk"]
channels_to_include = ["leak", "egl19", "slo1"]
channels_to_include = ["leak", "egl19", "bk2"]
channels_to_include = [
"leak",
"nca",
"shal",
"egl36",
"kir",
"shak",
"cca",
"unc2",
"egl19",
"ca",
"bk",
"slo1",
"bk2",
"slo2",
]
channels_to_include = ["leak", "kir", "cca", "ca"]
channels_to_include = ["leak", "kvs1"]
channels_to_include = ["leak"]
channels_to_include = ["leak", "kqt3"]
channels_to_include = ["leak", "egl2"]
channels_to_include = ["leak", "kir", "cca", "ca"]
channels_to_include = [
"leak",
"nca",
"shal",
"egl36",
"kir",
"shak",
"cca",
"unc2",
"egl19",
"ca",
"bk",
"slo1",
"bk2",
"slo2",
"kvs1",
"kqt3",
"egl2",
]
for c in channels_to_include:
print("Including channel: %s" % c)
if c == "cca":
c = "cca1"
all_g.remove("g%s" % c)
for p in all_g:
parsed_data["parameters"][p] = 0
new_ode_file = "Test_%s.ode" % cell
# For testing, as some channel gates take quite some time to reach steady state
additional_transient_phase = 2000
parsed_data["settings"]["total"] = 400 + additional_transient_phase
parsed_data["settings"]["trans"] = 0
parsed_data["settings"]["dt"] = 0.005
parsed_data["parameters"]["ton"] = 310 + additional_transient_phase
parsed_data["parameters"]["toff"] = 360 + additional_transient_phase
if short_simulation:
parsed_data["settings"]["total"] = 70
parsed_data["parameters"]["ton"] = 10
parsed_data["parameters"]["toff"] = 60
new_ode = to_xpp(parsed_data, new_ode_file)
mp_fig = "Membrane potentials"
ca_fig = "[Ca2+]"
print("Running XPP file for %s ms..." % parsed_data["settings"]["total"])
chans = [
["egl19", "m", "m_egl19"],
["egl19", "h", "hs_egl19"],
["bk2", "m", "mbk2"],
["unc2", "m", "m_unc2"],
["unc2", "h", "h_unc2"],
["bk", "m", "mbk"],
["slo2", "m", "mslo2"],
["slo1", "m", "mslo1"],
["kir", "m", "m_kir"],
["sk", "m", "m_sk"],
["shak", "m", "m_shak"],
["shak", "h", "h_shak"],
["cca", "m", "m_cca1"],
["cca", "h", "h_cca1"],
]
if cell == "AWCon":
chans = [
["egl19", "m", "m_egl19"],
["egl19", "h", "hs_egl19"],
["bk2", "m", "mbk2"],
["unc2", "m", "m_unc2"],
["unc2", "h", "h_unc2"],
["bk", "m", "mbk"],
["slo2", "m", "mslo2"],
["slo1", "m", "mslo1"],
["kir", "m", "m_kir"],
["sk", "m", "m_sk"],
["shak", "m", "m_shak"],
["shak", "h", "h_shak"],
["cca", "m", "m_cca1"],
["cca", "h", "h_cca1"],
["egl2", "m", "m_egl2"],
["kqt3", "s", "s_kqt3"],
["kqt3", "w", "w_kqt3"],
]
"""
chans = [
["kir", "m", "m_kir"],
["cca", "m", "m_cca1"],
["cca", "h", "h_cca1"],] """
plot_separately = {mp_fig: "v", ca_fig: "ca_intra1"}
for c in chans:
print("Plotting %s" % c)
plot_separately["var %s_%s %s" % (c[0], c[1], c[2])] = c[2]
axes = run_xpp_file(
new_ode_file, plot=True, show_plot_already=False, plot_separately=plot_separately
)
from matplotlib import pyplot as plt
from pyneuroml.pynml import reload_standard_dat_file
data, indices = reload_standard_dat_file("Sim_IClamp_%s.pop_%s.v.dat" % (cell, cell))
t_ms = [t * 1000 for t in data["t"]]
v_mV = [v * 1000 for v in data[0]]
ax = axes[mp_fig]
ax.plot(t_ms, v_mV, label="NeuroML - v", linewidth=0.5)
ax.legend()
data, indices = reload_standard_dat_file("pop_%s_0.caConc.dat" % cell)
ca = [c * 1 for c in data[0]]
ax = axes[ca_fig]
ax.plot(t_ms, ca, label="NeuroML - [Ca2+]", linewidth=0.5)
ax.legend()
for c in chans:
print("Plotting %s" % c)
data, indices = reload_standard_dat_file(
"pop_%s_0.biophys_membraneProperties_%s_chans_%s_%s_%s_q.dat"
% (cell, c[0], cell, c[0], c[1])
)
vv = [v * 1 for v in data[0]]
fig_name = "var %s_%s %s" % (c[0], c[1], c[2])
ax = axes[fig_name]
ax.plot(t_ms, vv, label="NeuroML %s" % fig_name, linewidth=0.5)
ax.legend()
plt.show()