forked from ProcessNetwork/ProcessNetwork_Software
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathclassifySignal.m
36 lines (28 loc) · 1.23 KB
/
classifySignal.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
function [classifiedMat,nCounts] = classifySignal(sampleMat,binEdges,nBinMat,NoDataCode)
[nData,nSignals,nreps]=size(sampleMat);
classifiedMat=NaN(nData,nSignals,nreps);
sampleMat(sampleMat == NoDataCode) = NaN;
for s = 1:nSignals
smat = sampleMat(:,s,:);
cmat = nBinMat(s)*ones(size(smat));
for e = 1:nBinMat(s)
% Find data in the variable falling within this bin
ii = find(smat <= binEdges(s,e));
cmat(ii) = e; % Assign classification
smat(ii) = NaN; % remove these that were classified from further consideration
% If this is the last bin (greatest values), assign values greater
% than this bin edge to this bin
if e == nBinMat(s)
ii = find(smat > binEdges(s,e));
cmat(ii) = e; % Assign classification
smat(ii) = NaN; % remove these that were classified from further consideration
end
end
% Now assign the classified mat for this variable to the master
% variable
classifiedMat(:,s,:) = cmat;
end
classifiedMat(isnan(sampleMat)) = NaN;
nCounts = sum(~isnan(classifiedMat(:)));
nCounts = nCounts/nSignals/nreps;
classifiedMat(isnan(classifiedMat)) = NoDataCode;