-
Notifications
You must be signed in to change notification settings - Fork 1
/
stim-o14.hoc
110 lines (91 loc) · 2.29 KB
/
stim-o14.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
objref inp
numodors=73
numactive=500
double odors[numodors][numactive]
inp=new File()
inp.ropen("odors-forsim500-kensaku.txt")
for od=0, numodors-1 {
for tf=0, numactive-1 {
odors[od][tf]=inp.scanvar()
// print " odor ",od, " mitral ",tf, odors[od][tf]
}
}
inp.close()
begintemplate OBStim
public nc, mgid, exists, ww,si,sw, endod, odors, pr, stod, wl, wh
external cvode, owfactor
objref nc, rinterval, rweight, fih, this
proc init(){localobj cell, pc, nil
pc = new ParallelContext()
exists = 0
// $1 is mitral_gid
mgid = $1
si=1
sw=1
ww=0
wl=0.2
wh=0.3
stod = 2
endod=6000
if (pc.gid_exists(mgid)) {
exists = 1
// seed_interval = mgid*10000 + 1
// seed_weight = mgid*10000 + 5000
cell = pc.gid2cell(mgid)
nc = new NetCon(nil, cell.synodor)
nc.delay = 0.5
fih = new FInitializeHandler(0, "init_ev()", this)
}
}
proc init_ev() {
printf("%s t=%g %g\n", this, t, stod)
seed_interval = si*10000 + 1
seed_weight = sw*10000 + 5000
rinterval = new Random()
rinterval.MCellRan4(seed_interval)
rinterval.uniform(100, 250)
rweight = new Random()
rweight.MCellRan4(seed_weight)
rweight.uniform(wl, wh)
cvode.event(t + stod, "ev()")//, this)
nc.event(t + stod + nc.delay)
nc.weight = 0
}
proc ev() {local next, dummy
dummy=rweight.repick()
if (t>=stod && t<=endod){nc.weight = ww*dummy*owfactor} else {nc.weight=0}
next = rinterval.repick()
// next = 800
printf("%s t=%g %g mt=%d rnd=%g w=%g\n", this, t, next, mgid, dummy, nc.weight)
next += t
cvode.event(next, "ev()")//, cell.synodor,1)
nc.event(next + nc.delay)
}
proc pr() {
printf("%d %g %g %g %g %g %g %g\n", mgid, seed_interval, seed_weight, ww, wl, wh, stod, endod)
}
endtemplate OBStim
objref stim_list_
proc create_stim() {localobj nil, wl, wh
stim_list_ = new List()
index=0
od=14
for i=0, numactive-1 {
stim_list_.append(new OBStim(i))
stim_list_.o(index).ww=odors[od][i]
stim_list_.o(index).si=global_si
stim_list_.o(index).sw=index
stim_list_.o(index).stod=global_stod
stim_list_.o(index).endod=global_endod
stim_list_.o(index).wl=global_wl
stim_list_.o(index).wh=global_wh
index=index+1
}
}
create_stim()
proc all_obstim_pr() {local i localobj list
list = new List("OBStim")
print "total stims: ", list.count()
for i=0, list.count-1 {list.object(i).pr()}
}
//all_obstim_pr()