Skip to content

Commit ed0fe1f

Browse files
committed
Folded in http://github.com/MouseLightProject/freezing repo as of commit 6f0a07bc, dated 2023-05-24
1 parent 4b19a21 commit ed0fe1f

File tree

59 files changed

+1289
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1289
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,6 @@ parfor_progress.txt
99
foreground-classifiers/data/
1010
foreground-classifiers/2021-03-17/
1111
RESTORED/
12+
freezing/octree*test*folder
13+
freezing/raw-tiles*test*folder
1214

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
function result = are_files_same_size_and_md5sum(file_name_1, file_name_2)
2+
file_size_1 = get_file_size(file_name_1) ;
3+
file_size_2 = get_file_size(file_name_2) ;
4+
if file_size_1 ~= file_size_2 ,
5+
result = false ;
6+
return
7+
end
8+
result = are_md5s_the_same(file_name_1, file_name_2) ;
9+
end
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
function batch_convert_all_mj2_files_to_tif(output_folder_name, ...
2+
input_folder_name, ...
3+
do_submit, ...
4+
do_try, ...
5+
maximum_running_slot_count, ...
6+
submit_host_name)
7+
% Find all .mj2 files in folders with no subfolders, convert them to .tif
8+
9+
slots_per_job = 1 ;
10+
bsub_options = '-P mouselight -W 59 -J thaw' ;
11+
find_and_batch(input_folder_name, ...
12+
@is_a_mj2_and_target_missing, ...
13+
@tif_from_mj2_single_for_find_and_batch, ...
14+
'do_submit', do_submit, ...
15+
'do_try', do_try, ...
16+
'submit_host_name', submit_host_name, ...
17+
'maximum_running_slot_count', maximum_running_slot_count, ...
18+
'slots_per_job', slots_per_job, ...
19+
'bsub_options', bsub_options, ...
20+
'predicate_extra_args', {input_folder_name, output_folder_name}, ...
21+
'batch_function_extra_args', {input_folder_name, output_folder_name}) ;
22+
end
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
function batch_convert_all_tif_files_to_mj2(mj2_folder_name, ...
2+
tif_folder_name, ...
3+
compression_ratio, ...
4+
do_submit, ...
5+
do_try, ...
6+
maximum_running_slot_count, ...
7+
submit_host_name)
8+
% Find all .tif files in folder tree, convert them to .mj2
9+
10+
slots_per_job = 1 ;
11+
bsub_options = '-P mouselight -W 59 -J freeze' ;
12+
find_and_batch(tif_folder_name, ...
13+
@does_file_name_end_in_dot_tif_and_mj2_is_missing, ...
14+
@mj2_from_tif_single_for_find_and_batch, ...
15+
'do_submit', do_submit, ...
16+
'do_try', do_try, ...
17+
'submit_host_name', submit_host_name, ...
18+
'maximum_running_slot_count', maximum_running_slot_count, ...
19+
'slots_per_job', slots_per_job, ...
20+
'bsub_options', bsub_options, ...
21+
'predicate_extra_args', {tif_folder_name, mj2_folder_name}, ...
22+
'batch_function_extra_args', {tif_folder_name, mj2_folder_name, compression_ratio}) ;
23+
end
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
function batch_preverify_stack_files_after_freezing(mj2_folder_name, ...
2+
tif_folder_name, ...
3+
do_submit, ...
4+
do_try, ...
5+
submit_host_name, ...
6+
maximum_running_slot_count)
7+
% Makes sure all the big target files are present in the the destination, and
8+
% are similar to their source files.
9+
10+
slots_per_job = 4 ;
11+
bsub_options = '-P mouselight -W 59 -J verify-frozen' ;
12+
find_and_batch(tif_folder_name, ...
13+
@does_need_preverification_after_freezing, ...
14+
@verify_single_mj2_file_after_freezing, ...
15+
'do_submit', do_submit, ...
16+
'do_try', do_try, ...
17+
'submit_host_name', submit_host_name, ...
18+
'maximum_running_slot_count', maximum_running_slot_count, ...
19+
'slots_per_job', slots_per_job, ...
20+
'bsub_options', bsub_options, ...
21+
'predicate_extra_args', {tif_folder_name, mj2_folder_name}, ...
22+
'batch_function_extra_args', {tif_folder_name, mj2_folder_name}) ;
23+
end
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
function batch_verify_tif_files_after_thawing(output_folder_name, ...
2+
input_folder_name, ...
3+
do_submit, ...
4+
do_try, ...
5+
submit_host_name, ...
6+
maximum_running_slot_count)
7+
% Makes sure all the leaf image files are present in the the destination, and
8+
% are similar to their source files.
9+
10+
slots_per_job = 4 ;
11+
bsub_options = '-P mouselight -W 59 -J verify-thawed-stack' ;
12+
find_and_batch(input_folder_name, ...
13+
@is_mj2_and_lacks_cert_for_output, ...
14+
@verify_single_tif_file_after_thawing, ...
15+
'do_submit', do_submit, ...
16+
'do_try', do_try, ...
17+
'submit_host_name', submit_host_name, ...
18+
'maximum_running_slot_count', maximum_running_slot_count, ...
19+
'slots_per_job', slots_per_job, ...
20+
'bsub_options', bsub_options, ...
21+
'predicate_extra_args', {input_folder_name, output_folder_name}, ...
22+
'batch_function_extra_args', {input_folder_name, output_folder_name}) ;
23+
end
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
function check_certs_after_verifying_freezing(tif_root_folder_path, mj2_root_folder_path)
2+
% Makes sure there's a .similar-mj2-exists for each .tif file in
3+
% tif_root_folder_path.
4+
5+
function result = verify_single_tif_file_after_mj2_from_tif_wrapper(tif_root_folder_path, tif_folder_relative_path, tif_file_name, depth) %#ok<INUSD>
6+
result = verify_single_tif_file_after_mj2_from_tif(tif_root_folder_path, tif_folder_relative_path, tif_file_name, mj2_root_folder_path) ;
7+
end
8+
9+
find_and_verify(...
10+
tif_root_folder_path, ...
11+
@does_file_name_end_in_dot_tif, ...
12+
@verify_single_tif_file_after_mj2_from_tif_wrapper, ...
13+
@is_not_the_ktx_folder) ;
14+
end
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
function check_certs_after_verifying_thawing(input_root_folder_path, output_root_folder_path)
2+
% Makes sure there's a .similar-tif-exists for each .mj2 file in
3+
% input_root_folder_path.
4+
5+
function result = check_single_cert_after_verifying_thawing_wrapper(root_folder_path, base_folder_relative_path, file_name, depth) %#ok<INUSD>
6+
result = check_single_cert_after_verifying_thawing(root_folder_path, base_folder_relative_path, file_name, output_root_folder_path) ;
7+
end
8+
9+
find_and_verify(...
10+
input_root_folder_path, ...
11+
@does_file_name_end_in_dot_mj2, ...
12+
@check_single_cert_after_verifying_thawing_wrapper, ...
13+
@(varargin)(true)) ;
14+
end
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
function result = check_single_cert_after_verifying_thawing(...
2+
input_root_folder_path, input_folder_relative_path, input_file_name, output_root_folder_path) %#ok<INUSD>
3+
output_file_name = replace_extension(input_file_name, '.tif') ;
4+
output_file_path = fullfile(output_root_folder_path, input_folder_relative_path, output_file_name) ;
5+
cert_file_path = horzcat(output_file_path, '.is-similar-to-mj2') ;
6+
result = logical( exist(cert_file_path, 'file') ) ;
7+
end
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
function copy_file_for_find_and_batch(tif_side_file_path, tif_root_folder_name, mj2_root_folder_name, varargin)
2+
relative_file_path_of_tif_side_file = relpath(tif_side_file_path, tif_root_folder_name) ;
3+
relative_file_path_of_mj2_side_file = relative_file_path_of_tif_side_file ;
4+
mj2_side_file_path = fullfile(mj2_root_folder_name, relative_file_path_of_mj2_side_file) ;
5+
mj2_side_folder_path = fileparts2(mj2_side_file_path) ;
6+
ensure_folder_exists(mj2_side_folder_path) ;
7+
copyfile(tif_side_file_path, mj2_side_file_path) ;
8+
end

0 commit comments

Comments
 (0)