-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmakePairedUnpaired.hoc
369 lines (304 loc) · 11 KB
/
makePairedUnpaired.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
///////////////////////////////////////////////////////////////////////////////
// makeSynapses.hoc: builds synapses in the model
//
// Note: this must be run *after* the cell geometry has been initialized
///////////////////////////////////////////////////////////////////////////////
//////////////////// declarations /////////////////////////////////////////////
strdef filename
objref runfile
// post-synaptic objects
objref gaba_paired, gaba_unpaired
gaba_paired = new List()
gaba_unpaired = new List()
// pre-synaptic objects
objref pre_paired, pre_unpaired
// pre_paired = new List()
// pre_unpaired = new List()
// connection objects
objref con_paired, con_unpaired
con_paired = new List()
con_unpaired = new List()
// Vectors for recording NetCon events
objref gaba_paired_tvec, gaba_paired_idvec
// gaba_paired_tvec = new Vector()
gaba_paired_idvec = new Vector()
objref gaba_unpaired_tvec, gaba_unpaired_idvec
// gaba_unpaired_tvec = new Vector()
gaba_unpaired_idvec = new Vector()
objref syn_location
syn_location = new Vector()
objref scts
scts = new Vector()
// write synapses
strdef syn_file, CA1synapses
objref runfile
objref header
header = new Vector()
objref syn_write_info
syn_write_info = new Vector()
//////////////////// procedure definitions ////////////////////////////////////
//-----------------------------------------------------------------------------
// make_gaba(location_paired, density_paired, location_unpaired, density_unpaired)
//-----------------------------------------------------------------------------
// creates the GABAergic post-synaptic objects, and places them in random
// positions on specifiec locations at the density indicated
// locations are specified using the following:
// 0 = soma
// 1 = proximal
// 2 = middle
// 3 = distal
proc make_gaba() { local secdis, secarea, numsyn, xpos, x, i, j, k localobj posr //declares local variablesa components, and add them to the lists
syn_location.resize(0)
// create a random number generator
posr = new Random(seed_prompt)
posr.uniform(0,1)
// add synapses in the soma
// add the paired synapses
if ($1 == 0) { // paired is in the soma
forsec somatic {
// determine the distance from the center of the soma to the center of this section
secdis = distance(1)
// calculate the area of this section
secarea = 0
for (x,0) {
secarea = secarea + area(x)
}
// calculate the number of synapses on this section
numsyn = int(secarea*$2)
print "numsyn is ", numsyn
// for each synapse, pick a random location,
// create gaba components, and add them to the lists
for i=1,numsyn{
xpos = posr.repick()
syn_location.append(xpos)
gaba_paired.append(new GABAa(xpos))
gaba_paired.o(gaba_paired.count()-1).gmax = gmax_paired_soma
}
}
}
// add the unpaired synapses
if ($3 == 0) { // unpaired is in the soma
forsec somatic {
// determine the distance from the center of the soma to the center of this section
secdis = distance(1)
// calculate the area of this section
secarea = 0
for (x,0) {
secarea = secarea + area(x)
}
// calculate the number of synapses on this section
numsyn = int(secarea*$4)
// for each synapse, pick a random location,
// create gaba components, and add them to the lists
for i=1,numsyn {
xpos = posr.repick()
gaba_unpaired.append(new GABAa(xpos))
gaba_unpaired.o(gaba_unpaired.count()-1).gmax = gmax_unpaired_soma
}
}
}
// add synapses in the proximal dendrites
// add the paired synapses
if ($1 == 1) { // paired is in the proximal dendrites
j = 0
forsec proximal {
// determine the distance from the center of the soma to the center of this section
secdis = distance(1)
// calculate the area of this section
secarea = 0
for (x,0) {
secarea = secarea + area(x)
}
// calculate the number of synapses on this section
numsyn = int(secarea*$2)
// for each synapse, pick a random location,
// create gaba components, and add them to the lists
for i=1,numsyn {
xpos = posr.repick()
syn_location.append(xpos)
gaba_paired.append(new GABAa(xpos))
gaba_paired.o(gaba_paired.count()-1).gmax = gmax_paired_prox
gaba_paired_idvec.append(proximal_indices.x(j))
}
j = j + 1
}
}
// add the unpaired synapses
if ($3 == 1) { // unpaired is in the proximal dendrites
j = 0
forsec proximal {
// determine the distance from the center of the soma to the center of this section
secdis = distance(1)
// calculate the area of this section
secarea = 0
for (x,0) {
secarea = secarea + area(x)
}
// calculate the number of synapses on this section
numsyn = int(secarea*$4)
// for each synapse, pick a random location,
// create gaba components, and add them to the lists
for i=1,numsyn {
xpos = posr.repick()
gaba_unpaired.append(new GABAa(xpos))
gaba_unpaired.o(gaba_unpaired.count()-1).gmax = gmax_unpaired_prox
gaba_unpaired_idvec.append(proximal_indices.x(j))
}
j = j + 1
}
}
// add synapses in the middle dendrites
// add the paired synapses
if ($1 == 2) { // paired is in the middle dendrites
j = 0
forsec middle {
// determine the distance from the center of the soma to the center of this section
secdis = distance(1)
// calculate the area of this section
secarea = 0
for (x,0) {
secarea = secarea + area(x)
}
// calculate the number of synapses on this section
numsyn = int(secarea*$2)
// for each synapse, pick a random location,
// create gaba components, and add them to the lists
for i=1,numsyn {
xpos = posr.repick()
syn_location.append(xpos)
gaba_paired.append(new GABAa(xpos))
gaba_paired.o(gaba_paired.count()-1).gmax = gmax_paired_mid
gaba_paired_idvec.append(middle_indices.x(j))
}
j = j + 1
}
}
// add the unpaired synapses
if ($3 == 2) { // unpaired is in the middle dendrites
j = 0
forsec middle {
// determine the distance from the center of the soma to the center of this section
secdis = distance(1)
// calculate the area of this section
secarea = 0
for (x,0) {
secarea = secarea + area(x)
}
// calculate the number of synapses on this section
numsyn = int(secarea*$4)
// for each synapse, pick a random location,
// create gaba components, and add them to the lists
for i=1,numsyn {
xpos = posr.repick()
gaba_unpaired.append(new GABAa(xpos))
gaba_unpaired.o(gaba_unpaired.count()-1).gmax = gmax_unpaired_mid
gaba_unpaired_idvec.append(middle_indices.x(j))
}
j = j + 1
}
}
// add synapss in the distal dendrites
// add the paired synapses
if ($1 == 3) { // paired is in the distal dendrites
j = 0
forsec distal {
// determine the distance from the center of the soma to the center of this section
secdis = distance(1)
// calculate the area of this section
secarea = 0
for (x,0) {
secarea = secarea + area(x)
}
// calculate the number of synapses on this section
numsyn = int(secarea*$2)
// for each synapse, pick a random location,
// create gaba components, and add them to the lists
for i=1,numsyn {
xpos = posr.repick()
syn_location.append(xpos)
gaba_paired.append(new GABAa(xpos))
gaba_paired.o(gaba_paired.count()-1).gmax = gmax_paired_dist
gaba_paired_idvec.append(distal_indices.x(j))
}
j = j + 1
}
}
// add the unpaired synapses
if ($3 == 3) { // unpaired is in the distal dendrites
j = 0
forsec distal {
// determine the distance from the center of the soma to the center of this section
secdis = distance(1)
// calculate the area of this section
secarea = 0
for (x,0) {
secarea = secarea + area(x)
}
// calculate the number of synapses on this section
numsyn = int(secarea*$4)
// for each synapse, pick a random location,
// create gaba components, and add them to the lists
for i=1,numsyn {
xpos = posr.repick()
gaba_unpaired.append(new GABAa(xpos))
gaba_unpaired.o(gaba_unpaired.count()-1).gmax = gmax_unpaired_dist
gaba_unpaired_idvec.append(distal_indices.x(j))
}
j = j + 1
}
}
print "# of GABA synapses is ", gaba_paired.count()
scts.resize(0)
for i = 0, gaba_paired.count()-1{
scts.append(999)
}
header.resize(0)
header.append(gaba_paired.count())
syn_write_info.resize(0)
syn_write_info.append(scts)
syn_write_info.append(syn_location)
//runfile = new File() // ask on forum about this
//sprint(syn_file,"./CA1<INSERTSECTIONNAME>synapses.dat")
//runfile.wopen(syn_file) // ask on forum about this
//runfile.seek(0)
//header.vwrite(runfile)
//syn_write_info.vwrite(runfile)
//print "synapses written to file ", syn_file
//runfile.close()
}
//-----------------------------------------------------------------------------
// make_gabapre(interval_paired, number_paired, start_paired, interval_unpaired,
// number_unpaired, start_unpaired)
//-----------------------------------------------------------------------------
// creates the presynaptic objects for the GABAergic synapses
proc make_gabapre() {
// create paired objects
pre_paired = new NetStim()
pre_paired.interval = $1
pre_paired.number = $2
pre_paired.start = $3
pre_paired.noise = 0
// create unpaired objects
pre_unpaired = new NetStim()
pre_unpaired.interval = $4
pre_unpaired.number = $5
pre_unpaired.start = $6
pre_unpaired.noise = 0
}
//-----------------------------------------------------------------------------
// make_gabacon()
//-----------------------------------------------------------------------------
// creates all of the connections between pre and post-synaptic objects
// for GABAergic synapses
proc make_gabacon() {
for i = 0,gaba_paired.count()-1 {
con_paired.append(new NetCon(pre_paired, gaba_paired.o(i), 0, 0, 1))
}
for i = 0,gaba_unpaired.count()-1 {
con_unpaired.append(new NetCon(pre_unpaired, gaba_unpaired.o(i), 0, 0, 1))
}
}
//////////////////// procedure calls /////////////////////////////////////
make_gaba(location_paired, density_paired, location_unpaired, density_unpaired)
make_gabapre(interval_paired, number_paired, start_paired, interval_unpaired, number_unpaired, start_unpaired)
make_gabacon()