forked from open-ephys/simpleclust
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sc_add_to_cluster_from_any.m
38 lines (26 loc) · 994 Bytes
/
sc_add_to_cluster_from_any.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
function features=add_to_cluster_from_any(features,i,s_opt,featureselects)
[px,py] =sc_getpolygon(features,features.colors(i,:));
% only visible ones
use=zeros(1,numel(features.ts));
for j=1:features.Nclusters
if features.clustervisible(j)
incluster=find(features.clusters==j );
use(incluster)=1;
end;
end;
notassigned=find(use); % just select from all
dX=features.data(features.featureselects(1),notassigned);
dY=features.data(features.featureselects(2),notassigned);
if ~s_opt.mex_intersect
in = inpolygon(dX,dY,px,py); % slow matlab method
else
% WAY faster Fast InPolygon detection MEX by Guillaume JACQUENOT
% from http://www.mathworks.com/matlabcentral/fileexchange/20754-fast-inpolygon-detection-mex
in = InPolygon(dX,dY,px,py);
end;
features.clusters_undo=features.clusters;
features.clusters(notassigned(in))=i;
% if we're adding from all to noise, also zoom in to fit all visible
if i==2
features=sc_zoom_all(features);
end;