forked from ModelDBRepository/127388
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pBGstim.hoc
518 lines (364 loc) · 12 KB
/
pBGstim.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
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
//----------------------------------------------------------------------------
// Initialize global variables
//----------------------------------------------------------------------------
/* COMMENTS see DBS_stim.txt */
DBS_STN = 0
DBS_STNGPe = 1
DBS_STNGPi = 2
DBS_GPeSTN = 3
DBS_GPeGPi = 4
DBS_GPeGPe = 5
DBS_GPiTha = 6
numDBS = 7
objref dbsONflags[numDBS],dbs_activationProb[numDBS], dbs_gidOffset
for tmpi=0,numDBS-1 {
dbsONflags[tmpi] = new Vector() //array of vectors containing indices into dbsStim object arrays
}
dbs_activationProb[DBS_STN] = new Vector(numSTN, 0.8)
dbs_activationProb[DBS_STNGPe] = new Vector(numSTN, 0.8)
dbs_activationProb[DBS_STNGPi] = new Vector(numSTN, 0.8)
dbs_activationProb[DBS_GPeSTN] = new Vector(numGPe, 0.8)
dbs_activationProb[DBS_GPeGPi] = new Vector(numGPe, 0.8)
dbs_activationProb[DBS_GPeGPe] = new Vector(numGPe, 0.8)
dbs_activationProb[DBS_GPiTha] = new Vector(numGPi, 0.8)
//gid offset of artificial cell (dbsStim object) gids, must be beyond those assigned to STN,GPe,GPi cells
// need gid to make connection for orthodromic event to be communicated
if (ncell > 1000) {
print "ERROR - gid overlap in dbsStim.hoc"
}
dbs_gidOffset = new Vector(numDBS)
dbs_gidOffset.x(DBS_STN) = 1000
dbs_gidOffset.x(DBS_STNGPe) = 2000
dbs_gidOffset.x(DBS_STNGPi) = 3000
dbs_gidOffset.x(DBS_GPeSTN) = 4000
dbs_gidOffset.x(DBS_GPeGPi) = 5000
dbs_gidOffset.x(DBS_GPeGPe) = 6000
dbs_gidOffset.x(DBS_GPiTha) = 7000
// ad* objects are dbsSTIM objects that apply a current to their somatic parent and send an event to orthodromic targets
// odnc* objects are pointers to NetCon objects connect an ad* to a target synapse, used to set weights and delays
objref directSTN[numSTN], adSTNGPe[numSTN], adSTNGPi[numSTN], adGPeSTN[numGPe], adGPeGPi[numGPe], adGPeGPe[numGPe], adGPiTha[numGPi]
//orthodromic effects through NetCon from antidromic sources of presyn cells that project to target
objref odncSTNGPe[numGPe], odncSTNGPi[numGPi], odncGPeSTN[numSTN], odncGPeGPi[numGPi], odncGPeGPe[numGPe] //vector of nclist indices for each cell
for tmpi=0,numSTN-1 {
if (pnm.gid_exists(cellID(ID_STN, tmpi))) {
directSTN[tmpi] = new dbsStim()
adSTNGPe[tmpi] = new dbsStim()
adSTNGPi[tmpi] = new dbsStim()
odncGPeSTN[tmpi] = new Vector()
}
}
for tmpi=0,numGPe-1 {
if (pnm.gid_exists(cellID(ID_GPe, tmpi))) {
adGPeSTN[tmpi] = new dbsStim()
adGPeGPi[tmpi] = new dbsStim()
adGPeGPe[tmpi] = new dbsStim()
odncSTNGPe[tmpi] = new Vector()
odncGPeGPe[tmpi] = new Vector()
}
}
for tmpi=0,numGPi-1 {
if (pnm.gid_exists(cellID(ID_GPi, tmpi))) {
adGPiTha[tmpi] = new dbsStim()
odncGPeGPi[tmpi] = new Vector()
odncSTNGPi[tmpi] = new Vector()
}
}
//----------------------------------------------------------------------------
// Functions to set up network from current value of global variables
//----------------------------------------------------------------------------
proc newStimOBJ() {local gid localobj dbs,nc,nil //($1:cell type, $2:index, $3:pathway type, $o4:dbsStim obj)
dbs = $o4
pnm.pc.gid2obj(cellID($1, $2)).soma dbs.loc(.5)
gid = cellID($1, $2) + dbs_gidOffset.x($3) //global id
pnm.pc.set_gid2node(gid, pnm.pc.id())
pnm.cells.append(dbs)
nc = new NetCon(dbs, nil)
pnm.pc.cell(gid, nc)
}
proc newStimNc() {local k,ncIndx localobj dbs,nc //($1:srctype,$2:srcIndx,$3:tartype,$4:tarIndx,$5:synIndx,$6:pathtype,$o7:ncIndx array[.])
//Get dbsStim object associated with presyn cell in this NetCon object.
// When it is antidromically active, its net_event will trigger an
// orthodromic event too, through this NetCon
ncIndx = pnm.nc_append(cellID($1, $2)+dbs_gidOffset.x($6), cellID($3, $4), synNum($1, $3, $5), 0, 0)
if (ncIndx >= 0) {
$o7.append(ncIndx)
}
}
proc STIconnectNet() { local i,j,k
//-----------------------------------------
// connections at/from STN
for i=0,numSTN-1 {
if (pnm.gid_exists(cellID(ID_STN, i))) {
newStimOBJ(ID_STN, i, DBS_STN, directSTN[i])
newStimOBJ(ID_STN, i, DBS_STNGPe, adSTNGPe[i])
newStimOBJ(ID_STN, i, DBS_STNGPi, adSTNGPi[i])
}
}
//-----------------------------------------
// connections from GPe
for i=0,numGPe-1 {
if (pnm.gid_exists(cellID(ID_GPe, i))) {
newStimOBJ(ID_GPe, i, DBS_GPeSTN, adGPeSTN[i])
newStimOBJ(ID_GPe, i, DBS_GPeGPi, adGPeGPi[i])
newStimOBJ(ID_GPe, i, DBS_GPeGPe, adGPeGPe[i])
}
}
//-----------------------------------------
// connections from GPi
for i=0,numGPi-1 {
if (pnm.gid_exists(cellID(ID_GPi, i))) {
newStimOBJ(ID_GPi, i, DBS_GPiTha, adGPiTha[i])
}
}
// Go through synapse lists for each cell (A) and find ad dbsStim objects for each presyn cell (Bs),
// then connect them as presyn objects to that cell (A)
//-----------------------------------------
// orthodromic dbs to STN
for i=0,numSTN-1 {
for j=0,numGPeSTN-1 {
newStimNc(ID_GPe, srcGPeSTN[i].x(j), ID_STN, i, j, DBS_GPeSTN, odncGPeSTN[i])
}
}
//-----------------------------------------
// orthodromic dbs to GPe
for i=0,numGPe-1 {
for j=0,numSTNGPe-1 {
newStimNc(ID_STN, srcSTNGPe[i].x(j), ID_GPe, i, j, DBS_STNGPe, odncSTNGPe[i])
}
for j=0,numGPeGPe-1 {
newStimNc(ID_GPe, srcGPeGPe[i].x(j), ID_GPe, i, j, DBS_GPeGPe, odncGPeGPe[i])
}
}
//-----------------------------------------
// orthodromic dbs to GPi
for i=0,numGPi-1 {
for j=0,numSTNGPi-1 {
newStimNc(ID_STN, srcSTNGPi[i].x(j), ID_GPi, i, j, DBS_STNGPi, odncSTNGPi[i])
}
for j=0,numGPeGPi-1 {
newStimNc(ID_GPe, srcGPeGPi[i].x(j), ID_GPi, i, j, DBS_GPeGPi, odncGPeGPi[i])
}
}
}
//----------------------------------------------------------------------------
proc STIupdateWeights() { local i,j
//-----------------------------------------
// connections at/from STN
for i=0,numSTN-1 {
if (pnm.gid_exists(cellID(ID_STN, i))) {
directSTN[i].del = dbs_del
directSTN[i].dur = dbs_dur
directSTN[i].amp = dbs_direct_amp
directSTN[i].pw = dbs_direct_pw
directSTN[i].period = dbs_period
directSTN[i].actPrb = dbs_activationProb[DBS_STN].x(i)
adSTNGPe[i].del = dbs_del
adSTNGPe[i].dur = dbs_dur
adSTNGPe[i].amp = dbs_ad_amp
adSTNGPe[i].pw = dbs_ad_pw
adSTNGPe[i].period = dbs_period
adSTNGPe[i].actPrb = dbs_activationProb[DBS_STNGPe].x(i)
adSTNGPi[i].del = dbs_del
adSTNGPi[i].dur = dbs_dur
adSTNGPi[i].amp = dbs_ad_amp
adSTNGPi[i].pw = dbs_ad_pw
adSTNGPi[i].period = dbs_period
adSTNGPi[i].actPrb = dbs_activationProb[DBS_STNGPi].x(i)
for j=0,numGPeSTN-1 {
pnm.nclist.o(odncGPeSTN[i].x(j)).weight = gmaxGPeSTN/numGPeSTN
pnm.nclist.o(odncGPeSTN[i].x(j)).weight[1] = 1 //dbs NetCon
pnm.nclist.o(odncGPeSTN[i].x(j)).delay = delGPeSTN
}
}
}
//-----------------------------------------
// connections from GPe
for i=0,numGPe-1 {
if (pnm.gid_exists(cellID(ID_GPe, i))) {
adGPeSTN[i].del = dbs_del
adGPeSTN[i].dur = dbs_dur
adGPeSTN[i].amp = dbs_ad_amp
adGPeSTN[i].pw = dbs_ad_pw
adGPeSTN[i].period = dbs_period
adGPeSTN[i].actPrb = dbs_activationProb[DBS_GPeSTN].x(i)
adGPeGPi[i].del = dbs_del
adGPeGPi[i].dur = dbs_dur
adGPeGPi[i].amp = dbs_ad_amp
adGPeGPi[i].pw = dbs_ad_pw
adGPeGPi[i].period = dbs_period
adGPeGPi[i].actPrb = dbs_activationProb[DBS_GPeGPi].x(i)
adGPeGPe[i].del = dbs_del
adGPeGPe[i].dur = dbs_dur
adGPeGPe[i].amp = dbs_ad_amp
adGPeGPe[i].pw = dbs_ad_pw
adGPeGPe[i].period = dbs_period
adGPeGPe[i].actPrb = dbs_activationProb[DBS_GPeGPe].x(i)
for j=0,numSTNGPe-1 {
pnm.nclist.o(odncSTNGPe[i].x(j)).weight = gmaxSTNGPe/numSTNGPe
pnm.nclist.o(odncSTNGPe[i].x(j)).weight[1] = 1 //dbs NetCon
pnm.nclist.o(odncSTNGPe[i].x(j)).delay = delSTNGPe
}
for j=0,numGPeGPe-1 {
pnm.nclist.o(odncGPeGPe[i].x(j)).weight = gmaxGPeGPe/numGPeGPe
pnm.nclist.o(odncGPeGPe[i].x(j)).weight[1] = 1 //dbs NetCon
pnm.nclist.o(odncGPeGPe[i].x(j)).delay = delGPeGPe
}
}
}
//-----------------------------------------
// connections from GPi
for i=0,numGPi-1 {
if (pnm.gid_exists(cellID(ID_GPi, i))) {
adGPiTha[i].del = dbs_del
adGPiTha[i].dur = dbs_dur
adGPiTha[i].amp = dbs_ad_amp
adGPiTha[i].pw = dbs_ad_pw
adGPiTha[i].period = dbs_period
adGPiTha[i].actPrb = dbs_activationProb[DBS_GPiTha].x(i)
for j=0,numSTNGPi-1 {
pnm.nclist.o(odncSTNGPi[i].x(j)).weight = gmaxSTNGPi/numSTNGPi
pnm.nclist.o(odncSTNGPi[i].x(j)).weight[1] = 1 //dbs NetCon
pnm.nclist.o(odncSTNGPi[i].x(j)).delay = delSTNGPi
}
for j=0,numGPeGPi-1 {
pnm.nclist.o(odncGPeGPi[i].x(j)).weight = gmaxGPeGPi/numGPeGPi
pnm.nclist.o(odncGPeGPi[i].x(j)).weight[1] = 1 //dbs NetCon
pnm.nclist.o(odncGPeGPi[i].x(j)).delay = delGPeGPi
}
}
}
}
strdef pstr
//----------------------------------------------------------------------------
proc dbsRESET() { local i
dbsOFF()
if (pnm.pc.id() == 0) {
// master tells all slave nodes to update network with inputs vector
pnm.pc.look_take("dbsRESET")
pnm.pc.post("dbsRESET")
pnm.pc.context("dbsRESET", 0)
for i=1,pnm.pc.nhost-1 {
sprint(pstr, "dbsRESET%d", i)
pnm.pc.take(pstr)
}
} else {
// slave nodes clear message from master and doit
pnm.pc.look("dbsRESET")
sprint(pstr, "dbsRESET%d", pnm.pc.id())
pnm.pc.post(pstr)
}
for i=0,numDBS-1 {
dbsONflags[i].resize(0)
}
}
//----------------------------------------------------------------------------
proc dbsOFF() { local i
if (pnm.pc.id() == 0) {
// master tells all slave nodes to update network with inputs vector
pnm.pc.look_take("dbsOFF")
pnm.pc.post("dbsOFF")
pnm.pc.context("dbsOFF", 0)
for i=1,pnm.pc.nhost-1 {
sprint(pstr, "dbsOFF%d", i)
pnm.pc.take(pstr)
}
} else {
// slave nodes clear message from master and doit
pnm.pc.look("dbsOFF")
sprint(pstr, "dbsOFF%d", pnm.pc.id())
pnm.pc.post(pstr)
}
// turn all OFF
for i=0,numSTN-1 {
if (pnm.gid_exists(cellID(ID_STN, i))) {
directSTN[i].active = 0
adSTNGPe[i].active = 0
adSTNGPi[i].active = 0
}
}
for i=0,numGPe-1 {
if (pnm.gid_exists(cellID(ID_GPe, i))) {
adGPeSTN[i].active = 0
adGPeGPi[i].active = 0
adGPeGPe[i].active = 0
}
}
for i=0,numGPi-1 {
if (pnm.gid_exists(cellID(ID_GPi, i))) {
adGPiTha[i].active = 0
}
}
}
//----------------------------------------------------------------------------
proc dbsON() { local i,j
dbsOFF()
if (pnm.pc.id() == 0) {
// master tells all slave nodes to update network with inputs vector
pnm.pc.look_take("dbsON")
for i=0,numDBS-1 {
pnm.pc.pack(dbsONflags[i])
}
pnm.pc.post("dbsON")
pnm.pc.context("dbsON", 0)
for i=1,pnm.pc.nhost-1 {
sprint(pstr, "dbsON%d", i)
pnm.pc.take(pstr)
}
} else {
// slave nodes clear message from master and doit
pnm.pc.look("dbsON")
for i=0,numDBS-1 {
pnm.pc.unpack(dbsONflags[i])
}
sprint(pstr, "dbsON%d", pnm.pc.id())
pnm.pc.post(pstr)
}
// turn selected components ON
for i=0, numDBS-1 {
for j=0,dbsONflags[i].size-1 {
if (i == DBS_STN) {
if (pnm.gid_exists(cellID(ID_STN, dbsONflags[i].x(j)))) {
directSTN[dbsONflags[i].x(j)].active = 1
}
}
if (i == DBS_STNGPe) {
if (pnm.gid_exists(cellID(ID_STN, dbsONflags[i].x(j)))) {
adSTNGPe[dbsONflags[i].x(j)].active = 1
}
}
if (i == DBS_STNGPi) {
if (pnm.gid_exists(cellID(ID_STN, dbsONflags[i].x(j)))) {
adSTNGPi[dbsONflags[i].x(j)].active = 1
}
}
if (i == DBS_GPeSTN) {
if (pnm.gid_exists(cellID(ID_GPe, dbsONflags[i].x(j)))) {
adGPeSTN[dbsONflags[i].x(j)].active = 1
}
}
if (i == DBS_GPeGPi) {
if (pnm.gid_exists(cellID(ID_GPe, dbsONflags[i].x(j)))) {
adGPeGPi[dbsONflags[i].x(j)].active = 1
}
}
if (i == DBS_GPeGPe) {
if (pnm.gid_exists(cellID(ID_GPe, dbsONflags[i].x(j)))) {
adGPeGPe[dbsONflags[i].x(j)].active = 1
}
}
if (i == DBS_GPiTha) {
if (pnm.gid_exists(cellID(ID_GPi, dbsONflags[i].x(j)))) {
adGPiTha[dbsONflags[i].x(j)].active = 1
}
}
}
}
}
//----------------------------------------------------------------------------
// Call setup functions when .hoc file is loaded
//----------------------------------------------------------------------------
STIconnectNet()
STIupdateWeights()
//----------------------------------------------------------------------------
// Dialog to update parameter values
//----------------------------------------------------------------------------