-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextractBBdata.m
87 lines (65 loc) · 3.26 KB
/
extractBBdata.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
function bbstruct = extractBBdata(bbstruct,bbmeta,user)
%extractBBdata: Get BB data from C3D file, trim and resample
% Prasanna Sritharan, April 2018
%
% --------------------------------------------------------------------
% Copyright (C) 2018 Prasanna Sritharan
% Copyright (C) 2018 La Trobe University
%
% This program is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program. If not, see <http://www.gnu.org/licenses/>.
% --------------------------------------------------------------------
% assign struct fields
ampg = user.AMPG;
samp = user.SAMP;
structpath = user.DATASRCPATH;
% pull Body Builder point data from C3D files
subjs = fieldnames(bbstruct);
for s=1:length(subjs)
subj = subjs{s};
trials = fieldnames(bbstruct.(subjs{s}));
disp(' ');
disp(['Subject: ' subjs{s}]);
disp(['==============================']);
for t=1:length(trials)
trial = trials{t};
if isempty(find(strcmpi(trials{t},bbmeta.SUBJECTFIELDS),1))
% skip ignored trials
if bbstruct.(subjs{s}).(trials{t}).ignore==1
disp(['--Ignoring trial: ' trials{t}]);
continue
end
disp(['Loading trial data: ' trials{t}]);
% pull data
switch bbstruct.(subjs{s}).(trials{t}).analysedlegs
case 1 % one leg
rawdatastruct = pullBBpoint(bbstruct.(subjs{s}).(trials{t}),bbmeta,ampg,bbstruct.(subjs{s}).kinematicsonly);
bbstruct.(subj).(trial).data = resampleBBdata(rawdatastruct,samp);
bbstruct.(subj).(trial) = addTimeVector(bbstruct.(subj).(trial),-1,samp);
case 2 % two legs
for p=1:2
tempstruct = buildTempStruct(bbstruct.(subjs{s}).(trials{t}),p);
rawdatastruct = pullBBpoint(tempstruct,bbmeta,ampg,bbstruct.(subjs{s}).kinematicsonly);
bbstruct.(subj).(trial).data{p} = resampleBBdata(rawdatastruct,samp);
bbstruct.(subj).(trial) = addTimeVector(bbstruct.(subj).(trial),p,samp);
end
end
else
continue;
end
end
end
% save struct
save(fullfile(structpath,'bb.mat'),'-struct','bbstruct');
disp(' ');
end