forked from open-ephys/simpleclust
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sc_extramenu.m
351 lines (223 loc) · 9.55 KB
/
sc_extramenu.m
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
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
function varargout=extramenu(features,mua,x,y,b,s_opt)
pos=[-1 -.8 -.6 -.5 -.4 -.3 -.2 0.0 0.1 0.4 0.5 0.8 1 1.2 1.4 1.7 1.9];
pos(6:end)=pos(6:end)+.2;
plot([-1.3 3.3] ,[-1 -1],'color',[.7 .7 .7]);
if nargout==0 % plot
i=1;
plot([1 1].*pos(i) ,[-1.1 -1],'color',[.7 .7 .7]);
plot([1 1].*pos(i+1) ,[-1.1 -1],'color',[.7 .7 .7]);
text(pos(i)+0.02,-1.05,'+wavelet');
i=2;
plot([1 1].*pos(i) ,[-1.1 -1],'color',[.7 .7 .7]);
plot([1 1].*pos(i+1) ,[-1.1 -1],'color',[.7 .7 .7]);
text(pos(i)+0.02,-1.05,'+PCA');
i=3;
plot([1 1].*pos(i) ,[-1.1 -1],'color',[.7 .7 .7]);
plot([1 1].*pos(i+1) ,[-1.1 -1],'color',[.7 .7 .7]);
text(pos(i)+0.02,-1.05,'wf+');
i=4;
plot([1 1].*pos(i) ,[-1.1 -1],'color',[.7 .7 .7]);
plot([1 1].*pos(i+1) ,[-1.1 -1],'color',[.7 .7 .7]);
text(pos(i)+0.02,-1.05,'wf-');
i=5;
plot([1 1].*pos(i) ,[-1.1 -1],'color',[.7 .7 .7]);
plot([1 1].*pos(i+1) ,[-1.1 -1],'color',[.7 .7 .7]);
text(pos(i)+0.02,-1.05,['isi+ [',num2str(features.isioptions(1).tmax),'ms]']);
i=6;
plot([1 1].*pos(i) ,[-1.1 -1],'color',[.7 .7 .7]);
plot([1 1].*pos(i+1) ,[-1.1 -1],'color',[.7 .7 .7]);
text(pos(i)+0.02,-1.05,'isi-');
i=7;
plot([1 1].*pos(i) ,[-1.1 -1],'color',[.7 .7 .7]);
plot([1 1].*pos(i+1) ,[-1.1 -1],'color',[.7 .7 .7]);
if features.plotgroup
plot([0 0.2]+pos(i)+0,[1 1].*-1.05,'color',[.7 .7 .7],'LineWidth',20);
end;
text(pos(i)+0.02,-1.05,'plotgroup?');
i=8;
plot([1 1].*pos(i) ,[-1.1 -1],'color',[.7 .7 .7]);
plot([1 1].*pos(i+1) ,[-1.1 -1],'color',[.7 .7 .7]);
text(pos(i)+0.02,-1.05,'.x');
i=9;
plot([1 1].*pos(i) ,[-1.1 -1],'color',[.7 .7 .7]);
plot([1 1].*pos(i+1) ,[-1.1 -1],'color',[.7 .7 .7]);
text(pos(i)+0.02,-1.05,['Ndisp ',num2str(features.Ndisplay),'(+)']);
i=10;
plot([1 1].*pos(i) ,[-1.1 -1],'color',[.7 .7 .7]);
plot([1 1].*pos(i+1) ,[-1.1 -1],'color',[.7 .7 .7]);
text(pos(i)+0.02,-1.05,['(-)']);
i=11;
plot([1 1].*pos(i) ,[-1.1 -1],'color',[.7 .7 .7]);
plot([1 1].*pos(i+1) ,[-1.1 -1],'color',[.7 .7 .7]);
text(pos(i)+0.02,-1.05,['new label']);
i=12; % rescaling!
plot([1 1].*pos(i) ,[-1.1 -1],'color',[.7 .7 .7]);
plot([1 1].*pos(i+1) ,[-1.1 -1],'color',[.7 .7 .7]);
text(pos(i)+0.02,-1.05,['rescale']);
%sc_scale_features
i=13; % undo
plot([1 1].*pos(i) ,[-1.1 -1],'color',[.7 .7 .7]);
plot([1 1].*pos(i+1) ,[-1.1 -1],'color',[.7 .7 .7]);
text(pos(i)+0.02,-1.05,['undo']);
% features.clusters=features.clusters_undo;
i=14; % undo
plot([1 1].*pos(i) ,[-1.1 -1],'color',[.7 .7 .7]);
plot([1 1].*pos(i+1) ,[-1.1 -1],'color',[.7 .7 .7]);
text(pos(i)+0.02,-1.05,['compare']);
i=15; % isi feature
plot([1 1].*pos(i) ,[-1.1 -1],'color',[.7 .7 .7]);
plot([1 1].*pos(i+1) ,[-1.1 -1],'color',[.7 .7 .7]);
text(pos(i)+0.02,-1.05,['+ISI feature']);
i=16; % sample specific pca feature
plot([1 1].*pos(i) ,[-1.1 -1],'color',[.7 .7 .7]);
plot([1 1].*pos(i+1) ,[-1.1 -1],'color',[.7 .7 .7]);
text(pos(i)+0.02,-1.05,['+PCA for subsets']);
else % evaluate x,y
i=1;
if (x>pos(i)) && (x<pos(i+1))
button = questdlg('compute wavelet feature? this will take a while.','compute wavelets?','Yes','No','Yes');
if strcmp(button,'Yes')
text(-.5,0,'computing additional wavelet features for visible spikes... ', 'BackgroundColor',[.7 .9 .7]);
drawnow;
features=sc_compute_extra_wavelet_coeffs(features,mua);
end;
end;
i=2;
if (x>pos(i)) && (x<pos(i+1))
text(-.5,0,'computing additional PCA features for visible spikes... ', 'BackgroundColor',[.7 .9 .7]);
drawnow;
features=sc_compute_extra_PCA_coeffs(features,mua);
end;
i=3; % waveforms +
if (x>pos(i)) && (x<pos(i+1))
features.waveformscale=features.waveformscale.*1.1;
features=sc_updateclusterimages(features,mua,s_opt);
end;
i=4; % waveforms -
if (x>pos(i)) && (x<pos(i+1))
features.waveformscale=features.waveformscale.*.9;
features=sc_updateclusterimages(features,mua,s_opt);
end;
% if features.selected>0
if features.isioptions(1).tmax>15
c=5;
else
c=2;
end;
i=5; % ISI +
if b==3 % on right click open up menu for manual entry
if ((x>pos(i)) && (x<pos(i+1))) || ( (x>pos(i)) && (x<pos(i+1)))
prompt={'Enter max ISI lag (ms)'};
name='ISI lag';
numlines=1;
defaultanswer={'10'};
answer=inputdlg(prompt,name,numlines,defaultanswer);
try features.isioptions(1).tmax=str2num(answer{1});
catch
features.isioptions(1).tmax=10;
end;
if numel( features.isioptions(1).tmax)==0
features.isioptions(1).tmax=10;
end;
features=sc_updateclusterimages(features,mua,s_opt);
end;
else % otherwise do +/-
if (x>pos(i)) && (x<pos(i+1))
features.isioptions(1).tmax=features.isioptions(1).tmax+c;
end;
i=6; % ISI -
if (x>pos(i)) && (x<pos(i+1))
features.isioptions(1).tmax=max(1,features.isioptions(1).tmax-c);
end;
% features=sc_updateclusterimages(features,mua,s_opt);
end;
% end;
i=7; % toggle plotgroup
if (x>pos(i)) && (x<pos(i+1))
features.plotgroup=1-features.plotgroup;
disp('toggle');
sc_plotallclusters(features,mua);
end;
i=8; % toggle point size
if (x>pos(i)) && (x<pos(i+1))
features.plotsize=1-features.plotsize;
%disp('toggle');
end;
i=9; %Ndisplay++
if (x>pos(i)) && (x<pos(i+1))
features.Ndisplay=features.Ndisplay+5000;
end;
i=10; %Ndisplay--
if (x>pos(i)) && (x<pos(i+1))
if features.Ndisplay>5000
features.Ndisplay=features.Ndisplay-5000;
end;
end;
i=11; % create new label
if (x>pos(i)) && (x<pos(i+1))
prompt = {'Enter new label:'};
dlg_title = 'new cluster label';
num_lines = 1;
def = {''};
newlabel = inputdlg(prompt,dlg_title,num_lines,def);
if numel(newlabel)>0
features.labelcategories{numel( features.labelcategories)+1} = newlabel{1};
features.nlabels=numel( features.labelcategories);
features.clusterlabels(features.nlabels)=1;
end;
%features.plotsize=1-features.plotsize;
%disp('toggle');
end;
i=12; % rescaling
if ((x>pos(i)) && (x<pos(i+1))) || (b==114) % 'r' hotkey
features=sc_zoom_all(features);
end;
%
i=13; % undo
if (x>pos(i)) && (x<pos(i+1))
features.clusters=features.clusters_undo;
features=sc_updateclusterimages(features,mua,s_opt);
end;
i=14; % compare clusters
if (x>pos(i)) && (x<pos(i+1))
sc_compare_features(features,mua);
end;
i=15; % compute isi feature
if (x>pos(i)) && (x<pos(i+1))
text(-.5,0,'computing additional ISI features, using only visible spikes... ', 'BackgroundColor',[.7 .9 .7]);
drawnow;
features=sc_add_isi_feature(features,mua);
end;
i=16; % compute partial pca feature
if (x>pos(i)) && (x<pos(i+1))
text(-.5,0,'click on first sample in waveform', 'BackgroundColor',[.7 .9 .7]);
drawnow
[x,y,b] = sc_ginput(1);
psize=0.65; % find whish one was clicked on
xpos=[0 0 0 1 1 1 2 2 2];
ypos=[1 2 3 1 2 3 1 2 3];
for i=1:features.Nclusters
xo=(xpos(i)*(psize+.01))+.05;
yo=-(ypos(i)*(psize+.01))+1;
if (x> 1+xo) && (x<1+xo+psize) && (y>yo) && (y<psize+yo) % find waveform display that click is in
npoints=numel(mua.ts_spike);
%xa= (linspace(0,psize,npoints));
samples=((x-(1+xo))/psize)*npoints;
samples_from=max(min(round(samples),npoints),1);
text(-.5,0,'click on secondsample in waveform', 'BackgroundColor',[.7 .9 .7]);
drawnow;
plot([1 1].*x,yo+[0 psize],'k--');
[x,y,b] = sc_ginput(1);
npoints=numel(mua.ts_spike);
%xa= (linspace(0,psize,npoints));
samples=((x-(1+xo))/psize)*npoints;
samples_to=max(min(round(samples),npoints),1);
plot([1 1].*x,yo+[0 psize],'k--');
text(-.5,0,'computing PCA for visible clusters in selected waveform sample range... ', 'BackgroundColor',[.7 .9 .7]);
drawnow;
features=sc_compute_extra_PCA_coeffs_partial(features,mua,samples_from,samples_to);
end;
end;
end;
varargout={features};
end;