Skip to content

Commit c8414c6

Browse files
committed
Added code for doing line-shifting in-place
1 parent 3945e2f commit c8414c6

40 files changed

+607
-140
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ parfor_progress.txt
88
*.stdouterr
99
foreground-classifiers/data/
1010
foreground-classifiers/2021-03-17/
11+
RESTORED/
1112

build_tile_index_dirwalk_callback.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
[~,file_base_name] = fileparts2(current_folder_relative_path) ;
1414
acquisition_file_name = [file_base_name '-ngc.acquisition'] ;
1515
acquisition_file_path = fullfile(root_folder_absolute_path, current_folder_relative_path, acquisition_file_name) ;
16-
if exist(acquisition_file_path, 'file') ,
16+
if ismember(acquisition_file_name, file_names) ,
17+
%if exist(acquisition_file_path, 'file') , % don't hit the FS again
1718
[ijk1, xyz] = read_lattice_position_from_acquisition_file(acquisition_file_path) ;
1819
updated_state = struct() ;
1920
updated_state.ijk1_from_tile_index = [state.ijk1_from_tile_index ; ijk1] ;
File renamed without changes.
File renamed without changes.

copy_raw_tile_neighborhood.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,19 @@ function copy_raw_tile_neighborhood(hood_raw_tile_root_folder_path, ...
2727
center_tile_relative_path) ; %#ok<ASGLU>
2828
tile_count = length(relative_path_from_tile_index) ;
2929

30-
% For each relative path, make a link
30+
% For each relative path, make a copy
3131
for tile_index = 1 : tile_count ,
3232
tile_relative_path = relative_path_from_tile_index{tile_index} ;
3333
destination_path = fullfile(hood_raw_tile_root_folder_path, tile_relative_path) ;
3434
source_path = fullfile(raw_tile_root_folder_path, tile_relative_path) ;
3535
destination_parent_path = fileparts(destination_path) ;
3636
ensure_folder_exists(destination_parent_path) ;
37-
system_from_list_with_error_handling({'ln', '-s', '-T', source_path, destination_path}) ;
37+
system_from_list_with_error_handling({'cp', '-R', '-T', source_path, destination_path}) ;
3838
end
3939

40-
% Make links for the metadata, etc
40+
% Make copies for the metadata, etc
4141
file_name = 'sample-metadata.txt' ;
4242
source_path = fullfile(raw_tile_root_folder_path, file_name) ;
4343
destination_path = fullfile(hood_raw_tile_root_folder_path, file_name) ;
44-
system_from_list_with_error_handling({'ln', '-s', '-T', source_path, destination_path}) ;
44+
system_from_list_with_error_handling({'cp', '-T', source_path, destination_path}) ;
4545
end

copy_raw_tile_neighborhood_as_links.m

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
function copy_raw_tile_neighborhood_as_links(hood_raw_tile_root_folder_path, ...
2+
raw_tile_root_folder_path, ...
3+
center_tile_relative_path, ...
4+
sample_memo_folder_path, ...
5+
do_force_computation)
6+
% Build the full tile index
7+
raw_tile_index = compute_or_read_from_memo(sample_memo_folder_path, ...
8+
'raw-tile-index', ...
9+
@()(build_raw_tile_index(raw_tile_root_folder_path)), ...
10+
do_force_computation) ;
11+
full_tile_index_from_full_tile_ijk1 = raw_tile_index.tile_index_from_tile_ijk1 ;
12+
full_tile_ijk1_from_full_tile_index = raw_tile_index.ijk1_from_tile_index ;
13+
xyz_from_full_tile_index = raw_tile_index.xyz_from_tile_index ;
14+
relative_path_from_full_tile_index = raw_tile_index.relative_path_from_tile_index ;
15+
%full_tile_grid_shape = size(full_tile_index_from_full_tile_ijk1)
16+
%full_tile_count = length(relative_path_from_full_tile_index)
17+
18+
% Get out just the tiles around the center_tile
19+
[tile_index_from_tile_ijk1, ...
20+
tile_ijk1_from_tile_index, ...
21+
xyz_from_tile_index, ...
22+
relative_path_from_tile_index] = ...
23+
extract_tiles_near_tile(full_tile_index_from_full_tile_ijk1, ...
24+
full_tile_ijk1_from_full_tile_index, ...
25+
xyz_from_full_tile_index, ...
26+
relative_path_from_full_tile_index, ...
27+
center_tile_relative_path) ; %#ok<ASGLU>
28+
tile_count = length(relative_path_from_tile_index) ;
29+
30+
% For each relative path, make a link
31+
for tile_index = 1 : tile_count ,
32+
tile_relative_path = relative_path_from_tile_index{tile_index} ;
33+
destination_path = fullfile(hood_raw_tile_root_folder_path, tile_relative_path) ;
34+
source_path = fullfile(raw_tile_root_folder_path, tile_relative_path) ;
35+
destination_parent_path = fileparts(destination_path) ;
36+
ensure_folder_exists(destination_parent_path) ;
37+
system_from_list_with_error_handling({'ln', '-s', '-T', source_path, destination_path}) ;
38+
end
39+
40+
% Make links for the metadata, etc
41+
file_name = 'sample-metadata.txt' ;
42+
source_path = fullfile(raw_tile_root_folder_path, file_name) ;
43+
destination_path = fullfile(hood_raw_tile_root_folder_path, file_name) ;
44+
system_from_list_with_error_handling({'ln', '-s', '-T', source_path, destination_path}) ;
45+
end

get_tile_flip_state.m

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
function flip_metadata = get_tile_flip_state(tile_path, sample_metadata)
2+
if sample_metadata.sample_metadata_version<=1 ,
3+
flip_metadata = struct() ;
4+
flip_metadata.is_x_flipped = sample_metadata.is_x_flipped ;
5+
flip_metadata.is_y_flipped = sample_metadata.is_y_flipped ;
6+
elseif sample_metadata.sample_metadata_version==2 ,
7+
xlineshift_file_path = fullfile(tile_path, 'Xlineshift.txt') ;
8+
if exist(xlineshift_file_path, 'file') ,
9+
% Tile is already line-shifted, which means it's also flipped on both axes
10+
flip_metadata = struct() ;
11+
flip_metadata.is_x_flipped = true ;
12+
flip_metadata.is_y_flipped = true ;
13+
else
14+
% Tile has not been line-shifted, so use the value from the sample metadata
15+
flip_metadata = struct() ;
16+
flip_metadata.is_x_flipped = sample_metadata.is_x_flipped ;
17+
flip_metadata.is_y_flipped = sample_metadata.is_y_flipped ;
18+
end
19+
else
20+
tile_metadata = read_tile_metadata(tile_path) ;
21+
flip_metadata = struct() ;
22+
flip_metadata.is_x_flipped = tile_metadata.is_x_flipped ;
23+
flip_metadata.is_y_flipped = tile_metadata.is_y_flipped ;
24+
end
25+
end
26+

0 commit comments

Comments
 (0)