forked from ModelDBRepository/127388
-
Notifications
You must be signed in to change notification settings - Fork 0
/
twoStateGen.mod
141 lines (109 loc) · 2.3 KB
/
twoStateGen.mod
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
COMMENT
Two state presynaptic event generator (burst on, burst off)
---------------------------
Generates presynaptic events at rate 1 until an external event is received.
If event is received, with probability p switches to rate 2 for a specified burst
duration, then reverts to rate 1.
Rates and duration are mean +/- std (using normal distribution for isi).
(derived from \nrn-5.8\src\nrnoc\netstim.mod)
ENDCOMMENT
NEURON {
ARTIFICIAL_CELL twoStateGen
RANGE start
RANGE bMean, bStd, iMean, iStd, bDurMean, bDurStd
RANGE p
}
PARAMETER {
start = 0 (ms) : start of first spike
bMean = 5 (ms) : mean ISI during burst
bStd = 0
iMean = 100 (ms) : mean ISI between bursts
iStd = 0
bDurMean = 50 (ms) : mean duration of burst
bDurStd = 0
p = 1 : probability of burst onset after external event
}
ASSIGNED {
event (ms)
on
}
PROCEDURE seed(x) {
set_seed(x)
}
INITIAL {
on = 0
if (start >= 0) {
: randomize the first spike so on average it occurs at
: with highest probability at start
event = start + invl(iMean,iStd) - iMean
: but not earlier than 0
if (event < 0) {
event = 0
}
net_send(event, 5)
}
}
FUNCTION invl(mean (ms), stddev (ms)) {
if (mean <= 0.) {
mean = .01 (ms) : I would worry if it were 0.
}
if (stddev > 0) {
invl = normrand(mean, stddev)
} else {
invl = mean
}
}
PROCEDURE next_invl() {
if (on == 1) {
event = invl(bMean, bStd)
} else {
event = invl(iMean, iStd)
}
if (event < 0) {
event = 0
}
}
NET_RECEIVE (w) {LOCAL tmp
if (flag == 0) { : external event
if (w > 0 && on == 0) { : turn on burst sequence
if (scop_random() <= p) {
if (bDurMean > 0) {
on = 1
next_invl()
net_send(event, 2)
tmp = normrand(bDurMean, bDurStd)
if (tmp < 0) {
tmp = bDurStd
}
net_send(tmp, 3) :shut off burst state after random duration
}
}
} else {
if (w < 0 && on == 1) { : turn off bursting
on = 0
}
}
} else {
if (flag == 1) {
net_event(t)
next_invl()
net_send(event,1)
} else {
if (flag == 2) {
net_event(t)
next_invl()
if (on == 1) {
net_send(event,2) : come back for another burst spike
}
} else {
if (flag == 3) {
on = 0 : turn off burst
} else {
if (flag == 5) { : from INITIAL
net_send(0,1) : start extraburst spike sequence
}
}
}
}
}
}