-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTREATMILL_force_split_mot.m
61 lines (56 loc) · 1.86 KB
/
TREATMILL_force_split_mot.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
function [L, R]=TREATMILL_force_split_mot(path,OPTIONS)
[out] = ReadMotFile(path);
%% I assume that the first strike is gone be a right foot strike!
if OPTIONS.FP_used ==1
indexuse = 3;
forcevaluesindex = [2:10];
elseif OPTIONS.FP_used ==2
indexuse = 12;
forcevaluesindex = [11:18];
end
v = (out.data(:,indexuse)>OPTIONS.FP_Stance_Threshold);
streaks = [];
streak_indices = {};
current_streak = 0;
start_index = 0;
for i = 1:length(v)
if v(i) == 1
if current_streak == 0
start_index = i;
end
current_streak = current_streak + 1;
elseif current_streak > 0
streaks(end+1) = current_streak;
streak_indices{end+1}= start_index:(i-1);
current_streak = 0;
end
end
if current_streak > 0
streaks(end+1) = current_streak;
streak_indices{end+1}= start_index:(i-1);
end
odd_streak_indices = [];
for i = 1:2:numel(streak_indices)
odd_streak_indices = [odd_streak_indices streak_indices{i}];
end
even_streak_indices = [];
for d = 2:2:numel(streak_indices)
even_streak_indices = [even_streak_indices streak_indices{d}];
end
[b_filt,a_filt] = butter(2, 20/(OPTIONS.FREQ_ANALOG/2), 'low');
inforce_moments = [forcevaluesindex(1:3), [forcevaluesindex(end-2):forcevaluesindex(end)]];
inforce_moments = [forcevaluesindex]; %% achtung <cop wird mit gefilyert
for y = 1 : length (inforce_moments)
out.data(:,inforce_moments(y)) = filtfilt(b_filt,a_filt,out.data(:,inforce_moments(y)));
end
GRF1= out.data;
GRF1(odd_streak_indices',forcevaluesindex)= 0;
GRF2= out.data;
GRF2(even_streak_indices',forcevaluesindex)= 0;
[GRF1] = force_clean_up(GRF1,OPTIONS.FP_Stance_Threshold);
[GRF2] = force_clean_up(GRF2,OPTIONS.FP_Stance_Threshold);
L = [erase(path, '.mot'), '_LeftGroundContact.mot'];
R = [erase(path, '.mot'), '_RightGroundContact.mot'];
writeMot(GRF1(:,2:end),GRF1(:,1),L);
writeMot(GRF2(:,2:end),GRF2(:,1),R);
end