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

Array-like API for NGFF I/O #19

Closed
ziw-liu opened this issue Jan 18, 2023 · 4 comments · Fixed by #31
Closed

Array-like API for NGFF I/O #19

ziw-liu opened this issue Jan 18, 2023 · 4 comments · Fixed by #31
Assignees
Labels
enhancement New feature or request NGFF OME-NGFF (OME-Zarr format)
Milestone

Comments

@ziw-liu
Copy link
Collaborator

ziw-liu commented Jan 18, 2023

In contrast to the readers/writers design inherited from waveorder.io, a 'dataset' container for NGFF datasets that offers array-like API is more ergonomic and pythonic for NGFF datasets. It is also more maintainable since the data and metadata models can stay in one place.

Pseudo code aggregated from our offline discussion:

from iohub.ngff import HCSZarr

from my_analysis import fancy_transformation_plot
from my_microscope import camera

with HCSZarr.open("./very_important.zarr", mode="r") as read_only_dataset:
    # Get a copy of data in RAM and prototype analysis
    # This syntax should be familiar for PyTorch users
    tczyx_example = read_only_dataset["A/1/0/0"].numpy()
    fancy_transformation_plot(tczyx_example)

with HCSZarr.open("./acquisition.zarr", mode="a") as write_and_create_ok_dataset:
    # Writing to a slice of the Zarr array
    new_position = write_and_create_ok_dataset["H"]["12"][5 + 1]
    new_position[0][0, 1, 2, :, :] = camera.next_frame()
@ziw-liu ziw-liu added enhancement New feature or request NGFF OME-NGFF (OME-Zarr format) labels Jan 18, 2023
@ziw-liu ziw-liu self-assigned this Jan 18, 2023
@ziw-liu ziw-liu added this to the 0.0.1 milestone Jan 18, 2023
@ziw-liu ziw-liu linked a pull request Feb 1, 2023 that will close this issue
@AhmetCanSolak
Copy link
Contributor

This is beautiful and I would suggest us to adopt datasets and drop support for waveorder.io style readers/writers. Curious to hear if @talonchandler and @ieivanov have any preference on this.

@talonchandler
Copy link
Contributor

I'm in favor of immediately dropping support for waveorder.io-style writers, since the iohub writers in #31 are an excellent spec-adherent replacement .

I'm a bit more conservative about dropping support for the current waveorder.io-style readers. I'm on board for dropping support for the readers when another "universal entry point" reader #40 (with support for pycromanager, ometiff, singlepagetiff datasets) becomes available. If iohub decides to drop support for these data formats, then recOrder and waveorder will not be able to depend on iohub until these features are reinstated.

@AhmetCanSolak
Copy link
Contributor

I'm a bit more conservative about dropping support for the current waveorder.io-style readers. I'm on board for dropping support for the readers when another "universal entry point" reader #40 (with support for pycromanager, ometiff, singlepagetiff datasets) becomes available. If iohub decides to drop support for these data formats, then recOrder and waveorder will not be able to depend on iohub until these features are reinstated.

I see your point and I am with you @talonchandler . We don't need to drop readers immediately but maybe we can provide a keyword argument to datasets which can allow you to call the legacy readers underneath temporarily. This way we can keep the readers as part of private API for some time and start promoting the dataset array API immediately. How would you feel about such direction?

@talonchandler
Copy link
Contributor

We don't need to drop readers immediately but maybe we can provide a keyword argument to datasets which can allow you to call the legacy readers underneath temporarily. This way we can keep the readers as part of private API for some time and start promoting the dataset array API immediately.

Sounds great to me!

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

Successfully merging a pull request may close this issue.

3 participants