-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake_videos.m
97 lines (75 loc) · 3.1 KB
/
make_videos.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
function make_videos(mark_courtship, mark_courtship_zero_dist_max, output_folder, video_path, video_id, circle_num_to_arena_id_map, stationary_frames)
img_folder = output_folder;
if strcmp(computer, 'GLNXA64')
imgFiles = dir([output_folder '/*.png']);
else
imgFiles = dir([output_folder '\*.png']);
end
numImages = length(imgFiles);
[~, video_name, ~] = fileparts(video_path);
frameRate = 5; % Frames per second
% ------- Yes courtship ------
disp('Creating yes_courtship.avi');
outputVideoFilename = [video_name '_' circle_num_to_arena_id_map(video_id) '_yes_courtship.avi']; % Name of the output video file
% Create a VideoWriter object
outputVideo = VideoWriter(outputVideoFilename);
outputVideo.FrameRate = frameRate;
open(outputVideo);
for k = 1:numImages
if mark_courtship(k) == 1
imgFilename = fullfile(img_folder,imgFiles(k).name);
img = imread(imgFilename);
writeVideo(outputVideo, img);
end
end
% Close the video file
close(outputVideo);
% ----------- No courtship ------------
disp('Creating no_courtship.avi');
outputVideoFilename = [video_name '_' circle_num_to_arena_id_map(video_id) '_no_courtship.avi']; % Name of the output video file
% Create a VideoWriter object
outputVideo = VideoWriter(outputVideoFilename);
outputVideo.FrameRate = frameRate;
open(outputVideo);
for k = 1:numImages
if mark_courtship(k) == 0
imgFilename = fullfile(img_folder,imgFiles(k).name);
img = imread(imgFilename);
writeVideo(outputVideo, img);
end
end
% Close the video file
close(outputVideo);
% ----------------- Yes, zero distance max ------------
disp('Creating yes_only_close_dist_criteria.avi');
outputVideoFilename = [video_name '_' circle_num_to_arena_id_map(video_id) '_stationary_courtship.avi']; % Name of the output video file
% Create a VideoWriter object
outputVideo = VideoWriter(outputVideoFilename);
outputVideo.FrameRate = frameRate;
open(outputVideo);
for k = 1:numImages
if mark_courtship_zero_dist_max(k) == 1
imgFilename = fullfile(img_folder,imgFiles(k).name);
img = imread(imgFilename);
writeVideo(outputVideo, img);
end
end
% Close the video file
close(outputVideo);
% ----------- stationary frames ------------
disp('Creating stationary.avi');
outputVideoFilename = [video_name '_' circle_num_to_arena_id_map(video_id) '_stationary.avi']; % Name of the output video file
% Create a VideoWriter object
outputVideo = VideoWriter(outputVideoFilename);
outputVideo.FrameRate = frameRate;
open(outputVideo);
for k = 1:numImages
if stationary_frames(k) == 1
imgFilename = fullfile(img_folder,imgFiles(k).name);
img = imread(imgFilename);
writeVideo(outputVideo, img);
end
end
% Close the video file
close(outputVideo);
end