-
Notifications
You must be signed in to change notification settings - Fork 0
/
Commander_BOF_H_mice.m
156 lines (128 loc) · 7.22 KB
/
Commander_BOF_H_mice.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
%% paths and filenames
PathVideo = 'd:\Projects\BOF\VideoData\';
PathDLC = 'd:\Projects\BOF\DLC\';
PathOut = 'd:\Projects\BOF\Behavior\';
PathPreset = 'd:\Projects\BOF\Presets\';
% % 1T
% FileNames = {
% 'H02_1T','H03_1T','H04_1T','H07_1T','H08_1T','H10_1T','H11_1T','H12_1T','H13_1T','H14_1T','H15_1T','H16_1T','H17_1T','H19_1T','H22_1T','H23_1T'
% };
% ArenaType = 'circle';
% % 2T
% FileNames = {
% 'H02_2T','H03_2T','H04_2T','H07_2T','H08_2T','H10_2T','H11_2T','H12_2T','H13_2T','H14_2T','H15_2T','H16_2T','H17_2T','H19_2T','H22_2T','H23_2T'
% };
% ArenaType = 'circle';
%
%
% % 3T
% FileNames = {
% 'H02_3T','H03_3T','H04_3T','H07_3T','H08_3T','H10_3T','H11_3T','H12_3T','H13_3T','H14_3T','H15_3T','H16_3T','H17_3T','H19_3T','H22_3T','H23_3T'
% };
% ArenaType = 'circle';
%
% 4T
FileNames = {
'H02_4T','H03_4T','H04_4T','H07_4T','H08_4T','H10_4T','H11_4T','H12_4T','H13_4T','H14_4T','H15_4T','H16_4T','H17_4T','H19_4T','H22_4T','H23_4T'
};
ArenaType = 'polygon';
%
% % 5T
% FileNames = {
% 'H02_5T','H03_5T','H04_5T','H07_5T','H08_5T','H10_5T','H11_5T','H12_5T','H13_5T','H14_5T','H15_5T','H16_5T','H17_5T','H19_5T','H22_5T','H23_5T'
% };
% ArenaType = 'circle';
FilesNumber = length(FileNames);
%% variables initiation
FreezingPercent = zeros(1,FilesNumber);
FreezingNumber = zeros(1,FilesNumber);
FreezingMeanTime = zeros(1,FilesNumber);
RearsPercent = zeros(1,FilesNumber);
RearsNumber = zeros(1,FilesNumber);
RearsMeanTime = zeros(1,FilesNumber);
if ArenaType == "polygon"
CornersWallsCenterPercent = zeros(3,FilesNumber);
CornersWallsCenterNumber = zeros(3,FilesNumber);
CornersWallsCenterMeanTime = zeros(3,FilesNumber);
CornersWallsCenterDistance = zeros(3,FilesNumber);
CornersWallsCenterMeanDistance = zeros(3,FilesNumber);
CornersWallsCenterVelocity = zeros(3,FilesNumber);
else
WallsMiddleCenterPercent = zeros(3,FilesNumber);
WallsMiddleCenterNumber = zeros(3,FilesNumber);
WallsMiddleCenterMeanTime = zeros(3,FilesNumber);
WallsMiddleCenterDistance = zeros(3,FilesNumber);
WallsMiddleCenterMeanDistance = zeros(3,FilesNumber);
WallsMiddleCenterVelocity = zeros(3,FilesNumber);
end
RestOtherLocomotionPercent = zeros(3,FilesNumber);
RestOtherLocomotionNumber = zeros(3,FilesNumber);
RestOtherLocomotionMeanTime = zeros(3,FilesNumber);
RestOtherLocomotionDistance = zeros(3,FilesNumber);
RestOtherLocomotionMeanDistance = zeros(3,FilesNumber);
RestOtherLocomotionVelocity = zeros(3,FilesNumber);
Distance = zeros(1,FilesNumber);
Velocity = zeros(1,FilesNumber);
% % BOF objects 1T
% ObjectNumber = zeros(3,length(FileNames));
% ObjectPercent = zeros(3,length(FileNames));
% ObjectMeanTime = zeros(3,length(FileNames));
% ObjectMeanDistance = zeros(3,length(FileNames));
% ObjectDistance = zeros(3,length(FileNames));
% BOF objects 2-5T
ObjectNumber = zeros(6,length(FileNames));
ObjectPercent = zeros(6,length(FileNames));
ObjectMeanTime = zeros(6,length(FileNames));
ObjectMeanDistance = zeros(6,length(FileNames));
ObjectDistance = zeros(6,length(FileNames));
%% main part
for file = 1:length(FileNames)
FilenameVideo = sprintf('BOF_%s.mp4', FileNames{file});
FilenameDLC = sprintf('BOF_%sDLC_resnet152_MiceUniversal152Oct23shuffle1_1000000.csv',FileNames{file});
FilenamePreset = sprintf('BOF_%s_Preset.mat', FileNames{file});
fprintf('Processing of BOF_%s\n', FileNames{file})
[Acts, BodyPartsTraces] = BehaviorAnalyzerBOF(PathVideo, FilenameVideo, PathDLC, FilenameDLC, PathOut, 1, 0, PathPreset, FilenamePreset);
% variables calculaion
FreezingPercent(file) = Acts(4).ActPercent;
FreezingNumber(file) = Acts(4).ActNumber;
FreezingMeanTime(file) = Acts(4).ActMeanTime;
RearsPercent(file) = Acts(5).ActPercent;
RearsNumber(file) = Acts(5).ActNumber;
RearsMeanTime(file) = Acts(5).ActMeanTime;
if ArenaType == "polygon"
CornersWallsCenterPercent(1:3,file) = [Acts(6).ActPercent; Acts(7).ActPercent; Acts(8).ActPercent];
CornersWallsCenterNumber(1:3,file) = [Acts(6).ActNumber; Acts(7).ActNumber; Acts(8).ActNumber];
CornersWallsCenterMeanTime(1:3,file) = [Acts(6).ActMeanTime; Acts(7).ActMeanTime; Acts(8).ActMeanTime];
CornersWallsCenterDistance(1:3,file) = [Acts(6).Distance; Acts(7).Distance; Acts(8).Distance];
CornersWallsCenterMeanDistance(1:3,file) = [Acts(6).ActMeanDistance; Acts(7).ActMeanDistance; Acts(8).ActMeanDistance];
CornersWallsCenterVelocity(1:3,file) = CornersWallsCenterDistance(1:3,file)./(CornersWallsCenterMeanTime(1:3,file).*CornersWallsCenterNumber(1:3,file))*100;
else
WallsMiddleCenterPercent(1:3,file) = [Acts(6).ActPercent; Acts(7).ActPercent; Acts(8).ActPercent];
WallsMiddleCenterNumber(1:3,file) = [Acts(6).ActNumber; Acts(7).ActNumber; Acts(8).ActNumber];
WallsMiddleCenterMeanTime(1:3,file) = [Acts(6).ActMeanTime; Acts(7).ActMeanTime; Acts(8).ActMeanTime];
WallsMiddleCenterDistance(1:3,file) = [Acts(6).Distance; Acts(7).Distance; Acts(8).Distance];
WallsMiddleCenterMeanDistance(1:3,file) = [Acts(6).ActMeanDistance; Acts(7).ActMeanDistance; Acts(8).ActMeanDistance];
WallsMiddleCenterVelocity(1:3,file) = WallsMiddleCenterDistance(1:3,file)./(WallsMiddleCenterMeanTime(1:3,file).*WallsMiddleCenterNumber(1:3,file))*100;
end
RestOtherLocomotionPercent(1:3,file) = [Acts(1).ActPercent; Acts(2).ActPercent; Acts(3).ActPercent];
RestOtherLocomotionNumber(1:3,file) = [Acts(1).ActNumber; Acts(2).ActNumber; Acts(3).ActNumber];
RestOtherLocomotionMeanTime(1:3,file) = [Acts(1).ActMeanTime; Acts(2).ActMeanTime; Acts(3).ActMeanTime];
RestOtherLocomotionDistance(1:3,file) = [Acts(1).Distance; Acts(2).Distance; Acts(3).Distance];
RestOtherLocomotionMeanDistance(1:3,file) = [Acts(1).ActMeanDistance; Acts(2).ActMeanDistance; Acts(3).ActMeanDistance];
RestOtherLocomotionVelocity(1:3,file) = RestOtherLocomotionDistance(1:3,file)./(RestOtherLocomotionMeanTime(1:3,file).*RestOtherLocomotionNumber(1:3,file))*100;
Distance(file) = BodyPartsTraces(13).AverageDistance;
Velocity(file) = BodyPartsTraces(13).AverageSpeed;
% for 2-5T
ObjectNumber(1:6,file) = [Acts(9).ActNumber; Acts(10).ActNumber; Acts(11).ActNumber;Acts(12).ActNumber; Acts(13).ActNumber; Acts(14).ActNumber];
ObjectPercent(1:6,file) = [Acts(9).ActPercent; Acts(10).ActPercent; Acts(11).ActPercent;Acts(12).ActPercent; Acts(13).ActPercent; Acts(14).ActPercent];
ObjectMeanTime(1:6,file) = [Acts(9).ActMeanTime; Acts(10).ActMeanTime; Acts(11).ActMeanTime;Acts(12).ActMeanTime; Acts(13).ActMeanTime; Acts(14).ActMeanTime];
ObjectMeanDistance(1:6,file) = [Acts(9).ActMeanDistance; Acts(10).ActMeanDistance; Acts(11).ActMeanDistance;Acts(12).ActMeanDistance; Acts(13).ActMeanDistance; Acts(14).ActMeanDistance];
ObjectDistance = ObjectNumber.*ObjectMeanDistance;
% % for 2-5T
% ObjectNumber(1:6,file) = [Acts(9).ActNumber; Acts(10).ActNumber];
% ObjectPercent(1:6,file) = [Acts(9).ActPercent; Acts(10).ActPercent];
% ObjectMeanTime(1:6,file) = [Acts(9).ActMeanTime; Acts(10).ActMeanTime];
% ObjectMeanDistance(1:6,file) = [Acts(9).ActMeanDistance; Acts(10).ActMeanDistance];
% ObjectDistance = ObjectNumber.*ObjectMeanDistance;
clear 'Acts' 'BodyPartsTraces';
end