-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconvert_full_named_trees_as_mat_to_swc.m
27 lines (26 loc) · 1.24 KB
/
convert_full_named_trees_as_mat_to_swc.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
function convert_full_named_trees_as_mat_to_swc(trees_as_swc_folder_path, trees_as_mat_folder_path)
tic_id = tic() ;
if ~exist(trees_as_swc_folder_path, 'file') ,
mkdir(trees_as_swc_folder_path) ;
end
mat_file_names = simple_dir(fullfile(trees_as_mat_folder_path, 'auto*.mat')) ;
file_count = length(mat_file_names) ;
fprintf('Converting %d trees as .mat to .swc...\n', file_count) ;
pbo = progress_bar_object(file_count) ;
parfor i = 1 : file_count ,
mat_file_name = mat_file_names{i} ;
swc_base_name = base_name_from_file_name(mat_file_name) ;
swc_file_name = horzcat(swc_base_name, '.swc') ;
swc_file_path = fullfile(trees_as_swc_folder_path, swc_file_name) ;
if ~exist(swc_file_path, 'file') ,
mat_file_path = fullfile(trees_as_mat_folder_path, mat_file_name) ;
mat_contents = load('-mat', mat_file_path) ;
named_tree = mat_contents.named_tree ;
save_named_tree_as_swc(swc_file_path, named_tree) ;
end
pbo.update() ; %#ok<PFBNS>
end
%pbo = progress_bar_object(0) ;
elapsed_time = toc(tic_id) ;
fprintf('Elapsed time for convert_full_named_trees_as_mat_to_swc() was %g seconds\n', elapsed_time) ;
end