-
Notifications
You must be signed in to change notification settings - Fork 12
OME-Zarr v0.5 (Zarr v3) support #301
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
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
88f90cf
Upgrade zarr-python dependency to 3.0 (#275)
aliddell a8fd837
Merge branch 'main' into zarr3-dev
ziw-liu b8da623
Support reading OME-Zarr 0.5 (#295)
ziw-liu 776ff4d
Merge branch 'main' into zarr3-dev
ziw-liu 5382c06
Write OME-Zarr 0.5 (#310)
ziw-liu bcd9a2b
Update acquire-zarr tests (#320)
ziw-liu 8713e9b
Enable tests with ome-zarr-py (#297)
ziw-liu 2d1c5fb
Parallel writing to shards (#311)
ziw-liu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| """ | ||
| Update OME-Zarr Version | ||
| ======================= | ||
|
|
||
| This script shows how to write the same OME-Zarr image | ||
| using a new version. | ||
| """ | ||
|
|
||
| # %% | ||
| from pathlib import Path | ||
| from tempfile import TemporaryDirectory | ||
|
|
||
| import numpy as np | ||
|
|
||
| from iohub.ngff import TransformationMeta, open_ome_zarr | ||
|
|
||
| # %% | ||
| # Set storage path | ||
| tmp_dir = TemporaryDirectory() | ||
| old_store_path = Path(tmp_dir.name) / "old.zarr" | ||
| new_store_path = Path(tmp_dir.name) / "new.zarr" | ||
|
|
||
| # %% | ||
| # Create a version 0.4 OME-Zarr dataset | ||
| random_image = np.random.randint( | ||
| 0, np.iinfo(np.uint16).max, size=(10, 2, 32, 128, 128), dtype=np.uint16 | ||
| ) | ||
| scale = [2.0, 3.0, 4.0, 5.0, 6.0] | ||
|
|
||
|
|
||
| with open_ome_zarr( | ||
| old_store_path, | ||
| layout="hcs", | ||
| mode="w-", | ||
| channel_names=["DAPI", "GFP"], | ||
| version="0.4", | ||
| ) as old_dataset: | ||
| position = old_dataset.create_position("A", "1", "0") | ||
| image = position.create_image( | ||
| "0", | ||
| random_image, | ||
| chunks=(1, 1, 4, 32, 32), | ||
| transform=[TransformationMeta(type="scale", scale=scale)], | ||
| ) | ||
|
|
||
| # %% | ||
| # Write the same image with version 0.5 and sharding | ||
|
|
||
| with open_ome_zarr(old_store_path, mode="r", layout="hcs") as old_dataset: | ||
| with open_ome_zarr( | ||
| new_store_path, | ||
| layout="hcs", | ||
| mode="w", | ||
| channel_names=old_dataset.channel_names, | ||
| version="0.5", | ||
| ) as new_dataset: | ||
| for name, old_position in old_dataset.positions(): | ||
| row, col, fov = name.split("/") | ||
| new_position = new_dataset.create_position(row, col, fov) | ||
| old_image = old_position["0"] | ||
| new_image = new_position.create_image( | ||
| "0", | ||
| data=old_image.numpy(), | ||
| chunks=(1, 1, 4, 32, 32), | ||
| shards_ratio=(2, 1, 8, 4, 4), | ||
| transform=old_position.metadata.multiscales[0] | ||
| .datasets[0] | ||
| .coordinate_transformations, | ||
| ) | ||
|
|
||
| # %% | ||
| # Read the new FOV to verify it was written correctly | ||
| with open_ome_zarr(new_store_path / "A/1/0", mode="r") as dataset: | ||
| assert dataset.scale == scale | ||
| image = dataset["0"] | ||
| assert image.shards == (2, 1, 32, 128, 128) | ||
| assert np.array_equal(image.numpy(), random_image) | ||
|
|
||
| # %% | ||
| # Clean up | ||
| tmp_dir.cleanup() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.