-
Notifications
You must be signed in to change notification settings - Fork 0
/
ran_test.hoc
128 lines (101 loc) · 3.05 KB
/
ran_test.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
NSNUM = 5 // how many NetStims to create
MAXSTREAM = 1000 // max # events in a NetStim's stream
// before it begins to repeat values already generated
// by a different stream.
// set to 0 and all NetStims will produce identical streams
ISI = 10 // default NetStim parameters
NUM = 50
START = 1
NOISE = 0
TSTOP = 20 // length of simulation
load_file("nrngui.hoc")
load_file("ranstream.hoc")
///// model setup
objref nslist, rslist
nslist = new List()
rslist = new List()
proc makenetstims() { local i localobj ns, rs
nslist = new List()
rslist = new List()
random_stream_offset_ = MAXSTREAM
for i = 0, $1-1 {
ns = new NetStim()
nslist.append(ns)
rs = new RandomStream(i)
rslist.append(rs)
ns.noiseFromRandom(rs.r)
rs.r.negexp(1) // must specify negexp distribution with mean = 1
rs.start()
}
}
makenetstims(NSNUM)
proc setparams() { local i
for i = 0,nslist.count()-1 {
nslist.o(i).interval = ISI
nslist.o(i).number = NUM
nslist.o(i).start = START
nslist.o(i).noise = NOISE
}
}
setparams() // default is deterministic spike times (NOISE = 0)
///// instrumentation
objref tvec, idvec, nil
tvec = new Vector()
idvec = new Vector()
proc instrumentation() { local i localobj nc
tvec = new Vector()
idvec = new Vector()
for i = 0,nslist.count()-1 {
nc = new NetCon(nslist.o(i), nil)
nc.record(tvec, idvec, i)
}
}
instrumentation()
///// simulation control
// spike times will be at 0.5*ISI + sample from negexp that has mean 0.5*ISI
NOISE = 0.5
setparams()
tstop = TSTOP
proc restart() { local i
for i = 0, rslist.count()-1 rslist.o(i).start()
}
objref g
proc myrun() {
run()
// make a raster plot of spike times
idvec.add(1) // so cell i spikes are marked at y = i+1
objref g
g = new Graph(0)
g.size(0,tstop,0,NSNUM)
g.view(0, 0, tstop, NSNUM, 47, 109, 300.48, 200.32)
idvec.mark(g, tvec, "|", 10, 2, 1)
// print out spike times
print " time cell"
for i=0, tvec.size-1 printf("%7.3f \t%d\n", tvec.x(i), idvec.x(i))
}
/////
print "============================================================"
print "Control: all have interval 10, number 50, start 10, noise 1"
print "============================================================"
myrun()
print " "
print "Take a good look at the graph. The marks at y = 1"
print "indicate the spikes generated by NetStim[0]."
print "When ready for next test, type"
print "test()"
print "at the oc> prompt, then press Return"
print " "
proc test() {
print "============================================================"
print "Test: NetStim 0 (i.e. cell 1) interval 1, number 3"
print "============================================================"
nslist.o(0).interval = 1
nslist.o(0).number = 3
restart() // restore each generator to the start of its stream
myrun()
print " "
print "Note that only the marks at y = 1 changed location in time."
print "Compare the NetStim spike times in this run"
print "against the spike times from the control run."
print "Note that only the spikes from \"cell 1\" (NetStim[0]) are different."
}