-
Notifications
You must be signed in to change notification settings - Fork 0
/
mcarrayTrimSyncedData.m
46 lines (27 loc) · 1.05 KB
/
mcarrayTrimSyncedData.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
function data = mcarrayTrimSyncedData(data)
% data = mcarrayTrimSyncedData(data)
%
% input: struct array of mocap structs, with a .syncpoint field.
% The syncpoint is given in frames, and may be obtained from the
% mcarraySyncWindowed function
%
% output: struct array of mocap structs. Aligned according to the
% syncpoint field, and cut by the latest start and earliest
% stop time across all recordings.
%
% By Kristian Nymoen, RITMO/University of Oslo, 2019
%
dnfold = [data.nFrames];
padding = 500;
for i = 1:length(data)
offset(i) = round(data(i).syncpoint)+padding;
data(i).data = [nan(offset(i) , data(i).nMarkers*3); data(i).data; nan(offset(i) , data(i).nMarkers*3);];
data(i).nFrames = data(i).nFrames + offset(i)*2;
end
startTrim = max([offset])+1;
endTrim = min([data.nFrames])-min(offset);
for i = 1:length(data)
data(i) = mctrim(data(i),startTrim,endTrim,'frame');
data(i).syncpoint = 0;
end
end