forked from DeNardoLab/BehaviorDEPOT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
genTracking_custom.m
38 lines (30 loc) · 1.23 KB
/
genTracking_custom.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
%genTracking
%INPUT: data (variable containing data read from CSV/H5), hmpl,
%& cutoffThreshold
%OUTPUT: Tracking structure
%FUNCTION: Convert data into Tracking structure format; apply hampel
%correction; remove unlikely points from Tracking
function Tracking = genTracking_custom(data, Params)
cutoffThreshold = Params.cutoffThreshold;
hmpl = Params.hampel;
% Convert data to Tracking structure and apply hampel correction
part_names = Params.part_names;
for i = 1:length(part_names)
this_part = part_names{i};
if hmpl
Tracking.(this_part) = hampel(data(i*3-1:i*3,:));
Tracking.(this_part) = [Tracking.(this_part); data(1+i*3,:)];
else
Tracking.(this_part) = data(i*3-1:i*3+1,:);
end
% toss data below likelihood threshold
Tracking.NaNs.(this_part) = find(Tracking.(this_part)(3,:) <= cutoffThreshold);
Tracking.(this_part)(1:2, Tracking.NaNs.(this_part)) = NaN;
i_reject = ['Percent_Rejcted_' this_part];
Tracking.NaNs.(i_reject) = length(Tracking.NaNs.(this_part))/length(Tracking.(this_part))*100;
end
disp('Tracking Structure Assembled')
if hmpl
disp('Hampel Correction Applied')
end
end