Skip to content
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

Labels properties are a dict of lists #12

Merged
merged 2 commits into from
Sep 22, 2021

Conversation

will-moore
Copy link
Member

@will-moore will-moore commented Sep 20, 2021

Fixes #6.

This updates napari-ome-zarr to transform label properties into the format that napari is now expecting, using index as the label ID as described at https://forum.image.sc/t/napari-labels-layer-properties/57649

e.g.

    {
        "index": [1381342, 1381343...]
        "key1": [1381342, 1381343...],
        "key2": [1682567, 1682567...]
    }

To test, using data exported from omero-cli-zarr at PR: ome/omero-cli-zarr#82

napari https://minio-dev.openmicroscopy.org/idr/v0.3/idr0062-blin-nuclearsegmentation/6001247.zarr

Mousing over a label should show associated values in the footer:

Screenshot 2021-09-20 at 14 06 01

Needed by from napari import conftest, since napari test deps aren't installed
@@ -32,6 +32,7 @@ deps =
# you can remove these if you don't use them
napari
magicgui
pooch
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does pooch get used, @will-moore ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See previous run failure: https://github.com/ome/napari-ome-zarr/runs/3651193426

.tox/py37-linux/lib/python3.7/site-packages/napari/conftest.py:5

>>> import pooch
ModuleNotFoundError

pooch is listed as a test dependency of napari.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As pooch is a testing dependency of napari (https://github.com/napari/napari/blob/95a5d06fe36f10fb26f5798f1327a3ea082d581f/setup.cfg#L105), updating https://github.com/ome/napari-ome-zarr/blob/main/tox.ini#L33 with

-    napari
+   napari[testing]

would be another option. Does it bring too many extra dependencies?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just trying this locally into my existing napari & ome-zarr-py env:

$ pip install -U napari[testing]

This download 8 packages, mostly very small (few MB or less) except torch (218 MB). 🤷

@joshmoore
Copy link
Member

With origin/main, I still see the error from #6: TypeError: len() of unsized object

With this PR, the image & label layers load.

I note that I see a separate error when viewing the labels in 3D:

/usr/local/anaconda3/envs/z/lib/python3.9/site-packages/napari/layers/labels/labels.py in _get_value_ray(self=<Labels layer '0'>, start_point=<class 'numpy.ndarray'> (3,) float64, end_point=<class 'numpy.ndarray'> (3,) float64, dims_displayed=[2, 3, 4])
    972                 sample_points, self._display_bounding_box(dims_displayed)
    973             ).astype(int)
--> 974             values = im_slice[tuple(clamped.T)]
        values = undefined
        im_slice = <class 'numpy.ndarray'> (257, 26, 31) int64
        global tuple = undefined
        clamped.T = <class 'numpy.ndarray'> (3, 504) int64
    975             nonzero_indices = np.flatnonzero(values)
    976             if len(nonzero_indices > 0):

IndexError: index 144 is out of bounds for axis 1 with size 26

@will-moore
Copy link
Member Author

@joshmoore No idea what's up with the 3D labels, but I don't think it's related to this PR.
Again, shame we don't know when it last worked.

@joshmoore
Copy link
Member

I created #14. Merging.

@joshmoore joshmoore merged commit be5ff0d into ome:main Sep 22, 2021
@imagesc-bot
Copy link

This pull request has been mentioned on Image.sc Forum. There might be relevant details there:

https://forum.image.sc/t/tool-for-adding-labels-group-to-ome-ngff/72839/4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

napari failing on labels v0.2 version of idr:6001247
4 participants