-
Notifications
You must be signed in to change notification settings - Fork 1
/
Figure8control.hoc
312 lines (233 loc) · 6.07 KB
/
Figure8control.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
back=0
//////// load needed templates////////////
if(!back){ load_file("nrngui.hoc") }
if(!back){ load_file("template/ObliquePath.hoc") }
if(!back){ load_file("template/BasalPath.hoc" ) }
objref econ,f1,f2,f3,ss,cvode
f1= new File()
f2= new File()
f3= new File()
ss=new SaveState()
cvode = new CVode(1)
x=cvode.active(1)
restart=0
v_init=-70
strdef morphology_location, morpho_path, ObliqueTrunkSection, BasalTrunkSection
objref vRP, vAPEX
proc xopen_morphology(){
sprint(morpho_path,"%s/%s",morphology_location,$s1)
xopen(morpho_path)
}
// Carmen
morphology_location = "pc2b"
ObliqueTrunkSection = "trunk[17]"
BasalTrunkSection = "trunk[7]"
xopen_morphology("cell.hoc") //reads morpholofy from the file
xopen_morphology("cell-analysis-simple.hoc") //reads simplified version of CA
// --------------- Creating lists-----------------
xopen("lib/TP-lib.hoc")
Tip_sections(apical_non_trunk_list,apical_trunk_list,"Apical")
objref apical_tip_list
apical_tip_list=TP_list // Apical Tip list
print "apical_tip_list"
apical_tip_list.printnames()
print "END apical_tip_list"
objref tmp_pl[num_tips],pl[num_tips],opl[num_tips],degree_apical_tip,peri_trunk_list
objref bl[num_tips],obl[num_tips],degree_basal_tip
xopen("lib/Oblique-lib.hoc")
oblique_sections(apical_tip_list,apical_trunk_list,num_tips) // apical dendrite path lists and degree of tips
xopen("lib/vector-distance.hoc")
//-----------------------------------------------------------------------------------------------------
printf("Setting up cell\n") // load cell-setup to
xopen("cell_setup_pc2b_control.hoc")
//load_file("atolscalekd.ses") // specify all mechanisms, membrane properties etc
///////////////////Load File//////////////////////
if(!back) { load_file("w_soma_cap.ses") }
/*cvode_active(1)*/
////// Spike counter//////////
objref apc, v1
proc insert_APC() {
apc = new APCount(0.5)
apc.thresh = $1
v1 = new Vector()
apc.record(v1)
}
proc init() {
if(restart){
f1.ropen("statekdsoma")
ss.fread(f1)
f1.close
finitialize(v_init)
ss.restore()
t=0
fcurrent()
cvode.re_init()
} else {
finitialize(v_init)
fcurrent()
}
}
////////////////////Main///////////////////
nsyn=10
objref s[nsyn], rsyn[nsyn], nc[nsyn]
objref rsynmda[nsyn], ncnmda[nsyn]
objref rect,recv,reci,savv,savi,savt
objref tvec,ampvec,iclamp
objref savtotcurr, savtotna16a, savtottrpm4, totcurr, totna16a, tottrpm4
strdef cmd
i=0
forall{
for(x){
sprint(cmd,"%s%d","objref totcurrentpart",i)
execute(cmd)
if(ismembrane("ican")){
sprint(cmd,"%s%d","objref tottrpm4apart",i)
execute(cmd)
}
if(ismembrane("na16a")){
sprint(cmd,"%s%d","objref totna16apart",i)
execute(cmd)
}
i=i+1
}
}
proc main(){
recv =new Vector()
rect =new Vector()
reci =new Vector()
i=0
forall{
for(x){
sprint(cmd,"%s%d%s","totcurrentpart",i,"=new Vector()")
execute(cmd)
if(ismembrane("ican")){
sprint(cmd,"%s%d%s","tottrpm4apart",i,"=new Vector()")
execute(cmd)
}
if(ismembrane("na16a")){
sprint(cmd,"%s%d%s","totna16apart",i,"=new Vector()")
execute(cmd)
}
i=i+1
}
}
//tol=cvode.atolscale(&soma.v(0.5),1e-5)
period=95.75
phase0=67.8234
dur=3
amp2=0.0
tstop= 16000
in=0
th=-14
access soma
insert_APC(th)
f3.wopen("spike.dat")
current=0.0 // 0.18
del=50
npulse = 10
pulsdur = 1000
pulsamp = 0.36
starttime = 13000
curbase = 0.09
soma {
iclamp = new IClamp( 0.5 )
tvec = new Vector(5 )
ampvec = new Vector(5 )
}
iclamp.del = 0
iclamp.dur = 1e9
tvec.x[0 ] = 0
tvec.x[1 ] = starttime
tvec.x[2 ] = starttime + pulsdur
tvec.x[3 ] = starttime + 2*pulsdur
tvec.x[4 ] = tstop
ampvec.x[0 ] = curbase
ampvec.x[1 ] = curbase
ampvec.x[2 ] = curbase + pulsamp
ampvec.x[3 ] = curbase
ampvec.x[4 ] = curbase
ampvec.play(&iclamp.amp,tvec,1)
access soma[0]
recv.record(&v(0.5))
rect.record(&t)
reci.record(&iclamp.i)
i=0
forall{
for(x){
sprint(cmd,"%s%d%s%s%s%f%s","totcurrentpart",i,".record(&",secname(),".i_cap(",x,"))")
execute(cmd)
if(ismembrane("ican")){
sprint(cmd,"%s%d%s%s%s%f%s","tottrpm4apart",i,".record(&",secname(),".itrpm4_ican(",x,"))")
execute(cmd)
}
if(ismembrane("na16a")){
sprint(cmd,"%s%d%s%s%s%f%s","totna16apart",i,".record(&",secname(),".ina_na16a(",x,"))")
execute(cmd)
}
i=i+1
}
}
//////////////run////////////////////////
run()
/////////////////////////////////////
savv= new File()
savt= new File()
savi = new File()
savv.wopen("v.txt")
savt.wopen("time.txt")
savi.wopen("i.txt")
recv.printf(savv)
rect.printf(savt)
reci.printf(savi)
savv.close
savt.close
savi.close
totcurr=new Vector(rect.size())
totna16a=new Vector(rect.size())
tottrpm4=new Vector(rect.size())
i=0
forall{
for(x){
sprint(cmd,"%s%d%s%f%s","totcurrentpart",i,".mul(area(",x,")*1e-8)")
execute(cmd)
sprint(cmd,"%s%d%s","totcurr.add(totcurrentpart",i,")")
execute(cmd)
if(ismembrane("ican")){
sprint(cmd,"%s%d%s%f%s","tottrpm4apart",i,".mul(area(",x,")*1e-8)")
execute(cmd)
sprint(cmd,"%s%d%s","tottrpm4.add(tottrpm4apart",i,")")
execute(cmd)
}
if(ismembrane("na16a")){
sprint(cmd,"%s%d%s%f%s","totna16apart",i,".mul(area(",x,")*1e-8)")
execute(cmd)
sprint(cmd,"%s%d%s","totna16a.add(totna16apart",i,")")
execute(cmd)
}
i=i+1
}
}
savtotcurr= new File()
savtotna16a= new File()
savtottrpm4 = new File()
savtotcurr.wopen("totcurr.txt")
savtotna16a.wopen("totna16a.txt")
savtottrpm4.wopen("tottrpm4.txt")
totcurr.printf(savtotcurr)
totna16a.printf(savtotna16a)
tottrpm4.printf(savtottrpm4)
savtotcurr.close
savtotna16a.close
savtottrpm4.close
// print the spike number
if(!back) printf("\n Current: %.4f nA | # Spikes: %d\n", current, apc.n)
if(!back) printf("___________________\n")
v1.printf(f3)
f3.close
f2.wopen("state.new")
ss.save
ss.fwrite(f2)
f2.close
}
main()
/******** end file ******/