-
Notifications
You must be signed in to change notification settings - Fork 1
/
SThprotocell.hoc
380 lines (289 loc) · 6.82 KB
/
SThprotocell.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
//
// The prototype STh cell class
//
print " "
print "loading STh cell data structures..."
print " "
begintemplate SThproto
public ntrees,ntree0,ntree1,somadiam,somaL,PI
public ref,child,diam,L,nseg,Ra,Cm
objref f
objref tree0ref,tree0c1,tree0c2,tree0diam,tree0L,tree0nseg,tree0dist,tree0var
objref tree1ref,tree1c1,tree1c2,tree1diam,tree1L,tree1nseg,tree1dist,tree1var
proc init() {local i, j, me, child1, child2
somaL = 18.8
somadiam = 18.3112
nsegscale = 1
ntrees = 2
tc=0
PI=3.14159265358979
printf(" %d trees\n",ntrees)
// TREE 1
ntree0=23
tree0ref = new Vector(ntree0)
tree0c1 = new Vector(ntree0)
tree0c2 = new Vector(ntree0)
tree0diam = new Vector(ntree0)
tree0L = new Vector(ntree0)
tree0nseg = new Vector(ntree0)
tree0dist = new Vector(ntree0)
tree0var = new Vector(ntree0)
f = new File()
f.ropen("sth-data/tree0-nom.dat")
i=0
while (!f.eof()) {
if (i<ntree0) {
tree0ref.x[i] = f.scanvar()-1 // myref
tree0c1.x[i] = f.scanvar()-1 // child1
tree0c2.x[i] = f.scanvar()-1 // child2
tree0diam.x[i] = f.scanvar() // diam
tree0L.x[i] = f.scanvar() // L
tree0nseg.x[i] = nsegscale*f.scanvar() // nseg
}
i=i+1
}
if (i!=ntree0) printf("WARNING file tree0ns.dat is inconsistent expecting %d branches got %d \n",ntree0,i)
// sort Vectors
sortv(ntree0,tree0ref,tree0c1,tree0c2,tree0diam,tree0L,tree0nseg)
printf(" loaded tree 0 (%d branches)\n",ntree0)
f.close()
// TREE 2
ntree1=11
tree1ref = new Vector(ntree1)
tree1c1 = new Vector(ntree1)
tree1c2 = new Vector(ntree1)
tree1diam = new Vector(ntree1)
tree1L = new Vector(ntree1)
tree1nseg = new Vector(ntree1)
tree1dist = new Vector(ntree1)
tree1var = new Vector(ntree1)
f = new File()
f.ropen("sth-data/tree1-nom.dat")
i=0
while (!f.eof()) {
if (i<ntree1) {
tree1ref.x[i] = f.scanvar()-1 // myref
tree1c1.x[i] = f.scanvar()-1 // child1
tree1c2.x[i] = f.scanvar()-1 // child2
tree1diam.x[i] = f.scanvar() // diam
tree1L.x[i] = f.scanvar() // L
tree1nseg.x[i] = nsegscale*f.scanvar() // nseg
}
i=i+1
}
if (i!=ntree1) printf("WARNING file tree0ns.dat is inconsistent expecting %d branches got %d \n",ntree1,i)
// sort Vectors
sortv(ntree1,tree1ref,tree1c1,tree1c2,tree1diam,tree1L,tree1nseg)
printf(" loaded tree 1 (%d branches)\n",ntree1)
f.close()
}
// sortv - sort the vectors into index reference order!
proc sortv() {local i, j, tmp
// arg1 is the number of branches
// arg2,3,4,5,6,7 are the vectors to sort
for i=0,$1-1 {
j=i
while (j<$1) {
if (($o2.x[j]==i) && (j!=i)) {
// swap jth line with ith
tmp = $o2.x[i]
$o2.x[i] = $o2.x[j]
$o2.x[j] = tmp
tmp = $o3.x[i]
$o3.x[i] = $o3.x[j]
$o3.x[j] = tmp
tmp = $o4.x[i]
$o4.x[i] = $o4.x[j]
$o4.x[j] = tmp
tmp = $o5.x[i]
$o5.x[i] = $o5.x[j]
$o5.x[j] = tmp
tmp = $o6.x[i]
$o6.x[i] = $o6.x[j]
$o6.x[j] = tmp
tmp = $o7.x[i]
$o7.x[i] = $o7.x[j]
$o7.x[j] = tmp
}
j=j+1
}
}
}
// ref(tree,branch) returns the recorded ref
func ref() {local res
res=0
if (($1==0) && ($2<ntree0)){
res=tree0ref.x[$2]
}
if (($1==1) && ($2<ntree1)){
res=tree1ref.x[$2]
}
return res
}
// diam(tree,branch) returns the recorded diam
func diam() {local res
res=0
if ($1==-1) {
res=somadiam
}
if (($1==0) && ($2<ntree0)){
res=tree0diam.x[$2]
}
if (($1==1) && ($2<ntree1)){
res=tree1diam.x[$2]
}
return res
}
// L(tree,branch) returns the recorded L
func L() {local res
res=0
if ($1==-1) {
res=somaL
}
if (($1==0) && ($2<ntree0)){
res=tree0L.x[$2]
}
if (($1==1) && ($2<ntree1)){
res=tree1L.x[$2]
}
return res
}
// Ra(tree) returns the recorded Ra
func Ra() {local res
return 150.224
}
// Cm(tree) returns the recorded membrane capacitance Cm [uF/cm^2]
func Cm() {local res
return 1.0
}
// nseg(tree,branch) returns the recorded nseg
func nseg() {local res
res=1
if (($1==0) && ($2<ntree0)){
res=tree0nseg.x[$2]
}
if (($1==1) && ($2<ntree1)){
res=tree1nseg.x[$2]
}
return res
}
// child(tree,branch,0|1) returns the child ref
func child() {local res
res=0
if ($3==0){
if (($1==0) && ($2<ntree0)){
res=tree0c1.x[$2]
}
if (($1==1) && ($2<ntree1)){
res=tree1c1.x[$2]
}
}
if ($3==1){
if (($1==0) && ($2<ntree0)){
res=tree0c2.x[$2]
}
if (($1==1) && ($2<ntree1)){
res=tree1c2.x[$2]
}
}
return res
}
endtemplate SThproto
//
// THE STh CELL OBJECT
//
begintemplate SThcell
public soma, dend0, dend1
// declare the variables we will be using
create soma, dend0[1], dend1[1]
objref sthtype
strdef cmd
proc init() {local i, j, me, child1, child2
// $1 = cell reference number
// $o2 = cell prototype
cellref = $1
sthtype = $o2
SThndend0 = sthtype.ntree0
SThndend1 = sthtype.ntree1
create soma, dend0[SThndend0], dend1[SThndend1]
soma {
nseg = sthtype.nseg(-1,-1)
Ra = sthtype.Ra(-1)
diam = sthtype.diam(-1,-1)
L = sthtype.L(-1,-1)
cm = sthtype.Cm(-1)
// channels
insert STh
insert Na
insert NaL
insert KDR
insert Kv31
insert Ih
insert Cacum
insert sKCa
insert CaT
insert HVA
}
for i = 0,SThndend0-1 {
me = sthtype.ref(0,i)
child1 = sthtype.child(0,i,0)
child2 = sthtype.child(0,i,1)
dend0[me] {
if (child1 >= 0) {
connect dend0[child1](0), 1
}
if (child2 >= 0) {
connect dend0[child2](0), 1
}
diam = sthtype.diam(0,i)
L = sthtype.L(0,i)
Ra = sthtype.Ra(0)
nseg = sthtype.nseg(0,i)
cm = sthtype.Cm(0)
// channels
insert STh
insert Na
insert NaL
insert KDR
insert Kv31
insert Ih
insert Cacum
insert sKCa
insert CaT
insert HVA
}
}
for i = 0,SThndend1-1 {
me = sthtype.ref(1,i)
child1 = sthtype.child(1,i,0)
child2 = sthtype.child(1,i,1)
dend1[me] {
if (child1 >= 0) {
connect dend1[child1](0), 1
}
if (child2 >= 0) {
connect dend1[child2](0), 1
}
diam = sthtype.diam(1,i)
L = sthtype.L(1,i)
Ra = sthtype.Ra(1)
nseg = sthtype.nseg(1,i)
cm = sthtype.Cm(0)
// channels
insert STh
insert Na
insert NaL
insert KDR
insert Kv31
insert Ih
insert Cacum
insert sKCa
insert CaT
insert HVA
}
}
// connect trees to soma
connect dend0[0](0), soma(1)
connect dend1[0](0), soma(0)
}
endtemplate SThcell