forked from MouseLightPipeline/skeletonize
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsave_skeleton_graph_as_binary.m
More file actions
23 lines (23 loc) · 1.13 KB
/
save_skeleton_graph_as_binary.m
File metadata and controls
23 lines (23 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
function save_skeleton_graph_as_binary(file_name, skeleton_ijks, neighbors_from_node_index)
fid = fopen(file_name, 'w') ;
if fid<0 ,
error('Unable to open file %s for writing', file_name) ;
end
cleaner = onCleanup(@()(fclose(fid))) ;
%neighbors_from_node_index = neighbors_from_node_index_from_adjacency(A) ;
node_count = size(skeleton_ijks, 1) ;
for node_index = 1 : node_count ,
ijk = skeleton_ijks(node_index,:) ;
%neighbor_node_indices = skeleton_graph.neighbors(node_index)' ; % want as row vector
%neighbor_node_indices_check = find(A(node_index,:)) ;
neighbor_node_indices = neighbors_from_node_index{node_index} ;
%assert(isempty(setdiff(neighbor_node_indices_check, neighbor_node_indices))) ;
degree = length(neighbor_node_indices) ;
numbers_to_print = horzcat(node_index, ijk, degree, neighbor_node_indices) ;
numbers_to_print_as_uint64 = uint64(numbers_to_print) ;
fwrite(fid, numbers_to_print_as_uint64, 'uint64') ;
%fprintf(fid, '%d ',numbers_to_print) ;
%fprintf(fid, '\n') ;
end
% fclose() handled by cleaner
end