-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_dxnnp1_list.m
executable file
·43 lines (31 loc) · 1.53 KB
/
get_dxnnp1_list.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
function [ dnnp1_list ] = get_dxnnp1_list (state_matrices_allti, trackdat_xyl, Nframes, S)
% collect autocorrelation in positional change between two adjacent frames
Num_comp_tracks = length( trackdat_xyl );
dxnnp1_list = [];
dynnp1_list = [];
% ---------------------------------
for ti = 1:Num_comp_tracks
% get mask for frames where the track was in the right state in that
% frame AND the subsequent one, AND the one after that:
mask = create_mask( state_matrices_allti{ti}, Nframes, S, 2 );
if( size(mask,2) ~= Nframes - 2 || size(mask,1) ~= size( trackdat_xyl(ti).dx, 1) )
disp("ERROR: mismatched frame length in get_dnnp1_list" )
return
end
dxnnp1_mat = mask .*( trackdat_xyl(ti).dx(:,1:Nframes-2) .* trackdat_xyl(ti).dx(:,2:Nframes-1) );
dynnp1_mat = mask .*( trackdat_xyl(ti).dy(:,1:Nframes-2) .* trackdat_xyl(ti).dy(:,2:Nframes-1) );
dxnnp1_vec = dxnnp1_mat(mask == 1);
dynnp1_vec = dynnp1_mat(mask == 1);
% if there's only a single subtrack, then the array gets returned with a different orientation.
% Make sure it's a horizonal array:
if( size(dxnnp1_vec,1) ~=1 )
dxnnp1_vec = transpose( dxnnp1_vec );
dynnp1_vec = transpose( dynnp1_vec );
end
dxnnp1_list = [ dxnnp1_list , dxnnp1_vec ];
dynnp1_list = [ dynnp1_list , dynnp1_vec ];
end
dnnp1_list = ( dxnnp1_list + dynnp1_list )/2;
% if there is any mismatched dimension between x and y,
% then there is a larger-scale problem that we want flagged.
end