-
Notifications
You must be signed in to change notification settings - Fork 1
/
viewspikes1.hoc
144 lines (137 loc) · 3.15 KB
/
viewspikes1.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
// The spike viewer colors spikes using the theme of red if
// a spike is potentiating, blue if depressing, and black if unchanged.
//Spikes are shown for a selected mitral cell at each granule position.
// The lower graph is a zoom view of the indicated postion in the
// full raster upper graph
begintemplate SpikeViewer1
external ngranule, nmitral, ncell
external gid2mg
objref tpat, idpat, vb, g, gz, this
objref dtpat, mat[2], xsel, ysel, csel
proc init() {
mdetect = 1
zv_width = 1000
tpat = $o1 // pattern_tvec
idpat = $o2 // pattern_idvec
color_spikes()
xmitral = int(nmitral/2)
xsel = tpat.c.resize(0)
ysel = tpat.c.resize(0)
csel = tpat.c.resize(0)
build()
}
proc build() {
vb = new VBox()
vb.ref(this)
vb.save("")
vb.intercept(1)
xpanel("",1)
xmenu("Z View Width")
xbutton("200", "zvw(200)")
xbutton("500", "zvw(500)")
xbutton("1000", "zvw(1000)")
xmenu()
xcheckbox("M detect", &mdetect, "x_change()")
xpvalue("Mitral gid", &xmitral, 1, "x_change()")
xpanel()
g = new Graph()
g.menu_tool("zoomed view", "zview")
g.size(0, 1000*int(tpat.x[tpat.size-1]/1000 + .5), 0, ngranule)
g.view(0,0,zv_width,ngranule,0,0,300,200)
vb.intercept(0)
vb.map("Spike Viewer", 200, 200, 500, 600)
g.exec_menu("zoomed view")
x_change()
}
proc zvw() {local x
zv_width = $1
x = g.view_info(1, 5)
g.view_size(1, x, x+zv_width, -10, ngranule+10)
}
proc zview() {local i
i = g.view_info()
if (i == 0) {
g.view_size(1, $2-zv_width/2, $2+zv_width/2, -10, ngranule+10)
}else{
translate($1, $2, $3)
}
}
i=0
x=0
width=0
proc translate() {local x0,y0
if ($1 == 2) {
i = g.view_info()
x = g.view_info(i, 5)
xrel=g.view_info(i, 11, $2)
width=g.view_info(i,1)
}
if ($1 == 1) {
x1 = g.view_info(i, 11, $2)
x0 = x - width*(x1 - xrel)
g.view_size(i, x0, x0 + width, -10, ngranule+10)
}
}
proc x_change() {local i, c, f, gid, m, g, is_m2g
if (xmitral < 0) {
xmitral = 0
}else if (xmitral > nmitral-1) {
xmitral = nmitral-1
}else{
xmitral = int(xmitral)
}
xsel.resize(0)
ysel.resize(0)
csel.resize(0)
for i=0, tpat.size-1 {
gid = idpat.x[i]
f = 0
if (gid > ncell){
gid2mg(gid, &m, &g, &is_m2g)
if (m == xmitral && is_m2g != mdetect) {
f = 1
xsel.append(tpat.x[i])
ysel.append(g)
}
}
if (f) {
dt = dtpat.x[i]
if (dt < ltpinvl_AmpaNmda) {
c = 2
}else if (dt > ltdinvl_AmpaNmda) {
c = 1
}else{
c = 3
}
csel.append(c)
}
}
gplt()
}
proc color_spikes() {local i, gid, m, g, is_m2g
dtpat = tpat.c
mat[0] = new Matrix(nmitral+1, ngranule+1)
for m=0, nmitral for g = 0, ngranule { mat[0].x[m][g] = -1000 }
mat[1] = mat[0].c
for i=0, tpat.size-1 {
gid = idpat.x[i]
if (gid < nmitral) {
m = gid + 1 g = 0 is_m2g = 0
}else if (gid < nmitral + ngranule) {
m = 0 g = gid - nmitral + 1
}else{
gid2mg(gid, &m, &g, &is_m2g)
m += 1
g += 1
}
dtpat.x[i] = tpat.x[i] - mat[is_m2g].x[m][g]
mat[is_m2g].x[m][g] = tpat.x[i]
}
}
proc gplt() {local i
g.erase()
for i=0, xsel.size-1 {
g.mark(xsel.x[i], ysel.x[i], "|", 2, csel.x[i], 1)
}
}
endtemplate SpikeViewer1