forked from MouseLightPipeline/pipeline-featmatch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
compute_stuff_from_pair_index.m
33 lines (32 loc) · 2.02 KB
/
compute_stuff_from_pair_index.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
function result = compute_stuff_from_pair_index(sample_date, random_pair_count, xyz_from_tile_index, raw_tile_map, relative_path_from_tile_index)
raw_tile_map_shape = size(raw_tile_map) ;
tile_count = length(relative_path_from_tile_index) ;
random_pair_done_count = 0 ;
rng(0) ; % seed the RNG to get a repeatable sequence of random ints
match_count_from_pair_index = zeros(random_pair_count, 1) ;
center_tile_xyz_from_pair_index = zeros(random_pair_count, 3) ;
center_tile_relative_path_from_pair_index = cell(random_pair_count, 1) ;
while random_pair_done_count < random_pair_count ,
center_tile_index = randi(tile_count, 1) ;
center_xyz = xyz_from_tile_index(center_tile_index, :) ;
other_xyz = center_xyz + [0 0 1] ;
if all(other_xyz <= raw_tile_map_shape) ,
other_tile_relative_path = raw_tile_map{other_xyz(1), other_xyz(2), other_xyz(3)} ;
if ~isempty(other_tile_relative_path) ,
center_tile_relative_path = relative_path_from_tile_index{center_tile_index} ;
match_count = ...
compute_pointmatch_on_single_pair_in_live_sample(sample_date, center_tile_relative_path, other_tile_relative_path) ;
random_pair_done_count = random_pair_done_count + 1 ;
% Store things for the just-done pair
random_pair_index = random_pair_done_count ;
match_count_from_pair_index(random_pair_index) = match_count ;
center_tile_xyz_from_pair_index(random_pair_index,:) = center_xyz ;
center_tile_relative_path_from_pair_index{random_pair_index} = center_tile_relative_path ;
end
end
end
% Package into a single result
result = struct('match_count_from_pair_index', {match_count_from_pair_index}, ...
'center_tile_xyz_from_pair_index', {center_tile_xyz_from_pair_index}, ...
'center_tile_relative_path_from_pair_index', {center_tile_relative_path_from_pair_index}) ;
end