diff --git a/docs/index.html b/docs/index.html index f55e9de..7df4478 100644 --- a/docs/index.html +++ b/docs/index.html @@ -689,8 +689,8 @@

Top-level functions and classes

256 257""" 258 -259__version__ = "1.2.2" -260__version_vector__ = (1, 2, 2) +259__version__ = "1.2.3" +260__version_vector__ = (1, 2, 3) 261 262from . import skeletonize 263from . import pre diff --git a/docs/skeletor.html b/docs/skeletor.html index f55e9de..7df4478 100644 --- a/docs/skeletor.html +++ b/docs/skeletor.html @@ -689,8 +689,8 @@

Top-level functions and classes

256 257""" 258 -259__version__ = "1.2.2" -260__version_vector__ = (1, 2, 2) +259__version__ = "1.2.3" +260__version_vector__ = (1, 2, 3) 261 262from . import skeletonize 263from . import pre diff --git a/docs/skeletor/skeletonize.html b/docs/skeletor/skeletonize.html index 0bdb74e..e074333 100644 --- a/docs/skeletor/skeletonize.html +++ b/docs/skeletor/skeletonize.html @@ -327,64 +327,68 @@

References

131 weights='weight', mode='ALL')[0] 132 133 # Get IDs of edges along the path -134 eids = SG.get_eids(path=path, directed=False) -135 -136 # Stop if farthest point is closer than min_length -137 add = True -138 if min_length: -139 # This should only be distance to the first branchpoint -140 # from the tip since we set other weights to zero -141 le = sum(SG.es[eids].get_attribute_values('weight')) -142 if le < min_length: -143 add = False -144 -145 if add: -146 # Add these new edges -147 new_edges = np.vstack((cc[path[:-1]], cc[path[1:]])).T -148 edges = np.append(edges, new_edges).reshape(-1, 2) -149 -150 # Invalidate points in the path -151 valid[path] = False -152 paths[path] = 0 +134 if getattr(ig, '__version_info__', (0, 0, 0))[1] >= 10: +135 pairs = zip(path[:-1], path[1:]) +136 eids = SG.get_eids(pairs, directed=False) +137 else: +138 eids = SG.get_eids(path=path, directed=False) +139 +140 # Stop if farthest point is closer than min_length +141 add = True +142 if min_length: +143 # This should only be distance to the first branchpoint +144 # from the tip since we set other weights to zero +145 le = sum(SG.es[eids].get_attribute_values('weight')) +146 if le < min_length: +147 add = False +148 +149 if add: +150 # Add these new edges +151 new_edges = np.vstack((cc[path[:-1]], cc[path[1:]])).T +152 edges = np.append(edges, new_edges).reshape(-1, 2) 153 -154 # Must set weights along path to 0 so that this path is -155 # taken again in future iterations -156 SG.es[eids]['weight'] = 0 +154 # Invalidate points in the path +155 valid[path] = False +156 paths[path] = 0 157 -158 # Get all nodes within `inv_dist` to this path -159 # Note: can we somehow only include still valid nodes to speed -160 # things up? -161 dist, _, sources = dijkstra(sp, directed=False, indices=path, -162 limit=inv_dist, min_only=True, -163 return_predecessors=True) -164 -165 # Invalidate -166 in_dist = dist <= inv_dist -167 to_invalidate = np.where(in_dist)[0] -168 valid[to_invalidate] = False -169 paths[to_invalidate] = 0 -170 -171 # Update mesh vertex to skeleton node map -172 mesh_map[cc[in_dist]] = cc[sources[in_dist]] -173 -174 pbar.update((~valid).sum() - invalidated) -175 invalidated = (~valid).sum() -176 -177 # Make unique edges (paths will have overlapped!) -178 edges = unique(edges, axis=0) -179 -180 # Create a directed acyclic and hierarchical graph -181 G_nx = edges_to_graph(edges=edges[:, [1, 0]], -182 fix_tree=True, fix_edges=False, -183 weight=False) -184 -185 # Generate the SWC table -186 swc, new_ids = make_swc(G_nx, coords=mesh.vertices, reindex=True) -187 -188 # Update vertex to node ID map -189 mesh_map = np.array([new_ids.get(n, -1) for n in mesh_map]) -190 -191 return Skeleton(swc=swc, mesh=mesh, mesh_map=mesh_map, method='teasar') +158 # Must set weights along path to 0 so that this path is +159 # taken again in future iterations +160 SG.es[eids]['weight'] = 0 +161 +162 # Get all nodes within `inv_dist` to this path +163 # Note: can we somehow only include still valid nodes to speed +164 # things up? +165 dist, _, sources = dijkstra(sp, directed=False, indices=path, +166 limit=inv_dist, min_only=True, +167 return_predecessors=True) +168 +169 # Invalidate +170 in_dist = dist <= inv_dist +171 to_invalidate = np.where(in_dist)[0] +172 valid[to_invalidate] = False +173 paths[to_invalidate] = 0 +174 +175 # Update mesh vertex to skeleton node map +176 mesh_map[cc[in_dist]] = cc[sources[in_dist]] +177 +178 pbar.update((~valid).sum() - invalidated) +179 invalidated = (~valid).sum() +180 +181 # Make unique edges (paths will have overlapped!) +182 edges = unique(edges, axis=0) +183 +184 # Create a directed acyclic and hierarchical graph +185 G_nx = edges_to_graph(edges=edges[:, [1, 0]], +186 fix_tree=True, fix_edges=False, +187 weight=False) +188 +189 # Generate the SWC table +190 swc, new_ids = make_swc(G_nx, coords=mesh.vertices, reindex=True) +191 +192 # Update vertex to node ID map +193 mesh_map = np.array([new_ids.get(n, -1) for n in mesh_map]) +194 +195 return Skeleton(swc=swc, mesh=mesh, mesh_map=mesh_map, method='teasar')