-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathISB.m
70 lines (60 loc) · 2.3 KB
/
ISB.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
function T = ISB(T, subject)
LR={'Left' 'Right'};
Co={'PelCo' 'ThiCo' 'TibCo' 'UNTibCo' 'FootCo'};
xyz={'x' 'y' 'z'};
% Kinematic angle extraction
for i_sub=subject
disp(['subject:',num2str(i_sub)])
for side=[2]
Static.Trajectory=T(i_sub).Static.(LR{side});
% out = checkISBDimensions(Static.Trajectory);
% if out==1
% disp(['sub:' num2str(i_sub) ' static' ' side:' LR{side}])
% continue;
% end
Static=Coordinate(Static); % Segments Coordinate Defenition
% Rotation Matrix for Static Offset _______________________________________
for i=1:length(Co)
for k=1:length(xyz)
if i==1
Static0.(Co{i}).(xyz{k})=mean(Static.(Co{i}).(xyz{k}),1);
else
for h=1:length(LR) %Left,Right
Static0.(Co{i}).(LR{h}).(xyz{k})=mean(Static.(Co{i}).(LR{h}).(xyz{k}),1);
end
end
end
end
Static2=EulerAngle(Static,Static0); % Euler Angle Calculation
% T(i_sub).Static.Static0.(LR{side})=Static0;
% T(i_sub).Static.Static2.(LR{side})=Static2;
for i_trial=1:length(T(i_sub).Trajectory.(LR{side}))
kin.Trajectory = T(i_sub).Trajectory.(LR{side})(i_trial);
out = checkISBDimensions(kin.Trajectory);
% if out==1
% disp(['sub:' num2str(i_sub) ' kin' ' trial:' num2str(i_trial) ' side:' LR{side}])
% continue;
% end
kin=Coordinate(kin); % Segments Coordinate Defenition
kin2=EulerAngle(kin,Static0); % Euler Angle Calculation
T(i_sub).KIN.(LR{side})(i_trial).value = kin2;
clear kin kin2
end
clear Static Static0 Static2
end
end
disp('ISB done')
end
function out = checkISBDimensions(traj)
% this function check if dimension of all markers in a trajectory set is
% consistent or not
out=0;
allFields= fieldnames(traj);
t = size(traj.(allFields{1}),1);
for i=2:length(allFields)
if size(traj.(allFields{i}),1) ~= t
warning('wrong marker dimension in traj -> %s',allFields{i})
out=1;
end
end
end