forked from open-ephys/simpleclust
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sc_intersect_cluster.m
31 lines (24 loc) · 1.05 KB
/
sc_intersect_cluster.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
function features=intersect_cluster(features,i,s_opt,featureselects)
[px,py] =sc_getpolygon(features,features.colors(i,:));
if i>1
inthiscluster=find(features.clusters==i);
else % if we're intersecting the null cluster, just take out from any other cluster and assign rest to noise
inthiscluster=find(features.clusters>0);
end;
dX=features.data(features.featureselects(1),inthiscluster);
dY=features.data(features.featureselects(2),inthiscluster);
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;
if i==1 %if called from null cluster, move all outside selection to noise
features.clusters(inthiscluster(~in))=2;
% if we're adding from all to noise, also zoom in to fit all visible
features=sc_zoom_all(features);
else
features.clusters(inthiscluster(~in))=1;
end;