-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSaveData.hoc
425 lines (340 loc) · 8.62 KB
/
SaveData.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
// Save simulation data to a folder (data0)
DT = 0.2 // Record data with a resolution of 0.2 ms
DTT = 0.02 // Record data with a resolution of 0.02 ms
sum = 0
objref f1
f1 = new File()
strdef filepath, filepath1, string, filename, WD
objref time, input, Vmean, Vmean2
objref Gpm[nmitx][nmity]
objref Ggm[nMit][nGran], Ggm_Total[nMit]
objref Vms[nmitx][nmity], Vmd[nmitx][nmity], Vmt[nmitx][nmity]
objref Vgs[ngranx][ngrany], Vgb[ngranx][ngrany]
objref Vps[npgx][npgy], Vpb[npgx][npgy]
objref Tt
objref Vmc22[5]
filepath1 = "RSP2/" // used to store random background inputs; not used currently
Tt = new Vector()
time = new Vector()
input = new Vector()
// Record time
Tt.record(&t, DTT)
time.record(&t, DT)
// Record input timecourse
input.record(&MCinput[0][0].i, DT)
//====================================================
// Record Voltage
//====================================================
for i = 0, 4 {
Vmc22[i] = new Vector()
}
Vmc22[0].record(&mit[2][2].soma.v(0.5), DTT)
Vmc22[1].record(&mit[2][2].dend.v(0.16), DTT)
Vmc22[2].record(&mit[2][2].dend.v(0.35), DTT)
Vmc22[3].record(&mit[2][2].dend.v(0.47), DTT)
Vmc22[4].record(&mit[2][2].dend.v(0.99), DTT)
// Record Mit Soma Voltage
for i=0, nmitx-1 {
for j=0, nmity-1 {
Vms[i][j] = new Vector()
Vms[i][j].record(&mit[i][j].soma.v(0.5), DT)
}
}
// Record Mit Dend Voltage
for i=0, nmitx-1 {
for j=0, nmity-1 {
Vmd[i][j] = new Vector()
Vmd[i][j].record(&mit[i][j].dend.v(1.0), DT)
}
}
// Record Mit tuft Voltage
for i=0, nmitx-1 {
for j=0, nmity-1 {
Vmt[i][j] = new Vector()
Vmt[i][j].record(&mit[i][j].tuft.v(0.5), DT)
}
}
// Record PG Soma Voltage
for i=0, npgx-1 {
for j=0, npgy-1 {
Vps[i][j] = new Vector()
Vps[i][j].record(&pg[i][j].soma.v(0.5), DT)
}
}
// Record PG Spine Voltage
for i=0, npgx-1 {
for j=0, npgy-1 {
Vpb[i][j] = new Vector()
Vpb[i][j].record(&pg[i][j].gemmbody.v(0.5), DT)
}
}
// Record GC Soma Voltage
for i=0, nmitx-1 {
for j=0, nmity-1 {
Vgs[i][j] = new Vector()
Vgs[i][j].record(&gran[i][j].soma.v(0.5), DT)
}
}
// Record Gran Spine Voltage
for i=0, ngranx-1 {
for j=0, ngrany-1 {
Vgb[i][j] = new Vector()
Vgb[i][j].record(&gran[i][j].gemmbody.v(0.5), DT)
}
}
//====================================================
// Record Conductance
//====================================================
// Record PG->MC conductance
for i=0, nmitx-1 {
for j=0, nmity-1 {
Gpm[i][j] = new Vector()
Gpm[i][j].record(&p2m[i][j].g, DT)
}
}
// Record GC->MC conductance
for i=0, nMit-1 {
for j=0, GMS[i]-1 {
Ggm[i][j] = new Vector()
Ggm[i][j].record(&g2m[i][j].g, DT)
}
}
//====================================================
// Save Data
//====================================================
proc save_data() {
WD = getcwd()
sprint(filepath, "data%d",$1)
print filepath
print "\n"
FL=chdir(filepath)
if (FL==-1) {
sprint(string, "system(\"mkdir %s\")", filepath)
//chdir("getcwd()")
chdir(WD)
execute(string)
} else {
chdir(WD)
}
//====================================================
size1 = Vms[0][0].size()
Vmean = new Vector(size1, 0)
// Calculate mean voltage
for i=0, nmitx-1 {
for j=0, nmity-1 {
Vmean = Vmean.c.add(Vms[i][j])
}
}
size2 = Vgb[0][0].size()
Vmean2 = new Vector(size2, 0)
for i=0, ngranx-1 {
for j=0, ngrany-1 {
Vmean2 = Vmean2.c.add(Vgb[i][j])
}
}
// Calculate the total GC GABAa conductance to each MC
size = Ggm[0][0].size()
for i=0, nMit-1 {
Ggm_Total[i] = new Vector(size, 0)
for j=0, GMS[i]-1 {
Ggm_Total[i] = Ggm_Total[i].c.add(Ggm[i][j])
}
}
// ====================================================
// Save Input
// ====================================================
sprint(filename, "%s/OSN", filepath)
f1.wopen(filename)
input.printf(f1)
f1.close()
sprint(filename, "%s/Odor", filepath)
f1.wopen(filename)
for i = 0, nmitx-1 {
for j = 0, nmity-1 {
f1.printf("%5.4f ", odor[i][j])
f1.printf("\n")
}
}
f1.close()
// ====================================================
// Save Simulation Time
// ====================================================
sprint(filename, "%s/tt", filepath)
f1.wopen(filename)
time.printf(f1)
f1.close()
sprint(filename, "%s/Tt", filepath)
f1.wopen(filename)
Tt.printf(f1)
f1.close()
//====================================================
// Save Conductance
//====================================================
// Save PG-->MC conductance
for i=0, nmitx-1 {
for j=0, nmity-1 {
sprint(filename, "%s/Gpm%d%d",filepath, i,j)
f1.wopen(filename)
Gpm[i][j].printf(f1)
f1.close()
}
}
// Save GC-->MC conductance
for i=0, nMit-1 {
sprint(filename, "%s/Ggm%d",filepath, i)
f1.wopen(filename)
Ggm_Total[i].printf(f1)
f1.close()
}
//====================================================
// Save Voltage
//====================================================
// Save voltage of lateral DEND of MC22 at various points
for i = 0, 4 {
sprint(filename, "%s/Vmc22_%d",filepath, i)
f1.wopen(filename)
Vmc22[i].printf(f1)
f1.close()
}
// Save mean MC voltage
Vmean = Vmean.div(nMit)
sprint(filename, "%s/Vam", filepath)
f1.wopen(filename)
Vmean.printf(f1)
f1.close()
Vmean2 = Vmean2.div(nGran)
sprint(filename, "%s/Vag", filepath)
f1.wopen(filename)
Vmean2.printf(f1)
f1.close()
// Save voltage of mitral cells
// Soma
for i=0, nmitx-1 {
for j=0, nmity-1 {
sprint(filename, "%s/Vms_%d_%d",filepath, i,j)
f1.wopen(filename)
Vms[i][j].printf(f1)
f1.close()
}
}
// Dendrite
for i=0, nmitx-1 {
for j=0, nmity-1 {
sprint(filename, "%s/Vmd_%d_%d",filepath, i,j)
f1.wopen(filename)
Vmd[i][j].printf(f1)
f1.close()
}
}
// Save PG voltages
// Soma
/*
for i=0, npgx-1 {
for j=0, npgy-1 {
sprint(filename, "%s/Vps%d%d",filepath, i,j)
f1.wopen(filename)
Vps[i][j].printf(f1)
f1.close()
}
}
*/
// Spine
for i=0, npgx-1 {
for j=0, npgy-1 {
sprint(filename, "%s/Vpb_%d_%d",filepath, i,j)
f1.wopen(filename)
Vpb[i][j].printf(f1)
f1.close()
}
}
// Save GC voltages
// Soma
/*
for i=0, nmitx-1 {
for j=0, nmity-1 {
sprint(filename, "%s/Vgs%d%d",filepath, i,j)
f1.wopen(filename)
Vgs[i][j].printf(f1)
f1.close()
}
}
*/
// Spine
for i=0, ngranx-1 {
for j=0, ngrany-1 {
sprint(filename, "%s/Vgb_%d_%d",filepath, i,j)
f1.wopen(filename)
Vgb[i][j].printf(f1)
f1.close()
}
}
//====================================================
// Save Spike Time
//====================================================
// Save MC somatic spike time
for i=0, nmitx-1 {
for j=0, nmity-1 {
sprint(filename, "%s/Ms_%d_%d",filepath, i,j)
f1.wopen(filename)
mit[i][j].spiketimes.printf(f1)
f1.close()
}
}
// Save MC dendritic spike time
for i=0, nmitx-1 {
for j=0, nmity-1 {
sprint(filename, "%s/Md_%d_%d",filepath, i,j)
f1.wopen(filename)
mit[i][j].dendspike.printf(f1)
f1.close()
}
}
// Save GC somatic spike time
for i=0, ngranx-1 {
for j=0, ngrany-1 {
sprint(filename, "%s/Gs_%d_%d",filepath, i,j)
f1.wopen(filename)
gran[i][j].spiketimes.printf(f1)
f1.close()
}
}
// Save GC dendritic spike time
for i=0, ngranx-1 {
for j=0, ngrany-1 {
sprint(filename, "%s/Gd_%d_%d",filepath, i,j)
f1.wopen(filename)
gran[i][j].dendspike.printf(f1)
f1.close()
}
}
// Save PG somatic spike time
for i=0, npgx-1 {
for j=0, npgy-1 {
sprint(filename, "%s/Ps_%d_%d",filepath, i,j)
f1.wopen(filename)
pg[i][j].spiketimes.printf(f1)
f1.close()
}
}
// Save PG dendritic spike time
for i=0, npgx-1 {
for j=0, npgy-1 {
sprint(filename, "%s/Pd_%d_%d",filepath, i,j)
f1.wopen(filename)
pg[i][j].dendspike.printf(f1)
f1.close()
}
}
//===============================================
// Save random spontaneous spikes
/*
for i = 0, nmitx-1 {
for j = 0, nmity-1 {
sprint(filename, "%ssp%d%d",filepath1, i, j)
f1.wopen(filename)
RSP[i][j].printf(f1)
f1.close()
}
}
*/
}