forked from oliveirafhm/NCCSystem-Toolbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpeakAnalysis.m
61 lines (53 loc) · 2.08 KB
/
peakAnalysis.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
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
% Peak analysis
% Run after windowing.m
% PhD student - Fabio Henrique ([email protected]) - 10/01/2019
% Last modification: xx/xx/2019
% Used in World Congress 2018
%% Estimate peaks (for plessey and tremsen signal)
nPeaksPerTask = [0 0 5 5 5 5 15 15 15 15];
commandwindow;
analysisWn = input('\n\nType the window number (task) for analysis (1-10): ');
maxPeaks = nPeaksPerTask(analysisWn);
nPeaksFlag = 0;
peakProminence = 0;
invertPlesseyFlag = 0;
plotFlag = 1;
sensorName = {'Plessey1','Gyro3Y','Gyro3Z'};
% Peak params
% min peak dist - same value for all sensors
if maxPeaks == 5
mpd = 1.2;
elseif maxPeaks == 15
mpd = 0.30;
end
mphP = 0.2; % min peak height
mphGY = 0.15;
mphGZ = 0.2;
% Plessey
window = windowsFiltered(analysisWn):windowsFiltered(analysisWn+1);
wnPlesseySig = env_ps1_filtered(window);
if max(wnPlesseySig) < abs(min(wnPlesseySig))*0.9 || invertPlesseyFlag
wnPlesseySig = wnPlesseySig * -1;
end
% fprintf('\n-- %s --\n',sensorName{1});
[pks{1}, locs{1}] = PeakFinder1(wnPlesseySig, meanEnvSampleRate,...
mpd, mphP, maxPeaks, nPeaksFlag, peakProminence, plotFlag);
if plotFlag, title([sensorName{1} ' signal peaks of task ' num2str(analysisWn)],'FontSize',18); end
% Tremsen
tsWindow = tsWindows(analysisWn):tsWindows(analysisWn+1);
% fprintf('\n-- %s --\n',sensorName{2});
[pks{2}, locs{2}] = PeakFinder1(gyro3Y_filtered(tsWindow), tsSampleRate,...
mpd, mphGY, maxPeaks, nPeaksFlag, peakProminence, plotFlag);
if plotFlag, title([sensorName{2} ' signal peaks of task ' num2str(analysisWn)],'FontSize',18); end
% fprintf('\n-- %s --\n',sensorName{3});
[pks{3}, locs{3}] = PeakFinder1(gyro3Z_filtered(tsWindow), tsSampleRate,...
mpd, mphGZ, maxPeaks, nPeaksFlag, peakProminence, plotFlag);
if plotFlag, title([sensorName{3} ' signal peaks of task ' num2str(analysisWn)],'FontSize',18); end
close(2:4)
%% Estimate features based on peaks
printFlag = 1;
fprintf('\nSource file: %s\n',fileName);
for i = 1:length(sensorName)
fprintf('\n-- Features of %s sensor of task %d --\n',sensorName{i}, analysisWn);
[~,~,~,~] = PeakFeatures(pks{i}, locs{i}, printFlag);
end