-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add napari plugin with skeletonize widget #184
Conversation
@jni This does not work for because of an strange error regarding label dimensionality. Strange because it says it expects a 2d or 3d layer but it has certainly been passed a 2d layer. import numpy as np
from skimage.morphology import skeletonize
img = np.zeros(shape=(100, 100), dtype=np.uint8)
img[0:10, 0:10] = 1
skeletonize(img, method='zhang') |
src/napari_skan/napari_skan.py
Outdated
|
||
def skeletonize_labels(labels: "napari.types.LabelsData", method: SkeletonizeMethod) -> "napari.types.LabelsData": | ||
binary_labels = (labels > 0).astype(np.uint8) | ||
skeletonized = skeletonize(binary_labels, method=method) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jamesyan-git yeah this was super tricky and confusing! But I finally cracked it! 😅
skeletonized = skeletonize(binary_labels, method=method) | |
skeletonized = skeletonize(binary_labels, method=method.value) |
What's happening is that skimage doesn't understand the enum method, so it finds no valid method and ends up in the else clause. It's a confusing error message, because apparently it never occurred to us that one could pass in an invalid argument. 😂 Would you mind raising an issue in skimage? I get the same error with:
import numpy as np
from skimage.morphology import skeletonize
result = skeletonize(np.ones((5, 5)), method='foo')
That was super tricky! 😅 Sorry for the misleading error message — good chance I wrote it at some point! 😂 As a minor comment, I would like this function to be in the skan package itself, not in a new napari_skan package. Thank you! 😊 🙏 |
Co-authored-by: Juan Nunez-Iglesias <jni@fastmail.com>
Thank you very much for the help @jni! It works now! |
@jamesyan-git so cool! 😊 Should we merge this one as-is and do the skeleton analysis in the next step? Or do you want to wait until you add the shapes layer? |
Hi @jni, sorry I missed that. I've added a docstring, I think we can merge now. |
LOL New networkx just dropped and broke everything! 😂🤦 |
This PR adds a napari plugin with a basic widget for skeletonizing a labels layer.