-
Notifications
You must be signed in to change notification settings - Fork 43
Open
Labels
Description
... And which side of the loop is chosen depends on whether the SciPy version used is 1.10 or earlier or 1.11 or later. 😕
Here's a reproducible example:
import napari
import numpy as np
from skimage.draw import random_shapes
from skimage.morphology import skeletonize
from skan import Skeleton, summarize
# Generate a random skeletons, first is a skeleton with a closed loop with side branches
kwargs = {"image_shape": (128, 128),
"max_shapes": 20,
"channel_axis": None,
"shape": None,
"rng": 1,
"allow_overlap": True,
"min_size": 20}
kwargs["rng"] = 13588686514
kwargs["min_size"] = 20
random_images, _ = random_shapes(**kwargs)
mask = np.where(random_images != 255, 1, 0)
skeleton_linear1 = skeletonize(mask)
viewer = napari.Viewer()
layer = viewer.add_labels(skeleton_linear1)
skeleton = Skeleton(skeleton_linear1)
all_paths = [skeleton.path_coordinates(i) for i in range(skeleton.n_paths)]
paths_table = summarize(skeleton, separator='_')
paths_table.reset_index(inplace=True, names='branch-id')
shp_layer = viewer.add_shapes(
all_paths,
shape_type='path',
features=paths_table,
metadata={'skeleton': skeleton},
)
shp_layer.edge_color = 'branch-id'
shp_layer.edge_color_cycle = [
'red', 'green', 'blue', 'cyan', 'magenta', 'yellow'
]
napari.run()This is the output on SciPy 1.10:
The same code with SciPy 1.11 produces:
Both are wrong (both loops should be completely closed).
Reactions are currently unavailable