ome / omero-cli-zarr

https://pypi.org/project/omero-cli-zarr/
GNU General Public License v2.0
16 stars 10 forks source link

Export plate masks #44

Closed dominikl closed 3 years ago

dominikl commented 3 years ago

Adds the functionality for exporting masks/labels for plates.

It exports the masks in a path structure like this:

13855.zarr:
...
0/A/1/Field_1/0/0.0.0.0.0
0/A/1/Field_1/0/0.1.0.0.0
...
0/A/1/Field_1/labels/0/0/0.0.0.0.0
0/A/1/Field_1/labels/0/0/0.0.0.0.1
...

For testing I used plate plate1_1_013 on merge-ci (user-3), doesn't take too long to export (about 10-15 min the first time).

omero zarr --cache_numpy export Plate:13855
omero zarr masks Plate:13855

Or create your own masks with a simple segmentation. I pasted a script together (based on idr0079 maks import script): https://gist.github.com/dominikl/0c65cc18d57b51c509e93e53c1c44bc6 .

Waiting for #43 to merged, will rebase then.

will-moore commented 3 years ago

I haven't had time to fully understand / test this yet, but I would like to see the mask for each image in a Plate nested under that image in the plate hierarchy, so that if you do napari path/to/plate/0/A/A/0/ then you get the image loading with masks?

dominikl commented 3 years ago

Hm, I thought the labels directory is at the root level of the zarr file. Anyway, can move the labels in the image directory as well. Where do we actually have the current working 'spec' documented? With all the notes, PRs and comments scattered around everywhere, it's really hard to find things.

joshmoore commented 3 years ago

If a group X has attrs "multiscales" then the labels for that are under X/labels

dominikl commented 3 years ago

Done. Updated the PR description accordingly.

joshmoore commented 3 years ago

Or create your own masks with a simple segmentation.

Heh. This is great. I'm imaging on export a dialog, "Oh, you don't seem to have any masks, shall I segment your image for you?" :smile:

will-moore commented 3 years ago

Created a plate locally using Dataset_to_Plate script and added masks using the gist above (thanks). Then exported plate and masks locally.

Opened a single image in napari and masks are displayed:

Screenshot 2020-11-10 at 16 04 06

joshmoore commented 3 years ago

NB: This makes me think we should really change the default name of the labels group.

will-moore commented 3 years ago

I noticed the README has omero zarr labels Image:1 --label-path=my_labels instead of 'masks'. Did we not decide to use the 'labels' terminology for all ome-zarr spec things now?

Also, doesn't --label-path=my_labels break the ome-zarr spec, where labels are always stored under 'labels'?

omero zarr export Image:6001247
omero zarr masks Image:6001247 --label-path=my_labels
napari 6001247.zarr

The labels are not shown in napari because ome-zarr-py checks for labels under /labels. It works if you omit the --label-path argument.

joshmoore commented 3 years ago

Did we not decide to use the 'labels' terminology for all ome-zarr spec things now?

"masks" is used when accessing OMERO (since there are no "labels"), so the CLI command was intended to be "masks".

Also, doesn't --label-path=my_labels break the ome-zarr spec, where labels are always stored under 'labels'?

Very likely. Does the -h output not say that?

will-moore commented 3 years ago

Ah, yes it does - But I always read the README not the -h. So I guess I don't understand why we offer that option to export it in a state that breaks the spec? If I want to break the spec, maybe I should just export it as valid 'labels', then rename the folder?

I can do the README fixes in another PR. We also need to add Plate support to the README.

will-moore commented 3 years ago

PR opened at https://github.com/ome/omero-cli-zarr/pull/46

dominikl commented 3 years ago

Note: With the last commit #45 needs to be merged in order for this to work.

joshmoore commented 3 years ago

pr-44-a (No labels are shown in the overall plate view)

will-moore commented 3 years ago

I think this is good to merge from me.

joshmoore commented 3 years ago

Merging along with gh-45