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

Add API for writing image-label #171

Closed
constantinpape opened this issue Feb 28, 2022 · 8 comments
Closed

Add API for writing image-label #171

constantinpape opened this issue Feb 28, 2022 · 8 comments
Labels
enhancement New feature or request

Comments

@constantinpape
Copy link
Contributor

Is there support to write "image-label" datasets (https://ngff.openmicroscopy.org/latest/#label-md) in ome-zarr-py already?
If yes, how do I use it?

@will-moore
Copy link
Member

Threre's an example at https://github.com/ome/ome-zarr-py/blob/0ea5bf61ef754069abf4f223897d55630c953fbf/README.rst
which is part of a long-standing PR #121
Actually, I have subsequently removed the labels from the PR to make it more concise for the README

@constantinpape
Copy link
Contributor Author

Thanks @will-moore; the example was very helpful and I could update my scripts to write ome.zarr with labels.

@sbesson
Copy link
Member

sbesson commented Mar 1, 2022

Looking at the example, I could imagine wrapping the succession of low-level calls into utilities dealing with the group/metadata creation/update e.g.

write_image(image=data, group=image_root)
label_root = add_label(image_root, label_name)
write_image(image=label_data, group=label_root)

or

write_image(image=data, group=image_root)
write_label(image=label_image, group=image_root, name=label_name)

It would be interesting to know you would see the value of introducing such API based on your usage @constantinpape.

@constantinpape
Copy link
Contributor Author

It would be interesting to know you would see the value of introducing such API based on your usage @constantinpape.

Yes, absolutely! write_label should also have support for (optional? depending on ome/ngff#105) arguments to pass the label/property values.

@sbesson sbesson changed the title Is writing "image-label" supported? Add API for writing image-label Mar 2, 2022
@sbesson sbesson added the enhancement New feature or request label Mar 2, 2022
@sbesson
Copy link
Member

sbesson commented Mar 2, 2022

I have updated the title of this issue to reflect the new scope.

So current preference would be rather a single API that would first create/update the intermediate groups (depending on the presence of labels) and then write the label image, is that correct? In terms of behavior, I agree the API should also support both mandatory as well as optional image-label attributes.

For the metadata, my current preference would be to extend write_multiscale to support an extra metadata dictionary similarly storage_options. This would allow to set additional metadata, either specified (omero, image-label...) or custom, to be stored in the attributes of the multiscales group.

Thinking of the sequence of a write_label_image API, the biggest unknown to me at this point is whether this API should call write_image or write_multiscales. The former is effectively a wrapper around the latter but I do not know whether it should always be seen as the single entry-point @joshmoore @will-moore ?

@will-moore
Copy link
Member

I think users will find write_image() and write_multiscale() useful, since they may have their pyramid already generated (not want to use the Scaler).

@constantinpape
Copy link
Contributor Author

As discussed in ome/napari-ome-zarr#33 this API would need to also add the group-level "labels" metadata, which btw should be explained better in the spec, see ome/ngff#108.

@constantinpape
Copy link
Contributor Author

Implemented in #178

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

No branches or pull requests

3 participants