Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if root is None:
return PrecomputedSkeleton()
# DBF: Distance to Boundary Field
# DAF: Distance from any voxel Field (distance from root field)
# PDRF: Penalized Distance from Root Field
DBF = kimimaro.skeletontricks.zero2inf(DBF) # DBF[ DBF == 0 ] = np.inf
DAF = dijkstra3d.euclidean_distance_field(labels, root, anisotropy=anisotropy)
DAF = kimimaro.skeletontricks.inf2zero(DAF) # DAF[ DAF == np.inf ] = 0
PDRF = compute_pdrf(dbf_max, pdrf_scale, pdrf_exponent, DBF, DAF)
# Use dijkstra propogation w/o a target to generate a field of
# pointers from each voxel to its parent. Then we can rapidly
# compute multiple paths by simply hopping pointers using path_from_parents
if not fix_branching:
parents = dijkstra3d.parental_field(PDRF, root)
del PDRF
else:
parents = PDRF
if soma_mode:
invalidated, labels = kimimaro.skeletontricks.roll_invalidation_ball(
labels, DBF, np.array([root], dtype=np.uint32),
scale=soma_invalidation_scale,
const=soma_invalidation_const,
anisotropy=anisotropy
)
paths = compute_paths(
root, labels, DBF, DAF,
parents, scale, const, anisotropy,
soma_mode, soma_radius, fix_branching,