-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfullSort.m
More file actions
63 lines (50 loc) · 1.82 KB
/
fullSort.m
File metadata and controls
63 lines (50 loc) · 1.82 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
function data = fullSort(data, nClusters, sensitivities)
%sensitivities = [1.4, 6, 4]; % ab1 was 1.2
%sensitivities = [ 3, 6, 10]; % ab2
%sensitivities = [ 1.8, 6, 4]; % small ab2
%sensitivities = [ 2.2, 6, 4]; % ab4
% First, quick-sort
% data2 = adaptQuickSort(data, nClusters);
data2 = quickSort(data, nClusters, sensitivities(1));
if length(unique(data2.spikeClusters)) == nClusters
% Then try to reclassify each spike after accounting for surrounding
% spikes.
data3 = resortResid(data2);
% Now redetect any spikes in the residual.
data4 = redetectResid(data3, sensitivities(2));
% Now reclassify those newly found spikes.
data5 = resortResid(data4);
% Now remove any spikes too close to each other
[data6, nRemoved] = pairScan(data5);
% Now reclassify again.
data7 = resortResid(data6);
% Now try to deal with difficult doublets
data8 = doubleScan(data7, sensitivities(3), false, true);
% Recompute the embedding for display;
data9 = embedFromResidual(data8);
disp(' ');
disp(['quickSorted: ',num2str(length(data2.spikeClusters))]);
disp('Resorted: ');
compareSort(data2,data3);
disp('Re-detected: ');
compareSort(data3,data4);
disp('Resorted: ');
compareSort(data4,data5);
disp(['Removed multiplets: ',num2str(nRemoved)]);
disp('Resorted: ');
compareSort(data6,data7);
disp('Pair Sorted.');
disp('Resorted: ');
compareSort(data8,data9);
disp(' ');
data = data9;
else
data = data2;
end
% figure;
% subplot(1,2,1);
% plotEmbeddings(data8);
% subplot(1,2,2);
% plotEmbeddings(data9);
% pause();
%