-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextractPerframeFtrs.m
37 lines (34 loc) · 1.01 KB
/
extractPerframeFtrs.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
function extractPerframeFtrs(outdir,ftrs,stationary,flowname)
if ~exist(outdir,'dir'),
mkdir( outdir);
end
ff = fields(ftrs);
% Initialize the struct for features of all the frames
for fnum = 1:numel(ff)
curf = ff{fnum};
if strcmp(curf,'hogftrs') ,
pfname = 'hf';
elseif strcmp(curf,'flowftrs') && stationary,
pfname = [flowname 's'];
elseif strcmp(curf,'flowftrs') && ~stationary,
pfname = flowname;
else
error('Unknown feature type');
end
for yy = 1:size(ftrs.(curf){1},1)
for xx = 1:size(ftrs.(curf){1},2)
for oo = 1:size(ftrs.(curf){1},3)
perframe = struct;
perframe.units.num = {};
perframe.units.den = {'s'};
for fly = 1:numel(ftrs.(ff{fnum}))
tt = ftrs.(ff{fnum}){fly}(yy,xx,oo,:);
perframe.data{fly} = tt(:);
end
perframe_name = sprintf('%s_%02d_%02d_%d',pfname,yy,xx,oo);
outfilename = fullfile(outdir,perframe_name);
save(outfilename,'-struct','perframe','-v7.3');
end
end
end
end