-
Notifications
You must be signed in to change notification settings - Fork 0
/
runMouseSegmentation.m
59 lines (52 loc) · 2.33 KB
/
runMouseSegmentation.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
function [] = runMouseSegmentation(param)
% Segmentation code for mouse behavior experiments, this is the main
% framework of dealing with all three conditions
% SH Nov 2017
%% extract parameters
fileIndx = param.fileIndx;
% dpath = param.dpath;
infopath = param.spath.finfo;
savepath = param.spath.seg;
%% process files
for n = 1:size(fileIndx,1)
movieParam = getAviInfo(fileIndx(n,1));
% movieParam = getVidInfo(dpath{n},fileIndx(n,1));
objinfo_name = movieParam.fileName;
fprintf('processing %s...\n',movieParam.fileName);
if ~exist([savepath movieParam.fileName '_seg.mat'],'file')
obj_region = false([movieParam.imageSize 2]);
load([infopath movieParam.fileName '_info.mat']);
[segAll,theta,centroid,a,b] = trackOFMouse(movieParam,box_region,obj_region);
save([savepath movieParam.fileName '_seg.mat'],'segAll','theta',...
'centroid','a','b','-v7.3');
else
fprintf('segmentation file exists, skipping this file\n');
end
if ~isnan(fileIndx(n,2))
movieParam = getAviInfo(fileIndx(n,2));
fprintf('processing %s...\n',movieParam.fileName);
if ~exist([savepath movieParam.fileName '_seg.mat'],'file')
load([infopath objinfo_name '_info.mat']);
load([infopath movieParam.fileName '_info.mat']);
[segAll,theta,centroid,a,b] = trackOFMouse(movieParam,box_region,fam_obj_region);
save([savepath movieParam.fileName '_seg.mat'],'segAll','theta',...
'centroid','a','b','-v7.3');
else
fprintf('segmentation file exists, skipping this file\n');
end
end
if ~isnan(fileIndx(n,3))
movieParam = getAviInfo(fileIndx(n,3));
fprintf('processing %s...\n',movieParam.fileName);
if ~exist([savepath movieParam.fileName '_seg.mat'],'file')
load([infopath objinfo_name '_info.mat']);
load([infopath movieParam.fileName '_info.mat']);
[segAll,theta,centroid,a,b] = trackOFMouse(movieParam,box_region,nor_obj_region);
save([savepath movieParam.fileName '_seg.mat'],'segAll','theta',...
'centroid','a','b','-v7.3');
else
fprintf('segmentation file exists, skipping this file\n');
end
end
end
end