-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbsoid_fsml.m
46 lines (41 loc) · 2.09 KB
/
bsoid_fsml.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 [labels_fsALL,f_10fps_fs] = bsoid_fsml(data_test,fps,behv_mdl)
%BSOID_FSML Frame-shifted B-SOiD applying multi-class support vector machine prediction on FPS/10 repeated times, each offset by a frame.
%
% [LABELS_FSALL,F_10FPS_FS] = BSOID_FSML(DATA,BEHV_MDL,FPS,SMTH_HSTRY,SMTH_FUTR) outputs classified behaviors matching your camera's frame-rate
%
% INPUTS:
% DATA_TEST Matrix of the positons of the 6-body parts outlining the rodent over time videotaped from the bottom looking up.
% Rows represents time.
% Columns 1 & 2 tracks snout; columns 3 to 6 tracks the two front paws; Columns 7 to 10 tracks the two hind paws;
% Columns 11 & 12 tracks the base of the tail. Tested on tracking data generated by DeepLabCut 2.0.
% FPS Rounded frame rate, can use VideoReader/ffmpeg(linux command) to automatically detect the input video fps. Try to match training dataset.
% BEHV_MDL Support Vector Machine Classifier Model. This is the output of bsoid_mdl.
%
% OUTPUTS:
% LABELS Predicted action based on the model, the group here matches the group number in the bsoid_gmm, 10 frame/second temporal resolution.
% F_10FPS_TEST The features collated for the test animal, 10 frame/second temporal resolution.
%
% EXAMPLES:
% clear data;
% load test_mouse.mat OF_mdl.mat;
% [labels,f_10fps_test] = bsoid_svm(data_test,60,OF_mdl);
%
% Created by Alexander Hsu, Date: 071919
% Contact [email protected]
%% Frameshift paradigm
for j = 1:fps/10
for i = 1:length(data_test)
data_test_fs{i} = data_test{i}(j:end,:);
end
[labels_fs{j},f_10fps_fs{j}] = bsoid_svm(data_test_fs,fps,behv_mdl); % Change 60 to your frame rate.
end
clear labels_fsALL labels_fsALLvec a
for k = 1:length(labels_fs{1})
for j = 1:fps/10
cap = length(labels_fs{end}{k});
labels_fsALL{k}(:,j) = labels_fs{j}{k}(1:cap);
end
a{k} = labels_fsALL{k}';
labels_fsALL{k} = a{k}(:);
end
return