From 4afa6e56e5bc0c9683ad03fa946aef503895c51d Mon Sep 17 00:00:00 2001 From: Jacky Ko Date: Wed, 24 Jan 2024 16:49:15 +0000 Subject: [PATCH 1/3] add doc --- aicsimageio/writers/ome_zarr_writer.py | 40 ++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/aicsimageio/writers/ome_zarr_writer.py b/aicsimageio/writers/ome_zarr_writer.py index e28b0d95b..10c7d19db 100644 --- a/aicsimageio/writers/ome_zarr_writer.py +++ b/aicsimageio/writers/ome_zarr_writer.py @@ -178,6 +178,46 @@ def write_image( ... writer = OmeZarrWriter("/path/to/file.ome.zarr") ... writer.write_image(image0, "Image:0", ["C00","C01","C02"]) ... writer.write_image(image1, "Image:1", ["C10","C11","C12"]) + + Write multi-scale image to OME-Zarr + >>> image = numpy.ndarray([3, 10, 1024, 2048]) + ... writer = OmeZarrWriter("/path/to/file.ome.zarr") + ... writer.write_image( + ... data, + ... image_name="Image:0", + ... channel_names=["C00","C01","C02"], + ... scale_num_levels=3, + ... scale_factor=2.0, + ... dimension_order="CZYX" + ... ) + + Write image channel color to OME-Zarr + >>> image = numpy.ndarray([3, 10, 1024, 2048]) + ... channel_colors = ["FFFFFF","00FFFF","0000FF"] + ... int_color = [int(c, 16) for c in channel_colors] + ... writer = OmeZarrWriter("/path/to/file.ome.zarr") + ... writer.write_image( + ... data, + ... image_name="Image:0", + ... channel_names=["C00","C01","C02"], + ... channel_colors=int_color, + ... dimension_order="CZYX" + ... ) + + Write pixel size to OME-Zarr + >>> from aicsimageio import AICSImage, types + ... image = numpy.ndarray([3, 10, 1024, 2048]) + ... channel_colors = ["FFFFFF","00FFFF","0000FF"] + ... int_color = [int(c, 16) for c in channel_colors] + ... writer = OmeZarrWriter("/path/to/file.ome.zarr") + ... writer.write_image( + ... data, + ... image_name="Image:0", + ... physical_pixel_sizes=types.PhysicalPixelSizes(X=0.5, Y=0.5, Z=1.0) + ... channel_names=["C00","C01","C02"], + ... channel_colors=int_color, + ... dimension_order="CZYX" + ... ) """ ndims = len(image_data.shape) if ndims < 2 or ndims > 5: From 82542a0131d76ae5367e83011e387814e1482bc4 Mon Sep 17 00:00:00 2001 From: Jacky Ko Date: Wed, 24 Jan 2024 16:59:00 +0000 Subject: [PATCH 2/3] ome zarr --- README.md | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 19cc6511d..af77b4da8 100644 --- a/README.md +++ b/README.md @@ -304,7 +304,7 @@ as an OME-TIFF, the writer class can also be used to customize as needed. ```python import numpy as np -from aicsimageio.writers import OmeTiffWriter +from aicsimageio.writers.ome_tiff_writer import OmeTiffWriter image = np.random.rand(10, 3, 1024, 2048) OmeTiffWriter.save(image, "file.ome.tif", dim_order="ZCYX") @@ -314,6 +314,35 @@ See [OmeTiffWriter documentation](./aicsimageio.writers.html#aicsimageio.writers.ome_tiff_writer.OmeTiffWriter.save) for more details. +### Saving to OME-ZARR +In-built writer for OME-ZARR output, effectively towards large image data + +```python +from aicsimageio import AICSImage, types +from aicsimageio.writers.ome_zarr_writer import OmeZarrWriter + +image = np.random.rand(3, 10, 1024, 2048) +channel_colors = ["FFFFFF","00FFFF","0000FF"] +int_color = [int(c, 16) for c in channel_colors] + +writer = OmeZarrWriter("./test.ome.zarr") + +writer.write_image( + image, + image_name="Image:0", + physical_pixel_sizes=types.PhysicalPixelSizes(X=0.5, Y=0.5, Z=1.0), # in um + channel_names=["C00","C01","C02"], + channel_colors=int_color, + scale_num_levels=3, + scale_factor=2.0, + dimension_order="CZYX" + ) +``` + +See +[OmeZarrWriter documentation](./aicsimageio.writers.html#aicsimageio.writers.ome_zarr_writer.OmeZarrWriter.save) +for more details. + #### Other Writers In most cases, `AICSImage.save` is usually a good default but there are other image From f4a19773d5421dd6577f6f20b9f01cac1ed56575 Mon Sep 17 00:00:00 2001 From: Jacky Ko Date: Wed, 24 Jan 2024 17:01:41 +0000 Subject: [PATCH 3/3] add zarr writer --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index af77b4da8..00cf2ca56 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ Image Reading, Metadata Conversion, and Image Writing for Microscopy Images in P - Files supported by [Bio-Formats](https://docs.openmicroscopy.org/bio-formats/latest/supported-formats.html) -- (`pip install aicsimageio bioformats_jar`) (Note: requires `java` and `maven`, see below for details.) - Supports writing metadata and imaging data for: - `OME-TIFF` + - `OME-ZARR` - `PNG`, `GIF`, [etc.](https://github.com/imageio/imageio) -- (`pip install aicsimageio[base-imageio]`) - Supports reading and writing to [fsspec](https://github.com/intake/filesystem_spec) supported file systems