jni / skan

Python module to analyse skeleton (thin object) images
https://skeleton-analysis.org
BSD 3-Clause "New" or "Revised" License
118 stars 39 forks source link

Add napari plugin with skeletonize widget #184

Closed jamesyan-git closed 1 year ago

jamesyan-git commented 1 year ago

This PR adds a napari plugin with a basic widget for skeletonizing a labels layer.

jamesyan-git commented 1 year ago

@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. Tried this in ipython with a numpy array and did not error. We checked the attributes of the data and it all seems to be what skeletonize requires, so I'm a bit lost. Would love your insights!

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')
jni commented 1 year ago

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! 😊 🙏

jamesyan-git commented 1 year ago

Thank you very much for the help @jni! It works now!

jni commented 1 year ago

@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?

jni commented 1 year ago

@jamesyan-git :wave:

jamesyan-git commented 1 year ago

Hi @jni, sorry I missed that. I've added a docstring, I think we can merge now. I wanted to add some instructions on the widget for the user, but it seems non trivial if we want to continue auto-generating it. Not auto-generating it would introduce dependencies though (magicgui for decorator at least), but this is necessary even for something trivial like changing the button text. I'm happy to go this route if you are, can do in separate PR if you approve. I was thinking of just adding an example for usage, but I'm not sure if that alone is sufficient for a new user. Let me know what you think and I'll follow up.

jni commented 1 year ago

LOL New networkx just dropped and broke everything! 😂🤦