-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpairScan.m
More file actions
29 lines (24 loc) · 1022 Bytes
/
pairScan.m
File metadata and controls
29 lines (24 loc) · 1022 Bytes
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
% Removes spikes in the same cluster less that ISIlimit apart
function [data, nRemoved] = pairScan(data)
ISIlimit = .003; % sec
clusterList = unique(data.spikeClusters);
for clustNn = 1:length(clusterList)
clustN = clusterList(clustNn);
nRemoved(clustN) = 0;
nFound = 1;
while (nFound > 0)
ix = find(data.spikeClusters == clustN);
sortedSamples = sort(data.spikeSamples(ix),'ascend');
ISIs = diff(sortedSamples);
ISIix = find(ISIs < ISIlimit*data.sampleRate);
nFound = length(ISIix);
if (nFound > 0)
sampToRemove = sortedSamples(ISIix(1));
origIX = dsearchn(data.spikeSamples(ix)',sampToRemove);
data.spikeSamples(ix(origIX)) = [];
data.spikeClusters(ix(origIX)) = [];
data.spikeEmbedding(ix(origIX),:) = [];
nRemoved(clustN) = nRemoved(clustN) + 1;
end
end
end