Skip to content

Commit 82c21fc

Browse files
committed
Added a few functions
1 parent 615c41a commit 82c21fc

5 files changed

+57
-14
lines changed

Diff for: collect_landmarks.m

+1-14
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,7 @@
99
landmark_file_name = sprintf('%s-desc.%d.txt', leaf_folder_name, background_channel_index) ;
1010
landmark_file_path = fullfile(landmark_folder_path, tile_relative_path, landmark_file_name) ;
1111
if exist(landmark_file_path, 'file') ,
12-
landmark_data = load_tabular_data(landmark_file_path) ;
13-
if isempty(landmark_data) ,
14-
ijk0_from_landmark_index = zeros(0,3) ;
15-
else
16-
flipped_ijk0_from_landmark_index = landmark_data(:,1:3) ;
17-
% the landmark-detection code is run on the the raw (flipped in x and y) tiles,
18-
% so need to un-flip the landmarks
19-
ijk0_from_landmark_index = ...
20-
[ (tile_shape_ijk(1)-1) - flipped_ijk0_from_landmark_index(:,1) ...
21-
(tile_shape_ijk(2)-1) - flipped_ijk0_from_landmark_index(:,2) ...
22-
flipped_ijk0_from_landmark_index(:,3) ] ;
23-
end
24-
%foreground_p_value_from_landmark_index = landmark_data(:,4) ;
25-
%imagery_value_from_landmark_index = landmark_data(:,5) ;
12+
ijk0_from_landmark_index = load_landmark_file(landmark_file_path, tile_shape_ijk) ;
2613
else
2714
fprintf('Missing (?) landmark file for tile %s\n', tile_relative_path) ;
2815
ijk0_from_landmark_index = zeros(0,3) ;

Diff for: figure_mip.m

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
function [f, a] = figure_mip(stack_yxz)
2+
mip = max(stack_yxz, [], 3) ;
3+
4+
c_min = double(min(min(mip))) ;
5+
c_max = double(max(max(mip))) ;
6+
if c_min == c_max ,
7+
c_mean = c_min ;
8+
c_min = c_mean - 0.5 ;
9+
c_max = c_mean + 0.5 ;
10+
end
11+
12+
f = figure('color', 'w') ;
13+
a = axes(f) ;
14+
imagesc(a, mip, [c_min c_max]) ;
15+
axis(a,'image') ;
16+
colormap(parula(256)) ;
17+
colorbar;
18+
end

Diff for: file_relative_path_from_tile_relative_path.m

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
function result = file_relative_path_from_tile_relative_path(relative_path, channel_index, label, extension)
2+
% E.g. '2020-12-01/01/01916' -> '2020-12-01/01/01916/01916-ngc.0.tif'
3+
if ~exist('label', 'var') || isempty(label) ,
4+
extension = 'ngc' ;
5+
end
6+
if ~exist('extension', 'var') || isempty(extension) ,
7+
extension = '.tif' ;
8+
end
9+
[~, leaf_folder_name] = fileparts2(relative_path) ;
10+
imagery_file_name = sprintf('%s-%s.%d%s', leaf_folder_name, label, channel_index, extension) ;
11+
result = fullfile(relative_path, imagery_file_name) ;
12+
end

Diff for: load_landmark_file.m

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
function [ijk0_from_landmark_index, foreground_p_value_from_landmark_index, imagery_value_from_landmark_index] =...
2+
load_landmark_file(landmark_file_name, tile_shape_ijk)
3+
landmark_data = load_tabular_data(landmark_file_name) ;
4+
if isempty(landmark_data) ,
5+
ijk0_from_landmark_index = zeros(0,3) ;
6+
else
7+
flipped_ijk0_from_landmark_index = landmark_data(:,1:3) ;
8+
% the landmark-detection code is run on the the raw (flipped in x and y) tiles,
9+
% so need to un-flip the landmarks
10+
ijk0_from_landmark_index = ...
11+
[ (tile_shape_ijk(1)-1) - flipped_ijk0_from_landmark_index(:,1) ...
12+
(tile_shape_ijk(2)-1) - flipped_ijk0_from_landmark_index(:,2) ...
13+
flipped_ijk0_from_landmark_index(:,3) ] ;
14+
end
15+
foreground_p_value_from_landmark_index = landmark_data(:,4) ;
16+
imagery_value_from_landmark_index = landmark_data(:,5) ;
17+
end

Diff for: p_map_file_relative_path_from_relative_path.m

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
function result = p_map_file_relative_path_from_relative_path(relative_path, channel_index, extension)
2+
% E.g. '2020-12-01/01/01916' -> '2020-12-01/01/01916/01916-ngc.0.tif'
3+
if ~exist('extension', 'var') || isempty(extension) ,
4+
extension = '.h5' ;
5+
end
6+
[~, leaf_folder_name] = fileparts2(relative_path) ;
7+
imagery_file_name = sprintf('%s-prob.%d%s', leaf_folder_name, channel_index, extension) ;
8+
result = fullfile(relative_path, imagery_file_name) ;
9+
end

0 commit comments

Comments
 (0)