-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathNRTdata.hoc
executable file
·448 lines (418 loc) · 21.8 KB
/
NRTdata.hoc
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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
/* A class for handling recorded NRT data. Inputs:
$o1 - a NRT cell to be recorded;
$o2 - a voltage clamp object;
$3 - a scalar indicating the size of the data file: 1 - full, 0 - minimal.
Contains a public procedure 'save' for saving the data. Inputs:
$s1 - the name (string) of the data file including its format extension
for saving simulation data. */
begintemplate NRTdata
public save, saveIAHP, rect, recv, recIVC, reci
external cvode, varDt, varDt_local, expandList
objref cell, rect, recv, recIVC, reci, recIKleak, recINaleak, recINa, recINam, recINah, recIK, recIKn
objref recCai, recCahvai, recICa, recICam, recICah, recIh, recIho1, recIho2, recIhp1, recIAHP, recIAHPm1, recIAHPm2
objref recICAN, recICANp1, recICANo, recINaPm, recNai, recIKNaw, recIHVA, recIHVAm
objref recAMPA, recNMDA, recmGluR1a, recmGluR1a_R, recmGluR1a_G, GLUfullsynList, recGABAa, GABAAsyn
objref recGaps, gapList
proc initGLUfull() {local i, count localobj synGLU, synGLUfull // $o1 - the cell object
if (dataGlu) { // Excitatory synaptic current data
synGLU = $o1.getSyn("GLU")
synGLUfull = $o1.getSyn("GLUfull")
if (object_id(synGLU,1) != -1 || object_id(synGLUfull,1) != -1) {
recAMPA = new List() // rec I_AMPA
recNMDA = new List() // rec I_NMDA
access cell.soma
count = 0
GLUfullsynList = $o1.getSynList("GLUfull")
if (GLUfullsynList.count()) {
recmGluR1a = new List() // rec I_mGluR1a
recmGluR1a_R = new List() // rec I_mGluR1a R state
recmGluR1a_G = new List() // rec I_mGluR1a G state
if (varDt) {
for i = 0, GLUfullsynList.count()-1 {
recAMPA = expandList(recAMPA)
cvode.record(&GLUfullsynList.o(i).iAMPA, recAMPA.o(i), rect)
recNMDA = expandList(recNMDA)
cvode.record(&GLUfullsynList.o(i).iNMDA, recNMDA.o(i), rect)
recmGluR1a = expandList(recmGluR1a)
cvode.record(&GLUfullsynList.o(i).iKLeak, recmGluR1a.o(i), rect)
recmGluR1a_R = expandList(recmGluR1a_R)
cvode.record(&GLUfullsynList.o(i).R_c, recmGluR1a_R.o(i), rect)
recmGluR1a_G = expandList(recmGluR1a_G)
cvode.record(&GLUfullsynList.o(i).G_c, recmGluR1a_G.o(i), rect)
count += 1
}
} else {
for i = 0, GLUfullsynList.count()-1 {
recAMPA = expandList(recAMPA)
recAMPA.o(i).record(&GLUfullsynList.o(i).iAMPA)
recNMDA = expandList(recNMDA)
recNMDA.o(i).record(&GLUfullsynList.o(i).iNMDA)
recmGluR1a = expandList(recmGluR1a)
recmGluR1a.o(i).record(&GLUfullsynList.o(i).iKLeak)
recmGluR1a_R = expandList(recmGluR1a_R)
recmGluR1a_R.o(i).record(&GLUfullsynList.o(i).R_c)
recmGluR1a_G = expandList(recmGluR1a_G)
recmGluR1a_G.o(i).record(&GLUfullsynList.o(i).G_c)
count += 1
}
}
}
if (object_id(synGLU,1) != -1) {
if (varDt) {
recAMPA = expandList(recAMPA)
cvode.record(&synGLU.iAMPA, recAMPA.o(count), rect)
recNMDA = expandList(recNMDA)
cvode.record(&synGLU.iNMDA, recNMDA.o(count), rect)
} else {
recAMPA = expandList(recAMPA)
recAMPA.o(count).record(&synGLU.iAMPA)
recNMDA = expandList(recNMDA)
recNMDA.o(count).record(&synGLU.iNMDA)
}
}
}
}
}
proc initGABA() { // $o1 - the cell object
if (dataGABA) { // Inhibitory synaptic current data
GABAAsyn = $o1.getSyn("GABAa")
if (object_id(GABAAsyn,1) != -1) {
recGABAa = new Vector()
access cell.soma
if (varDt) {
cvode.record(&GABAAsyn.i, recGABAa, rect)
} else {
recGABAa.record(&GABAAsyn.i)
}
}
}
}
proc initGaps() {local i // $o1 - the cell object
if (dataGaps) { // Gap junction current data
gapList = cell.getGapList()
if (gapList.count()) {
recGaps = new List()
access cell.soma
for i = 0, gapList.count()-1 {
recGaps = expandList(recGaps)
if (varDt) {
cvode.record(&gapList.o(i).i, recGaps.o(i), rect)
} else {
recGaps.o(i).record(&gapList.o(i).i)
}
}
}
}
}
proc init() {
cell = $o1
access cell.soma
for (i = 609; i <= 889; i += 20) {
if (cell.gid == i && $3 != 30) {
bigData = $3
break
} else {
bigData = $3
}
}
rect = new Vector() // record time
recv = new Vector() // record membrane potential
if (bigData == 10) {
dataVClamp = 1
dataNil = 1
dataExC = 1
dataIL = 1
dataINa = 1
dataIK = 1
dataICa = 1
dataIh = 1
dataIAHP = 1
dataICAN = 1
dataINaP = 1
dataIKNa = 1
dataIHVA = 1
dataGlu = 1
dataGABA = 1
dataGaps = 1
rect = new Vector() // record time
cell = $o1
access cell.soma
if (dataVClamp && object_id($o2,1) != -1) { // Voltage clamp
recIVC = new Vector() // record voltage clamp current
if (varDt) {
cvode.record(&$o2.i, recIVC, rect)
} else {
recIVC.record(&$o2.i)
}
}
if (dataNil) { // Basic data
recv = new Vector() // record membrane potential
if (varDt) {
cvode.record(&cell.soma.v(0.5), recv, rect)
} else {
rect.record(&t)
recv.record(&cell.soma.v(0.5))
}
}
if (dataExC && !varDt) { // Basic data 2
reci = new Vector() // record total membrane current
if (varDt) {
cvode.record(&cell.soma.i_membrane(0.5), reci, rect)
} else {
reci.record(&cell.soma.i_membrane(0.5))
}
}
if (dataIL) { // Leak data
recIKleak = new Vector() // record K+ leak current
recINaleak = new Vector() // record Na+ leak current
if (varDt) {
cvode.record(&cell.soma.i_pas(0.5), recIKleak, rect)
cvode.record(&cell.soma.i_naleak(0.5), recINaleak, rect)
} else {
recIKleak.record(&cell.soma.i_pas(0.5))
recINaleak.record(&cell.soma.i_naleak(0.5))
}
}
if (dataINa) { // I_Na current data
recINa = new Vector() // record Na+ current
recINam = new Vector() // activation state
recINah = new Vector() // inactivation state
if (varDt) {
cvode.record(&cell.soma.ina(0.5), recINa, rect)
cvode.record(&cell.soma.m_hhT(0.5), recINam, rect)
cvode.record(&cell.soma.h_hhT(0.5), recINah, rect)
} else {
recINa.record(&cell.soma.ina(0.5))
recINam.record(&cell.soma.m_hhT(0.5))
recINah.record(&cell.soma.h_hhT(0.5))
}
}
if (dataIK) { // I_K(DR) current data
recIK = new Vector() // record K+ current
recIKn = new Vector() // activation state
if (varDt) {
cvode.record(&cell.soma.ik(0.5), recIK, rect)
cvode.record(&cell.soma.n_hhT(0.5), recIKn, rect)
} else {
recIK.record(&cell.soma.ik(0.5))
recIKn.record(&cell.soma.n_hhT(0.5))
}
}
if (dataICa) { // Ca2+ current data
recCai = new Vector() // record intracellular [Ca2+] associated with IT
recICa = new Vector() // record Ca2+ current
recICam = new Vector() // activation state
recICah = new Vector() // inactivation state
if (varDt) {
cvode.record(&cell.soma.cai(0.5), recCai, rect)
cvode.record(&cell.soma.ica(0.5), recICa, rect)
cvode.record(&cell.soma.m_its(0.5), recICam, rect)
cvode.record(&cell.soma.h_its(0.5), recICah, rect)
} else {
recCai.record(&cell.soma.cai(0.5))
recICa.record(&cell.soma.ica(0.5))
recICam.record(&cell.soma.m_its(0.5))
recICah.record(&cell.soma.h_its(0.5))
}
}
if (dataIh) { // I_h current data
recIh = new Vector() // record anomalous rectifier current
recIho1 = new Vector() // normal activation state
recIho2 = new Vector() // increased conductance activation state
recIhp1 = new Vector() // proportion of bound calcium-binding (CB) protein
if (varDt) {
cvode.record(&cell.soma.ih(0.5), recIh, rect)
cvode.record(&cell.soma.o1_iarg(0.5), recIho1, rect)
cvode.record(&cell.soma.o2_iarg(0.5), recIho2, rect)
cvode.record(&cell.soma.p1_iarg(0.5), recIhp1, rect)
} else {
recIh.record(&cell.soma.ih(0.5))
recIho1.record(&cell.soma.o1_iarg(0.5))
recIho2.record(&cell.soma.o2_iarg(0.5))
recIhp1.record(&cell.soma.p1_iarg(0.5))
}
}
if (dataIAHP) { // I_AHP current data
recIAHP = new Vector() // record Ca2+ activated hyperpolarising K+ current
recIAHPm1 = new Vector() // record the fast activating component
recIAHPm2 = new Vector() // record the slow activating component
if (varDt) {
cvode.record(&cell.soma.ikb(0.5), recIAHP, rect)
cvode.record(&cell.soma.m1_iahp(0.5), recIAHPm1, rect)
cvode.record(&cell.soma.m2_iahp(0.5), recIAHPm2, rect)
} else {
recIAHP.record(&cell.soma.ikb(0.5))
recIAHPm1.record(&cell.soma.m1_iahp(0.5))
recIAHPm2.record(&cell.soma.m2_iahp(0.5))
}
}
if (dataICAN) { // I_CAN current data
recICAN = new Vector() // record nonspecific cation current CAN
recICANp1 = new Vector() // levels of Ca2+-bound messenger protein
recICANo = new Vector() // proportion of open channels
if (varDt) {
cvode.record(&cell.soma.in(0.5), recICAN, rect)
//cvode.record(&cell.soma.p1_ican(0.5), recICANp1, rect)
//cvode.record(&cell.soma.o_ican(0.5), recICANo, rect)
cvode.record(&cell.soma.mCa_icanmNRT(0.5), recICANp1, rect)
cvode.record(&cell.soma.mCa_icanmNRT(0.5), recICANo, rect)
} else {
recICAN.record(&cell.soma.in(0.5))
//recICANp1.record(&cell.soma.p1_ican(0.5))
//recICANo.record(&cell.soma.o_ican(0.5))
recICANp1.record(&cell.soma.mCa_icanmNRT(0.5))
recICANo.record(&cell.soma.mCa_icanmNRT(0.5))
}
}
if (dataINaP) {
recINaPm = new Vector()
if (varDt) {
cvode.record(&cell.soma.m_inap(0.5), recINaPm, rect)
} else {
recINaPm.record(&cell.soma.m_inap(0.5))
}
}
if (dataIKNa) { // I_K[Na] current data
recNai = new Vector() // record intracellular [Na+]
recIKNaw = new Vector() // activation state
if (varDt) {
cvode.record(&cell.soma.nai(0.5), recNai, rect)
cvode.record(&cell.soma.w_inf_iknaThCx(0.5), recIKNaw, rect)
} else {
recNai.record(&cell.soma.nai(0.5))
recIKNaw.record(&cell.soma.w_inf_iknaThCx(0.5))
}
}
if (dataIHVA) { // I_HVA current data
recCahvai = new Vector() // record intracellular [Ca2+] associated with IHVA
recIHVA = new Vector() // record high threshold Ca2+ current
recIHVAm = new Vector() // record high threshold Ca2+ current activation component
if (varDt) {
cvode.record(&cell.soma.cahvai(0.5), recCahvai, rect)
cvode.record(&cell.soma.icahva(0.5), recIHVA, rect)
cvode.record(&cell.soma.m_ihvaNRT(0.5), recIHVAm, rect)
} else {
recCahvai.record(&cell.soma.cahvai(0.5))
recIHVA.record(&cell.soma.icahva(0.5))
recIHVAm.record(&cell.soma.m_ihvaNRT(0.5))
}
}
initGLUfull(cell)
initGABA(cell)
initGaps(cell)
} else if (bigData == 11 || bigData == 20 || bigData == 50) {
if (varDt) {
cvode.record(&cell.soma.v(0.5), recv, rect)
} else {
rect.record(&t)
recv.record(&cell.soma.v(0.5))
}
}
}
proc save() {local i localobj savData, dataMatrix
savData = new File()
savData.wopen($s1)
dataMatrix = new Matrix()
if (bigData == 10) {
if (varDt || varDt_local) {
subtract = 0
dataMatrix.resize(38, rect.size())
if (object_id(rect,1) != -1) { dataMatrix.setrow(0, rect) }
} else {
subtract = 1
dataMatrix.resize(37, rect.size())
}
if (object_id(recv,1) != -1) { dataMatrix.setrow(1-subtract, recv) }
if (object_id(recIVC,1) != -1) { dataMatrix.setrow(2-subtract, recIVC) }
if (object_id(reci,1) != -1) { dataMatrix.setrow(3-subtract, reci) }
if (object_id(recIKleak,1) != -1) { dataMatrix.setrow(4-subtract, recIKleak) }
if (object_id(recINaleak,1) != -1) { dataMatrix.setrow(5-subtract, recINaleak) }
if (object_id(recINa,1) != -1) { dataMatrix.setrow(6-subtract, recINa) }
if (object_id(recINam,1) != -1) { dataMatrix.setrow(7-subtract, recINam) }
if (object_id(recINah,1) != -1) { dataMatrix.setrow(8-subtract, recINah) }
if (object_id(recIK,1) != -1) { dataMatrix.setrow(9-subtract, recIK) }
if (object_id(recIKn,1) != -1) { dataMatrix.setrow(10-subtract, recIKn) }
if (object_id(recCai,1) != -1) { dataMatrix.setrow(11-subtract, recCai) }
if (object_id(recCahvai,1) != -1) { dataMatrix.setrow(12-subtract, recCahvai) }
if (object_id(recICa,1) != -1) { dataMatrix.setrow(13-subtract, recICa) }
if (object_id(recICam,1) != -1) { dataMatrix.setrow(14-subtract, recICam) }
if (object_id(recICah,1) != -1) { dataMatrix.setrow(15-subtract, recICah) }
if (object_id(recIh,1) != -1) { dataMatrix.setrow(16-subtract, recIh) }
if (object_id(recIho1,1) != -1) { dataMatrix.setrow(17-subtract, recIho1) }
if (object_id(recIho2,1) != -1) { dataMatrix.setrow(18-subtract, recIho2) }
if (object_id(recIhp1,1) != -1) { dataMatrix.setrow(19-subtract, recIhp1) }
if (object_id(recIAHP,1) != -1) { dataMatrix.setrow(20-subtract, recIAHP) }
if (object_id(recIAHPm1,1) != -1) { dataMatrix.setrow(21-subtract, recIAHPm1) }
if (object_id(recIAHPm2,1) != -1) { dataMatrix.setrow(22-subtract, recIAHPm2) }
if (object_id(recICAN,1) != -1) { dataMatrix.setrow(23-subtract, recICAN) }
if (object_id(recICANp1,1) != -1) { dataMatrix.setrow(24-subtract, recICANp1) }
if (object_id(recICANo,1) != -1) { dataMatrix.setrow(25-subtract, recICANo) }
if (object_id(recINaPm,1) != -1) { dataMatrix.setrow(26-subtract, recINaPm) }
if (object_id(recNai,1) != -1) { dataMatrix.setrow(27-subtract, recNai) }
if (object_id(recIKNaw,1) != -1) { dataMatrix.setrow(28-subtract, recIKNaw) }
if (object_id(recIHVA,1) != -1) { dataMatrix.setrow(29-subtract, recIHVA) }
if (object_id(recIHVAm,1) != -1) { dataMatrix.setrow(30-subtract, recIHVAm) }
if (object_id(recAMPA,1) != -1) {
for i = 1, recAMPA.count()-1 {
{ recAMPA.o(0).add(recAMPA.o(i)) }
{ recNMDA.o(0).add(recNMDA.o(i)) }
}
dataMatrix.setrow(31-subtract, recAMPA.o(0))
dataMatrix.setrow(32-subtract, recNMDA.o(0))
}
if (object_id(recmGluR1a,1) != -1) {
for i = 1, recmGluR1a.count()-1 {
{ recmGluR1a.o(0).add(recmGluR1a.o(i)) }
{ recmGluR1a_R.o(0).add(recmGluR1a_R.o(i)) }
{ recmGluR1a_G.o(0).add(recmGluR1a_G.o(i)) }
}
dataMatrix.setrow(33-subtract, recmGluR1a.o(0))
dataMatrix.setrow(4-subtract, recmGluR1a.o(0))
dataMatrix.setrow(34-subtract, recmGluR1a_R.o(0))
dataMatrix.setrow(35-subtract, recmGluR1a_G.o(0))
}
if (object_id(recGABAa,1) != -1) { dataMatrix.setrow(36-subtract, recGABAa) }
if (object_id(recGaps,1) != -1) {
for i = 1, recGaps.count()-1 {
{ recGaps.o(0).add(recGaps.o(i)) }
}
dataMatrix.setrow(37-subtract, recGaps.o(0))
}
} else if (bigData == 11 || bigData == 20 || bigData == 50) {
if (varDt || varDt_local) {
dataMatrix.resize(2, rect.size())
if (object_id(rect,1) != -1) { dataMatrix.setrow(0, rect) }
if (object_id(recv,1) != -1) { dataMatrix.setrow(1, recv) }
} else {
dataMatrix.resize(1, rect.size())
if (object_id(recv,1) != -1) { dataMatrix.setrow(0, recv) }
}
}
dataMatrix.fprint(savData, "%g\t")
savData.close()
}
proc saveIAHP() {localobj savData, dataMatrix
savData = new File()
savData.wopen($s1)
dataMatrix = new Matrix()
if (bigData == 10) {
dataMatrix.resize(10, rect.size())
if (object_id(rect,1) != -1) { dataMatrix.setrow(0, rect) }
if (object_id(recv,1) != -1) { dataMatrix.setrow(1, recv) }
if (object_id(recIVC,1) != -1) { dataMatrix.setrow(2, recIVC) }
if (object_id(recCai,1) != -1) { dataMatrix.setrow(3, recCai) }
if (object_id(recCahvai,1) != -1) { dataMatrix.setrow(4, recCahvai) }
if (object_id(recICa,1) != -1) { dataMatrix.setrow(5, recICa) }
if (object_id(recIHVA,1) != -1) { dataMatrix.setrow(6, recIHVA) }
if (object_id(recIAHP,1) != -1) { dataMatrix.setrow(7, recIAHP) }
if (object_id(recIAHPm1,1) != -1) { dataMatrix.setrow(8, recIAHPm1) }
if (object_id(recIAHPm2,1) != -1) { dataMatrix.setrow(9, recIAHPm2) }
} else if (bigData == 20) {
dataMatrix.resize(2, rect.size())
if (object_id(rect,1) != -1) { dataMatrix.setrow(0, rect) }
if (object_id(recv,1) != -1) { dataMatrix.setrow(1, recv) }
}
dataMatrix.fprint(savData, "%g\t")
savData.close()
}
endtemplate NRTdata