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

Simplify first example in docs #326

Merged
merged 1 commit into from
Nov 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 46 additions & 7 deletions docs/source/python.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,52 @@ of 2 in the X and Y dimensions.
Alternatively, the :py:func:`ome_zarr.writer.write_multiscale` can be used, which takes a
"pyramid" `numpy` arrays.

The following code creates a 3D Image in OME-Zarr::

import numpy as np
import zarr
import os

from ome_zarr.io import parse_url
from ome_zarr.writer import write_image

path = "test_ngff_image.zarr"
os.mkdir(path)

size_xy = 128
size_z = 10
rng = np.random.default_rng(0)
data = rng.poisson(lam=10, size=(size_z, size_xy, size_xy)).astype(np.uint8)

# write the image data
store = parse_url(path, mode="w").store
root = zarr.group(store=store)
write_image(image=data, group=root, axes="zyx", storage_options=dict(chunks=(1, size_xy, size_xy)))


This image can be viewed in `napari` using the
`napari-ome-zarr <https://github.com/ome/napari-ome-zarr>`_ plugin::

$ napari test_ngff_image.zarr

Rendering settings
------------------
Render settings can be added to an existing zarr group::

store = parse_url(path, mode="w").store
root = zarr.group(store=store)
root.attrs["omero"] = {
"channels": [{
"color": "00FFFF",
"window": {"start": 0, "end": 20, "min": 0, "max": 255},
"label": "random",
"active": True,
}]
}

Writing labels
--------------

The following code creates a 3D Image in OME-Zarr with labels::

import numpy as np
Expand Down Expand Up @@ -73,13 +119,6 @@ The following code creates a 3D Image in OME-Zarr with labels::

write_image(label, label_grp, axes="zyx")


This image can be viewed in `napari` using the
`napari-ome-zarr <https://github.com/ome/napari-ome-zarr>`_ plugin::

$ napari test_ngff_image.zarr


Writing HCS datasets to OME-NGFF
--------------------------------

Expand Down
Loading