-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathOCY_run_Skel2Graph3D.m
43 lines (32 loc) · 1.13 KB
/
OCY_run_Skel2Graph3D.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
36
37
38
39
40
41
42
43
function [A,node,link,skel] = OCY_run_Skel2Graph3D(skel,cells,THR_BRANCH)
% OCY_filter_nodes - clean up graph structure to match voxel skeleton
%
% [node,link,cell] = OCY_filter_nodes(node,link,cell,cells)
%
% [node,link,cell] = OCY_filter_nodes(node,link,cell,cells,THR)
%
% All branches shorter than THR are removed.
if (nargin==1)
THR_BRANCH = 0;
end;
% dimensions of stack
w = size(skel,1);
l = size(skel,2);
h = size(skel,3);
[~,node,link] = Skel2Graph3D(skel,THR_BRANCH);
% total length of network
wl = sum(cellfun('length',{node.links}));
% initial step: condense, convert to voxels and back
skel = Graph2Skel3D(node,link,w,l,h);
skel = Skeleton3D(skel,cells);
[A,node,link] = Skel2Graph3D(skel,THR_BRANCH);
% calculate new total length of network
wl_new = sum(cellfun('length',{node.links}));
% iterate the same steps until network length changed by less than 0.5%
while(wl_new~=wl)
wl = wl_new;
skel = Graph2Skel3D(node,link,w,l,h);
skel = Skeleton3D(skel,cells);
[A,node,link] = Skel2Graph3D(skel,THR_BRANCH);
wl_new = sum(cellfun('length',{node.links}));
end;