-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathF_Time_Feature_PeakAnalysis.m
More file actions
31 lines (23 loc) · 1.14 KB
/
F_Time_Feature_PeakAnalysis.m
File metadata and controls
31 lines (23 loc) · 1.14 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
function peakFeatures = F_Time_Feature_PeakAnalysis(frame,peakNumber)
%detrend the data
% [p,s,mu] = polyfit((1:numel(frame))',frame,6);
% f_y = polyval(p,(1:numel(frame))',[],mu);
% detrendedFrame = frame - f_y;
[pks,locs,widths,proms] = findpeaks(frame,'SortStr','descend','NPeaks',peakNumber);
if(length(pks)==peakNumber)
peakFeatures= [pks',diff(locs)',widths',proms', mean(pks), mean(diff(locs)), mean(widths),mean(proms)];
else
pks=[pks; zeros(peakNumber-length(pks),1)];
locs=[locs; zeros(peakNumber-length(locs),1)];
widths=[widths; zeros(peakNumber-length(widths),1)];
proms=[proms; zeros(peakNumber-length(proms),1)];
peakFeatures= [pks',diff(locs)',widths',proms', mean(pks), mean(diff(locs)), mean(widths),mean(proms)];
end
% peakFeatures= [pks',diff(locs)',widths',proms', mean(pks), mean(diff(locs)), mean(widths),mean(proms)];
% detrendedFrame=-detrendedFrame;
% [pks,locs,widths,proms] = findpeaks(detrendedFrame,'SortStr','descend','NPeaks',peakNumber);
% meanIntervalI = mean(diff(locs));
% meanPksI=mean(pks);
% meanWidthsI=mean(widths);
% meanProminanceI=mean(proms);
end