-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathembeddingPlot.m
More file actions
119 lines (85 loc) · 3.56 KB
/
embeddingPlot.m
File metadata and controls
119 lines (85 loc) · 3.56 KB
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
classdef embeddingPlot < daughterPlot
properties
overlayHandle
end
methods
function EP = embeddingPlot(HS)
EP = EP@daughterPlot(HS);
EP.doPlot();
figure(EP.handSorter.mainFig.handle);
end
function doPlot(EP)
figure(EP.windowHandle);
clf;
% ffsubplot(2,1,1);
clusterList = unique(EP.handSorter.data.spikeClusters);
for clustNn=1:length(clusterList)
clustN = clusterList(clustNn);
ix = find(EP.handSorter.data.spikeClusters == clustN);
points = scatter(EP.handSorter.data.spikeEmbedding(ix,1),...
EP.handSorter.data.spikeEmbedding(ix,2),...
16,EP.handSorter.colorList(clustN,:),'o',...
'MarkerFaceColor','none'); hold on;
set(points,'ButtonDownFcn',@EP.plotClick);
end
set(gca,'XTick',[],'YTick',[]); box on;
% box off;
set(gca,'ButtonDownFcn',@EP.plotClick);
end
function plotOverlay(EP, spikeIX)
try
delete(EP.overlayHandle);
catch
end
x = EP.handSorter.data.spikeEmbedding(spikeIX,:);
figure(EP.windowHandle);
EP.overlayHandle = scatter(x(1),x(2),16,'k','o','LineWidth',2,...
'MarkerFaceColor','k','MarkerEdgeColor','none');
figure(EP.handSorter.mainFig.handle);
end
function setPointLock(EP, caller, event)
spikeIX = event.data;
if ~isempty(spikeIX)
EP.plotOverlay(spikeIX);
else
try
delete(EP.overlayHandle);
catch
end
end
end
function convertSpike(EP, caller, event)
refreshData(EP, caller, event);
spikeIX = event.data;
EP.plotOverlay(spikeIX);
end
function removeSpike(EP, caller, event)
refreshData(EP, caller, event);
end
function refreshData(EP, caller, event)
EP.doPlot();
figure(EP.handSorter.mainFig.handle);
end
function plotClick(EP, obj, event)
if strcmp(get(obj,'Type'),'axes')
ax = obj;
else
ax = get(obj, 'Parent');
end
pt = get(ax, 'CurrentPoint');
clickVec = pt(1,1:2);
score1s = EP.handSorter.data.spikeEmbedding(:,1);
score2s = EP.handSorter.data.spikeEmbedding(:,2);
distances = (score1s - clickVec(1)).^2 + (score2s - clickVec(2)).^2;
[B,spikeIX] = min(distances);
clustN = EP.handSorter.data.spikeClusters(spikeIX);
disp(['Cluster ',EP.handSorter.spikeCategories(clustN),' spike #',num2str(spikeIX)]);
EP.plotOverlay(spikeIX);
% Lock onto spike
newPos = EP.handSorter.time(EP.handSorter.data.spikeSamples(spikeIX));
EP.handSorter.selectedPointIX = spikeIX;
EP.handSorter.setFocusLocation(newPos);
EP.handSorter.setMode(1, spikeIX);
end
end
end