-
Notifications
You must be signed in to change notification settings - Fork 1
/
Th2.hoc
executable file
·452 lines (393 loc) · 15.2 KB
/
Th2.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
449
450
451
452
objref devRi, cells, TCcells, NRTcells, cellLists
objref nodeGids, nodeTCgids, nodeNRTgids, nodeGidLists
objref gids, TCgids, NRTgids, gidLists, gapList
objref ncTCNRTAMPA, ncTCNRTNMDA, ncNRTTCGABAa, ncNRTTCGABAb, ncNRTNRTGABAa
objref delTCNRT, delNRTTC, delNRTNRT, weiTCNRTAMPA, weiTCNRTNMDA, weiNRTTCGABAa, weiNRTTCGABAb, weiNRTNRTGABAa
objref ncTCNRT, ncNRTTC, ncNRTNRT, weiTCNRT, weiNRTTC, weiNRTNRT
objref ncNRTminisAMPAout, ncTCminisGABAaout, ncNRTminisGABAaout
objref ncSpike, tvec, idvec, nil
objref cellLists_Th, nodeGidLists_Th, gidLists_Th, ncTCNRT_Th, ncNRTTC_Th, ncNRTNRT_Th
if (!(name_declared("gid"))) {
gid = 0
}
proc initParam() {local koefWei
koefWei = 1
nTCgids = 0
nNRTgids = 100
ratioTCNRT = 0.10
ratioNRTTC = 0.10
ratioNRTNRT = 0.10
TCNRTfact = koefWei*1*1 // 0.5mV
NRTTCfact = koefWei*1*1
NRTNRTfact = koefWei*1*1
delayTCNRT = 1 // must be >0.6
delayNRTTC = 2.5 // must be >0.6
delayNRTNRT = 1 // must be >0.6
ngids = nTCgids + nNRTgids
combinedSyns = 1 // Combined AMPA+NMDA and GABAa+GABAb synapses for release probs of <1
P_release_Th = 0.8 // Synaptic release probability
synSpread_Th = 5 // Number of synapses formed between any two connecting neurons
gaps = 0 // Gap unctions between NRT cells? 0 - no; 1 - yes.
}
// ------------------------------------------------------------------------
// Create models of single cells:
// ------------------------------------------------------------------------
proc initCells() {
cells = new List()
TCcells = new List()
NRTcells = new List()
cellLists = new List()
cellLists.append(cells)
cellLists.append(TCcells)
cellLists.append(NRTcells)
nodeGids = new Vector()
nodeTCgids = new Vector()
nodeNRTgids = new Vector()
nodeGidLists = new List()
nodeGidLists.append(nodeGids)
nodeGidLists.append(nodeTCgids)
nodeGidLists.append(nodeNRTgids)
gids = new Vector(ngids)
TCgids = new Vector(nTCgids)
NRTgids = new Vector(nNRTgids)
gidLists = new List()
gidLists.append(gids)
gidLists.append(TCgids)
gidLists.append(NRTgids)
startGid = gid
}
proc riCells() {
devRi = new Vector(ngids)
if (pc.id == 0) {
if (randomise.x[1]) {
{r.Random123(randomInstance,0)}
r.normal(0,1)
for i = 0, ngids-1 {
devRi.x[i] = normRepick(r)
}
randomInstance += 1
}
}
if (pProc) {
{pc.barrier()}
pc.broadcast(devRi, 0)
}
}
proc setRi() { // $o1 - cell object; $2 - SD of Ri
if (randomise.x[1] == 1) {
x = normRepick(r)
$o1.soma.g_pas(0.5) = $o1.soma.g_pas(0.5) + $2*devRi.x[gid-startGid]
}
}
proc createMini() { // $o1 - a cell; $2 - number of AMPA synapses per cell; $3 - number of GABAAsynapses per cell.
if (randomise.x[4]) {
$o1.createMini("AMPA", $2)
$o1.createMini("GABAa", $3)
}
}
obfunc pickCell() {localobj cell
if (gid-startGid <= nTCgids-1) {
cell = new TCcell(gid)
setRi(cell, 0.0000005)
TCcells.append(cell)
createMini(cell, 1, nNRTgids*ratioNRTTC*synSpread_Th*P_release_Th)
nodeTCgids.append(gid)
} else {
cell = new NRTcell(gid)
setRi(cell, 0.0000005)
NRTcells.append(cell)
createMini(cell, nTCgids*ratioTCNRT*synSpread_Th*P_release_Th, (nNRTgids*ratioNRTNRT-1)*synSpread_Th*P_release_Th)
nodeNRTgids.append(gid)
}
return cell
}
proc instantiateCells() {localobj cell, nc
tvec = new Vector() // will be Vectors that record all spike times (tvec)
idvec = new Vector() // and the corresponding id numbers of the cells that spiked (idvec)
ncSpike = new List()
if (pProc) {
for cellitr(&gid, pc) {
pc.set_gid2node(gid, pc.id)
cell = pickCell()
nc = cell.connect2target(nil, 1, 1)
pc.cell(gid, nc)
//pc.spike_record(gid, tvec, idvec)
ncSpike.append(nc)
cells.append(cell)
nodeGids.append(gid)
}
} else {
for gid = startGid, startGid+ngids-1 {
cell = pickCell()
nc = cell.connect2target(nil, 1, 1)
//nc.record(tvec, idvec)
ncSpike.append(nc)
cells.append(cell)
nodeGids.append(gid)
}
}
for gid = startGid, startGid+ngids-1 {
if (gid-startGid <= nTCgids-1) {
TCgids.x[gid-startGid] = gid
} else {
NRTgids.x[gid-startGid-nTCgids] = gid
}
gids.x[gid-startGid] = gid
}
}
proc createCells() {
initCells()
riCells()
instantiateCells()
}
// ------------------------------------------------------------------------
// Create the network:
// ------------------------------------------------------------------------
proc delNet() {local i, x // Set the synaptic delays
delTCNRT = new Vector(round(nTCgids*ratioTCNRT*nNRTgids*synSpread_Th))
delNRTTC = new Vector(round(nNRTgids*ratioNRTTC*nTCgids*synSpread_Th))
delNRTNRT = new Vector(round((nNRTgids*ratioNRTNRT-1)*nNRTgids*synSpread_Th))
if ((pProc && pc.id == 0) || !pProc) {
if (randomise.x[2]) {
{r.Random123(randomInstance,0)}
r.normal(0,1)
for i = 0,delTCNRT.size()-1 {
x = normRepick(r)
delTCNRT.x[i] = delayTCNRT + 0.2*delayTCNRT*x
if (delTCNRT.x[i] < 1) {
delTCNRT.x[i] = 1
}
}
for i = 0,delNRTTC.size()-1 {
x = normRepick(r)
delNRTTC.x[i] = delayNRTTC + 0.2*delayNRTTC*x
if (delNRTTC.x[i] < 1) {
delNRTTC.x[i] = 1
}
}
for i = 0,delNRTNRT.size()-1 {
x = normRepick(r)
delNRTNRT.x[i] = delayNRTNRT + 0.2*delayNRTNRT*x
if (delNRTNRT.x[i] < 1) {
delNRTNRT.x[i] = 1
}
}
randomInstance += 1
} else {
for i = 0,delTCNRT.size()-1 {
delTCNRT.x[i] = delayTCNRT
if (delTCNRT.x[i] < 1) {
delTCNRT.x[i] = 1
}
}
for i = 0,delNRTTC.size()-1 {
delNRTTC.x[i] = delayNRTTC
if (delNRTTC.x[i] < 1) {
delNRTTC.x[i] = 1
}
}
for i = 0,delNRTNRT.size()-1 {
delNRTNRT.x[i] = delayNRTNRT
if (delNRTNRT.x[i] < 1) {
delNRTNRT.x[i] = 1
}
}
}
}
if (pProc) {
{pc.barrier()}
pc.broadcast(delTCNRT, 0)
pc.broadcast(delNRTTC, 0)
pc.broadcast(delNRTNRT, 0)
}
}
proc weiNet() {local i, x // Set the synaptic weights
if (combinedSyns || randomise.x[5]) {
weiTCNRT = new Vector(round(nTCgids*ratioTCNRT*nNRTgids*synSpread_Th))
weiNRTTC = new Vector(round(nNRTgids*ratioNRTTC*nTCgids*synSpread_Th))
weiNRTNRT = new Vector(round((nNRTgids*ratioNRTNRT-1)*nNRTgids*synSpread_Th))
if ((pProc && pc.id == 0) || !pProc) {
if (randomise.x[3]) {
{r.Random123(randomInstance,0)}
r.normal(0,1)
for i = 0,weiTCNRT.size()-1 {
x = normRepick(r)
weiTCNRT.x[i] = testWei((1 + 0.05*x)*TCNRTfact)
}
for i = 0,weiNRTTC.size()-1 {
x = normRepick(r)
weiNRTTC.x[i] = testWei((1 + 0.05*x)*NRTTCfact)
}
for i = 0,weiNRTNRT.size()-1 {
x = normRepick(r)
weiNRTNRT.x[i] = testWei((1 + 0.05*x)*NRTNRTfact)
}
randomInstance += 1
} else {
for i = 0,weiTCNRT.size()-1 {
weiTCNRT.x[i] = testWei(TCNRTfact)
}
for i = 0,weiNRTTC.size()-1 {
weiNRTTC.x[i] = testWei(NRTTCfact)
}
for i = 0,weiNRTNRT.size()-1 {
weiNRTNRT.x[i] = testWei(NRTNRTfact)
}
}
}
if (pProc) {
{pc.barrier()}
pc.broadcast(weiTCNRT, 0)
pc.broadcast(weiNRTTC, 0)
pc.broadcast(weiNRTNRT, 0)
}
} else {
weiTCNRTAMPA = new Vector(round(nTCgids*ratioTCNRT*nNRTgids*synSpread_Th))
weiTCNRTNMDA = new Vector(round(nTCgids*ratioTCNRT*nNRTgids*synSpread_Th))
weiNRTTCGABAa = new Vector(round(nNRTgids*ratioNRTTC*nTCgids*synSpread_Th))
weiNRTTCGABAb = new Vector(round(nNRTgids*ratioNRTTC*nTCgids*synSpread_Th))
weiNRTNRTGABAa = new Vector(round((nNRTgids*ratioNRTNRT-1)*nNRTgids*synSpread_Th))
if ((pProc && pc.id == 0) || !pProc) {
if (randomise.x[3]) {
{r.Random123(randomInstance,0)}
r.normal(0,1)
for i = 0,weiTCNRTAMPA.size()-1 {
x = normRepick(r)
weiTCNRTAMPA.x[i] = testWei((1 + 0.05*x)*TCNRTfact)
//x = normRepick(r)
weiTCNRTNMDA.x[i] = testWei((1 + 0.05*x)*TCNRTfact)
}
for i = 0,weiNRTTCGABAa.size()-1 {
x = normRepick(r)
weiNRTTCGABAa.x[i] = testWei((1 + 0.05*x)*NRTTCfact)
//x = normRepick(r)
weiNRTTCGABAb.x[i] = testWei((1 + 0.05*x)*NRTTCfact)
}
for i = 0,weiNRTNRTGABAa.size()-1 {
x = normRepick(r)
weiNRTNRTGABAa.x[i] = testWei((1 + 0.05*x)*NRTNRTfact)
}
randomInstance += 1
} else {
for i = 0,weiTCNRTAMPA.size()-1 {
weiTCNRTAMPA.x[i] = testWei(TCNRTfact)
weiTCNRTNMDA.x[i] = testWei(TCNRTfact)
}
for i = 0,weiNRTTCGABAa.size()-1 {
weiNRTTCGABAa.x[i] = testWei(NRTTCfact)
weiNRTTCGABAb.x[i] = testWei(NRTTCfact)
}
for i = 0,weiNRTNRTGABAa.size()-1 {
weiNRTNRTGABAa.x[i] = testWei(NRTNRTfact)
}
}
}
if (pProc) {
{pc.barrier()}
pc.broadcast(weiTCNRTAMPA, 0)
pc.broadcast(weiTCNRTNMDA, 0)
pc.broadcast(weiNRTTCGABAa, 0)
pc.broadcast(weiNRTTCGABAb, 0)
pc.broadcast(weiNRTNRTGABAa, 0)
}
}
}
proc connectNet() {
if (combinedSyns || randomise.x[5]) {
// Create TC-NRT AMPA and NMDA synapses and connect them to the source:
createSyns(NRTcells, nodeNRTgids, "GLU", P_release_Th, pc)
ncTCNRT = connectSynsVar(TCcells, TCgids, NRTcells, NRTgids, ratioTCNRT, "GLU", delTCNRT, weiTCNRT, 1, pc, randomise.x[4], synSpread_Th, P_release_Th)
if (randomise.x[4]) {
weight = 1 //
ncNRTminisAMPAout = connectMinis(NRTcells, 0.6, weight, "GLU")
ncTCNRT.append(ncNRTminisAMPAout)
}
// Create TC AMPA and NMDA synapses:
createSyns(TCcells, nodeTCgids, "GLU", P_release_Th, pc)
// Create NRT-TC GABAa and GABAb synapses and connect them to the source:
ncNRTTC = connectSynsVar(NRTcells, NRTgids, TCcells, TCgids, ratioNRTTC, "GABA", delNRTTC, weiNRTTC, 1, pc, randomise.x[4], synSpread_Th, P_release_Th)
if (randomise.x[4]) {
weight = 1 //
ncTCminisGABAaout = connectMinis(TCcells, 0.6, weight, "GABA")
ncNRTTC.append(ncTCminisGABAaout)
}
// Create NRT-NRT GABAa synapses and connect them to the source:
createSyns(NRTcells, nodeNRTgids, "GABAa", P_release_Th, pc)
ncNRTNRT = connectSynsVar(NRTcells, NRTgids, NRTcells, NRTgids, ratioNRTNRT, "GABAa", delNRTNRT, weiNRTNRT, 0, pc, randomise.x[4], synSpread_Th, P_release_Th)
if (randomise.x[4]) {
weight = 1 //
ncNRTminisGABAaout = connectMinis(NRTcells, 0.6, weight, "GABAa")
ncNRTNRT.append(ncNRTminisGABAaout)
}
} else {
// Create TC-NRT AMPA synapses and connect them to the source:
createSyns(NRTcells, nodeNRTgids, "AMPA", P_release_Th, pc)
ncTCNRTAMPA = connectSynsVar(TCcells, TCgids, NRTcells, NRTgids, ratioTCNRT, "AMPA", delTCNRT, weiTCNRTAMPA, 1, pc, randomise.x[4], synSpread_Th, P_release_Th)
if (randomise.x[4]) {
weight = 1 //
ncNRTminisAMPAout = connectMinis(NRTcells, 0.6, weight, "AMPA")
ncTCNRTAMPA.append(ncNRTminisAMPAout)
}
// Create TC-NRT NMDA synapses and connect them to the source:
createSyns(NRTcells, nodeNRTgids, "NMDA", P_release_Th, pc)
ncTCNRTNMDA = connectSynsVar(TCcells, TCgids, NRTcells, NRTgids, ratioTCNRT, "NMDA", delTCNRT, weiTCNRTNMDA, 1, pc, randomise.x[4], synSpread_Th, P_release_Th)
ncTCNRT = new List()
ncTCNRT.append(ncTCNRTAMPA)
ncTCNRT.append(ncTCNRTNMDA)
// Create TC AMPA synapses:
createSyns(TCcells, nodeTCgids, "AMPA", P_release_Th, pc)
// Create TC NMDA synapses:
createSyns(TCcells, nodeTCgids, "NMDA", P_release_Th, pc)
// Create NRT-TC GABAa synapses and connect them to the source:
createSyns(TCcells, nodeTCgids, "GABAa", P_release_Th, pc)
ncNRTTCGABAa = connectSynsVar(NRTcells, NRTgids, TCcells, TCgids, ratioNRTTC, "GABAa", delNRTTC, weiNRTTCGABAa, 1, pc, randomise.x[4], synSpread_Th, P_release_Th)
if (randomise.x[4]) {
weight = 1 //
ncTCminisGABAaout = connectMinis(TCcells, 0.6, weight, "GABAa")
ncNRTTCGABAa.append(ncTCminisGABAaout)
}
// Create NRT-TC GABAb synapses and connect them to the source:
ncNRTTCGABAb = connectSynsVar(NRTcells, NRTgids, TCcells, TCgids, ratioNRTTC, "GABAb", delNRTTC, weiNRTTCGABAb, 1, pc, randomise.x[4], synSpread_Th, P_release_Th)
ncNRTTC = new List()
ncNRTTC.append(ncNRTTCGABAa)
ncNRTTC.append(ncNRTTCGABAb)
// Create NRT-NRT GABAa synapses and connect them to the source:
createSyns(NRTcells, nodeNRTgids, "GABAa", P_release_Th, pc)
ncNRTNRTGABAa = connectSynsVar(NRTcells, NRTgids, NRTcells, NRTgids, ratioNRTNRT, "GABAa", delNRTNRT, weiNRTNRTGABAa, 0, pc, randomise.x[4], synSpread_Th, P_release_Th)
if (randomise.x[4]) {
weight = 1 //
ncNRTminisGABAaout = connectMinis(NRTcells, 0.6, weight, "GABAa")
ncNRTNRTGABAa.append(ncTCminisGABAaout)
}
}
// Create gap junctions:
if (gaps) {
gapList = createGaps(1e9, NRTcells, nodeNRTgids, NRTgids, pc)
varDt_local = 0
}
}
proc createNet() {
delNet()
weiNet()
connectNet()
}
proc setLists() {
ratioTCNRT_Th = ratioTCNRT
ratioNRTTC_Th = ratioNRTTC
ratioNRTNRT_Th = ratioNRTNRT
cellLists_Th = cellLists
nodeGidLists_Th = nodeGidLists
gidLists_Th = gidLists
ncTCNRT_Th = ncTCNRT
ncNRTTC_Th = ncNRTTC
ncNRTNRT_Th = ncNRTNRT
}
proc createTh() {
initParam()
createCells()
//createNet()
setLists()
}
if (isTh) {
createTh()
}