forked from erhanbas/navigator
-
Notifications
You must be signed in to change notification settings - Fork 1
/
label_machine_centerpoints.m
35 lines (33 loc) · 2.27 KB
/
label_machine_centerpoints.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
34
35
function consensus_neurons_with_machine_centerpoints_labelled = ...
label_machine_centerpoints(output_folder_path, ...
fragments_folder_path, ...
consensus_swcs_folder_path, ...
sample_folder_path)
all_fragment_centerpoints = compute_or_read_from_memo(output_folder_path, ...
'all_fragment_centerpoints', ...
@()(read_all_fragment_centerpoints(fragments_folder_path))) ;
consensus_neurons_and_names = compute_or_read_from_memo(output_folder_path, ...
'consensus_neurons', ...
@()(collect_consensus_neurons(consensus_swcs_folder_path))) ;
consensus_neurons = consensus_neurons_and_names.consensus_neurons ;
consensus_neuron_names = consensus_neurons_and_names.consensus_neuron_names ;
[~, spacing] = load_transform_txt(fullfile(sample_folder_path, 'transform.txt')) ;
consensus_neurons_with_machine_centerpoints_labelled = ...
compute_or_read_from_memo(output_folder_path, ...
'consensus_neurons_with_machine_centerpoints_labelled', ...
@()(label_machine_centerpoints_in_neurons(consensus_neurons, all_fragment_centerpoints, spacing))) ;
% Write the swc's that don't exist already
consensus_neuron_count = length(consensus_neurons) ;
swc_folder_path = fullfile(output_folder_path, 'as-swcs') ;
if consensus_neuron_count>0 && ~exist(swc_folder_path, 'file') ,
mkdir(swc_folder_path) ;
end
for i = 1:consensus_neuron_count ,
consensus_neuron_name = consensus_neuron_names{i} ;
swc_file_name = sprintf('%s.swc', consensus_neuron_name) ;
swc_file_path = fullfile(swc_folder_path, swc_file_name) ;
if ~exist(swc_file_path, 'file') ,
save_swc(swc_file_path, consensus_neurons_with_machine_centerpoints_labelled{i}, consensus_neuron_name) ;
end
end
end