-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWeathervane.m
46 lines (40 loc) · 1.61 KB
/
Weathervane.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
function weathervane = Weathervane(track, movie_features)
% Compute the weathervane stats of a track. Per Iino, this is the change in
% bearing between the bearing of a local velocity vector and the bearing to
% the point 1 mm "into the future".
% The output is an Nx4 matrix, where the columns are:
% 1 - the bearing of the local velocity vector.
% 2 - the change in bearing, as defined above.
% 3 - the frame of the velocity vector.
% 4 - the distance between the origin of the velocity vector and the
% center of the odorant.
segmented_track = SegmentTrackPath(track, movie_features.fps);
long_run = bitand(segmented_track, SegmentMasks.LongRun) == SegmentMasks.LongRun;
[long_run_segments, num_of_long_runs] = SegmentVector(long_run);
drop_center = movie_features.drop{1};
fp = track.filteredPath(:,2:3);
weathervane = [];
for segment_ix = 1:num_of_long_runs
if ~long_run_segments(segment_ix,3)
continue
end
start_ix = long_run_segments(segment_ix,1);
stop_ix = long_run_segments(segment_ix,2);
for ix = start_ix:stop_ix-1
curr_point = fp(ix,:);
% Look ahead to 1 mm
for next_ix = ix+1:stop_ix
next_point = fp(next_ix,:);
if Dist(curr_point, next_point) > movie_features.pixels_per_mm
weathervane(end+1,:) = [ ...
track.bearings(ix) ...
GetAngle(track.velocityVectors(ix,:), next_point - curr_point) ...
track.filteredPath(ix,1) ...
Dist(curr_point, drop_center) ...
];
break
end
end
end
end
end