-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrunAlgorithmForIC.m
162 lines (133 loc) · 3.79 KB
/
runAlgorithmForIC.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
%%%%%%% Pelvis
target = Acceleration_Pelvis_X;
[pks,locs] = findpeaks(target, 'MINPEAKHEIGHT', 2);
if(draw)
figure('name', strcat('Pelvis-', int2str(i)));
plot(1:END_TIME, target); hold on;
plot(locs,pks+0.05,'k^','markerfacecolor',[1 0 0]), hold off;
end
% Save locs to PelvisTime
OUT_FILE_NAME = strcat(ROOT_DIR, 'IC-Time/PelvisTime-', int2str(i), '.txt');
OUT = [];
OUT = [OUT ; locs];
%OUT = [];
%for eventIndex = 1 : length(eventTimes.ICs)
% tmp = abs(locs - eventTimes.ICs(eventIndex));
% ind = find(tmp == min(tmp));
% if(min(tmp) > 30)
% continue; % We dont accept frame different bigger then 30
% end
% OUT = [OUT ;locs(ind)];
%end
dlmwrite(OUT_FILE_NAME, OUT);
%%%%%%%% Tight
%temp = [];
%target = Acceleration_RightUpperLeg_X;
%[pks,locs] = findpeaks(target, 'MINPEAKHEIGHT', 2.5);
%
%if(draw)
% figure('name',strcat('Right Upper Leg-', int2str(i)));
% plot(1:END_TIME, target); hold on;
%
% set(gca,'FontSize',28)
% xlabel('Frame');
% ylabel('Acceleration (acc/s^2)');
% title('Upper Leg Acceleration (Anterior Posterior)');
%end
%am = [];
%mx = [];
%
%for index = 1 : length(locs);
% if(locs(index) + 50 < END_TIME)
% [am(index), mx(index)] = min(target(locs(index):locs(index)+50));
% mx(index) = mx(index) + locs(index);
% end
%end
%
%plot(mx,am+0.05,'k^','markerfacecolor',[1 0 0], 'MarkerSize', 12);
%
%OUT_FILE_NAME = strcat(ROOT_DIR, 'TightTime-', int2str(i), '.txt');
%dlmwrite(OUT_FILE_NAME, mx);
%%%%%%% Shank
temp = [];
target = AngularVelocity_RightLowerLeg_Y;
[pks,locs] = findpeaks(target, 'MINPEAKHEIGHT', 2.5);
if(draw)
figure('name',strcat('Right Lower Leg-', int2str(i)));
plot(1:END_TIME, target); hold on;
end
am = [];
mx = [];
for index = 1 : length(locs)
if(locs(index) + 50 < END_TIME)
[am(index), mx(index)] = min(target(locs(index):locs(index)+50));
mx(index) = mx(index) + locs(index);
end
end
if(draw)
plot(mx,am+0.05,'k^','markerfacecolor',[1 0 0]), hold off;
end
temp = [temp ; mx];
target = AngularVelocity_LeftLowerLeg_Y;
[pks,locs] = findpeaks(target, 'MINPEAKHEIGHT', 2.5);
am = [];
mx = [];
for index = 1 : length(locs)
if(locs(index) + 50 < END_TIME)
[am(index), mx(index)] = min(target(locs(index):locs(index)+50));
mx(index) = mx(index) + locs(index);
end
end
if(draw)
figure('name',strcat('Left Lower Leg-', int2str(i)));
plot(1:END_TIME, target); hold on;
plot(mx,am+0.05,'k^','markerfacecolor',[1 0 0]), hold off;
end
temp = [temp ; mx];
temp = sort(temp, 'ascend');
%OUT = [];
%for eventIndex = 1 : length(eventTimes.ICs)
% tmp = abs(temp - eventTimes.ICs(eventIndex));
% ind = find(tmp == min(tmp));
% if(min(tmp) > 30)
% continue; % We dont accept frame different bigger then 30
% end
% OUT = [OUT temp(ind)];
%end
OUT = temp;
% Save locs to TightTime
OUT_FILE_NAME = strcat(ROOT_DIR, 'IC-Time/ShankTime-', int2str(i), '.txt');
dlmwrite(OUT_FILE_NAME, OUT);
%%%%%%% Foot
temp = [];
target = Acceleration_RightFoot_X;
[pks,locs] = findpeaks(target, 'MINPEAKHEIGHT', 10);
if(draw)
figure('name',strcat('Right Foot-', int2str(i)));
plot(1:END_TIME, target); hold on;
plot(locs,pks+0.05,'k^','markerfacecolor',[1 0 0]), hold off;
end
temp = [temp ; locs];
target = Acceleration_LeftFoot_X;
[pks,locs] = findpeaks(target, 'MINPEAKHEIGHT', 10);
if(draw)
figure('name',strcat('Left Foot-', int2str(i)));
plot(1:END_TIME, target); hold on;
plot(locs,pks+0.05,'k^','markerfacecolor',[1 0 0]), hold off;
end
temp = [temp ; locs];
temp = sort(temp, 'ascend');
% Save locs to FootTime
%OUT = [];
%for eventIndex = 1 : length(eventTimes.ICs)
% tmp = abs(temp - eventTimes.ICs(eventIndex));
% ind = find(tmp == min(tmp));
% if(min(tmp) > 30)
% continue; % We dont accept frame different bigger then 30
% end
% OUT = [OUT temp(ind)];
%end
OUT = temp;
% Save locs to TightTime
OUT_FILE_NAME = strcat(ROOT_DIR, 'IC-Time/FootTime-', int2str(i), '.txt');
dlmwrite(OUT_FILE_NAME, OUT);