-
Notifications
You must be signed in to change notification settings - Fork 1
/
init_icms.hoc
370 lines (275 loc) · 7.09 KB
/
init_icms.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
/* Initiates simulation of coritcal column model with ICMS
* Adapted from Markram et al., 2015 & Aberra et al., 2018
* 2020/06/16 Modified by Karthik Kumaravelu
* AUTHOR: Karthik Kumaravelu, Duke University
* CONTACT: karthik.kumaravelu@duke.edu
*/
// cell_id = 6 // leave unset until user selects cell
{load_file("nrngui.hoc")}
{load_file("interpCoordinates.hoc")}
{load_file("setPointers.hoc")}
// {load_file("calcVe.hoc")}
// {load_file("stimWaveform.hoc")}
{load_file("cellChooser.hoc")}
{load_file("setParams.hoc")}
{load_file("editMorphology.hoc")} // procs for editing cell morphology
// {load_file("rig.ses")}
// createPanels() // in setParams.hoc
celsius = 37 // default temp
setParamsAdultRat()
cell_chooser(cell_id)
steps_per_ms = 40
dt = .025
secondorder = 0
tstop = 210
objref RLx
objref input_file1
RLx = new Vector()
input_file1 = new File()
input_file1.ropen("realx.dat")
RLx.scanf(input_file1,6410)
input_file1.close()
objref RLy
objref input_file2
RLy = new Vector()
input_file2 = new File()
input_file2.ropen("realy.dat")
RLy.scanf(input_file2,6410)
input_file2.close()
objref RLz
objref input_file3
RLz = new Vector()
input_file3 = new File()
input_file3.ropen("realz.dat")
RLz.scanf(input_file3,6410)
input_file3.close()
objref RLang
objref input_file6
RLang = new Vector()
input_file6 = new File()
input_file6.ropen("realang.dat")
RLang.scanf(input_file6,6410)
input_file6.close()
objref tot_cell_count
objref input_file7
tot_cell_count = new Vector()
input_file7 = new File()
input_file7.ropen("cell_cnt.dat")
tot_cell_count.scanf(input_file7,25)
input_file7.close()
sigma_e = 2.76e-7
DEL = 201
DUR = 0.2
AMP = -50
Space_Constant = 250
FREQ = 2
ELECx1=200
ELECy1=1000
ELECz1=200
ELECx2=200+400
ELECy2=1000
ELECz2=200
Space_Constant1 = 0.1
ampratio_xtra=0
proc calcesI(){ local x0,y0,z0,sigma_e,r,ange
x0 = $1
y0 = $2
z0 = $3
ange = $4
sigma_e = $5
net_ad_x1=((x0*cos(ange))-(z0*sin(ange)))-(x0)
net_ad_y1=(y0)-(y0)
net_ad_z1=(((x0)*sin(ange))+((z0)*cos(ange)))-(z0)
forall {
if (ismembrane("xtra")){
for(x,0){
xrot1=((x0+x_xtra(x))*cos(ange))-((z0+z_xtra(x))*sin(ange))
yrot1=y0+y_xtra(x)
zrot1=((x0+x_xtra(x))*sin(ange))+((z0+z_xtra(x))*cos(ange))
x_fin=xrot1-net_ad_x1
y_fin=yrot1-net_ad_y1
z_fin=zrot1-net_ad_z1
r1w = sqrt(((x_fin-ELECx1)^2)+((y_fin-ELECy1)^2)+((z_fin-ELECz1)^2))
r2w = sqrt(((x_fin-ELECx2)^2)+((y_fin-ELECy2)^2)+((z_fin-ELECz2)^2))
es1_xtra(x) = 1e-3/(4*PI*sigma_e*r1w)
es2_xtra(x) = 1e-3/(4*PI*sigma_e*r2w)
}
}
}
}
objref stim_amp, stim_time
stim_amp = new Vector()
stim_time = new Vector()
proc stim_waveform() {
// this uses interpolated play
// index 0 1 2 3 4 5
// stim vec 0, 0, 1, 1, 0 0
// time vec 0, DEL, DEL, DEL+DUR, DEL+DUR, DEL+DUR+1
// really 0, $1, $1, $1+$2, $1+$2, $1+$2+1
// first the stim vector
stim_amp.resize(10*10)
stim_amp.fill(0)
for itc1=0,9{
stim_amp.x[2+(10*itc1)]=1
stim_amp.x[3+(10*itc1)]=1
stim_amp.x[6+(10*itc1)]=-1
stim_amp.x[7+(10*itc1)]=-1
}
stim_amp.mul($3)
stim_time.resize(10*10)
for itc=0,9{
stim_time.x[1+(10*itc)]=$1+((1000/$4)*itc)
stim_time.x[2+(10*itc)]=$1+((1000/$4)*itc)
stim_time.x[3+(10*itc)]=$1+$2+((1000/$4)*itc)
stim_time.x[4+(10*itc)]=$1+$2+((1000/$4)*itc)
stim_time.x[5+(10*itc)]=$1+$2+0.053+((1000/$4)*itc)
stim_time.x[6+(10*itc)]=$1+$2+0.053+((1000/$4)*itc)
stim_time.x[7+(10*itc)]=$1+$2+0.053+$2+((1000/$4)*itc)
stim_time.x[8+(10*itc)]=$1+$2+0.053+$2+((1000/$4)*itc)
stim_time.x[9+(10*itc)]=$1+$2+0.053+$2+1+((1000/$4)*itc)
}
}
proc attach_stim() {
forall {
if (ismembrane("xtra")) {
stim_amp.play(&stim_xtra, stim_time, 1)
}
}
}
proc setstim() {
del = $1
dur = $2
amp = $3
freq = $4
stim_waveform(del, dur, amp, freq)
attach_stim()
}
objref tvec
double vm_soma[1]
tvec = new Vector()
objref vm[1]
vm[0] = new Vector()
objref fihprog_
objref myout
objref myout1
proc recvm(){
if (t>=200){
vm_soma=cell.soma[0].v(0.5)
tvec.append(t)
vm.append(vm_soma)
}
cvode.event(t+dt, "recvm()")
}
tot_nseg=0
forsec Myelin_secList {
tot_nseg=tot_nseg+nseg
}
forsec Node_secList {
tot_nseg=tot_nseg+nseg
}
forsec Unmyelin_secList {
tot_nseg=tot_nseg+nseg
}
objref efmm[1]
for i=0, 0{
efmm[i] = new Matrix(400,tot_nseg+1)}
proc rec_vm_axon(){
if (t>=200){
efmm[0].x[(t-200)/dt][0] = t
cnt=1
kpo=0
forsec Myelin_secList {
for j=1,nseg{
abc=1/(nseg+1)
efmm[0].x[(t-200)/dt][cnt] = Myelin[kpo].v(j*abc)
cnt=cnt+1
}
kpo=kpo+1
}
kpo=0
forsec Node_secList {
for j=1,nseg{
abc=1/(nseg+1)
efmm[0].x[(t-200)/dt][cnt] = Node[kpo].v(j*abc)
cnt=cnt+1
}
kpo=kpo+1
}
kpo=0
forsec Unmyelin_secList {
for j=1,nseg{
abc=1/(nseg+1)
efmm[0].x[(t-200)/dt][cnt] = Unmyelin[kpo].v(j*abc)
cnt=cnt+1
}
kpo=kpo+1
}
}
cvode.event(t+dt, "rec_vm_axon()")
}
proc progress() {
n_run1=$1
print "t=",t
strdef d,data1,data_n1,dar
d =".dat"
data1 = "Vm_"
dar = "_"
sprint(data_n1,"%s%d%s%d%s",data1,cell_id,dar,n_run1,d)
strdef spkflnm1
sprint(spkflnm1, data_n1)
myout = new File()
if (t>=200){
if (t == 200){
myout.wopen(spkflnm1)
} else {
myout.aopen(spkflnm1)
}
for i=0, tvec.size-1 {
myout.printf("%g %g\n", tvec.x[i], vm.x[i])
}
myout.close()
vm.resize(0)
tvec.resize(0)
}
strdef data2,data_n2
data2 = "Vm_axon_"
sprint(data_n2,"%s%d%s%d%s",data2,cell_id,dar,n_run1,d)
myout1 = new File()
if (t>=200){
myout1.wopen(data_n2)
for i=0, 399{
for j=0, tot_nseg{
myout1.printf("%g\t", efmm[0].x[i][j])
}
myout1.printf("\n")
}
}
if (t == 0) {
recvm()
rec_vm_axon()}
cvode.event(t+10, "progress(n_run1)")
}
proc run_all(){
n_run1=$1
calcesI(RLx.x[tot_cell_count.sum(0,cell_id-1)-tot_cell_count.x[cell_id-1]+n_run1-1],RLy.x[tot_cell_count.sum(0,cell_id-1)-tot_cell_count.x[cell_id-1]+n_run1-1],RLz.x[tot_cell_count.sum(0,cell_id-1)-tot_cell_count.x[cell_id-1]+n_run1-1],RLang.x[tot_cell_count.sum(0,cell_id-1)-tot_cell_count.x[cell_id-1]+n_run1-1],sigma_e)
setstim(DEL,DUR,AMP,FREQ)
sprint(cell_dir,"cells/%s",cell_names.o(cell_id-1).s)
chdir(cell_dir)
cell.synapses.load_synapses(cell,RLx.x[tot_cell_count.sum(0,cell_id-1)-tot_cell_count.x[cell_id-1]+n_run1-1],RLy.x[tot_cell_count.sum(0,cell_id-1)-tot_cell_count.x[cell_id-1]+n_run1-1],RLz.x[tot_cell_count.sum(0,cell_id-1)-tot_cell_count.x[cell_id-1]+n_run1-1],RLang.x[tot_cell_count.sum(0,cell_id-1)-tot_cell_count.x[cell_id-1]+n_run1-1],ELECx1,ELECy1,ELECz1,Space_Constant,ELECx2,ELECy2,ELECz2,Space_Constant1)
chdir(current_dir)
cell.synapses.reset_synapses()
cell.synapses.update_synapses()
{fihprog_ = new FInitializeHandler("progress(n_run1)")}
run()
}
objref pc
pc = new ParallelContext()
{pc.runworker()}
proc batchrun() {
for md_inst1 = 1, tot_cell_count.x[cell_id-1] {
pc.submit("run_all",md_inst1)
}
while (pc.working()) {
}
}
batchrun()