Skip to content

Commit

Permalink
proposal for simplified API for tiled acquisition
Browse files Browse the repository at this point in the history
  • Loading branch information
mattersoflight committed Feb 11, 2023
1 parent b9516b1 commit 61237f9
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
5 changes: 4 additions & 1 deletion examples/hcs_zarr.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@
# create and write to positions
for i, (row, col, fov) in enumerate(position_list):
position = dataset.create_position(row, col, fov)
position["0"] = i*np.ones((2, 3, 5, 32, 32)).astype(np.uint16)
position["0"] = i * np.ones((2, 3, 5, 32, 32)).astype(np.uint16)
# 2 timepoints, 3 channels, 5 z-slices, 32x32 image

#position.img or position.data is a more intuitive way to write and read data.
# Can we implement this?
# print dataset summary
dataset.print_tree()
# Try viewing the hcs.zarr dataset in napari.
Expand Down
2 changes: 2 additions & 0 deletions examples/singleFOV_zarr.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
store_path, layout="fov", mode="a", channel_names=["DAPI", "GFP"]
) as dataset:
dataset["img"] = tczyx
#dataset.img or dataset.data is a more intuitive way to write and read data.
# Can we implement this?

# %%
# Opening in read-only mode prevents writing
Expand Down
41 changes: 41 additions & 0 deletions examples/tiles_zarr.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# %%
# This script writes a tiled (multi-FOV) zarr dataset.
# It is not spcified by the NGFF specification, but is a common use case.
# We repurpose the HCS layout from the NGFF specification to make multi-position data to view with napari-ome-zarr.


import os

import numpy as np

from iohub.ngff import open_ome_zarr

# %%
# Set storage path

store_path = f'{os.path.expanduser("~/")}tiles.zarr'

# %%
# Write 5D data to multiple positions.
# While the NGFF specification allows for arbitrary names,
# the ome-zarr-py library (thus the napari-ome-zarr plugin)
# only load arrays with name '0'.

position_list = ((row, col) for row in ("row_0", "row_1") for col in range(10))

with open_ome_zarr(
store_path,
layout="tiles",
mode="w",
channel_names=["DAPI", "GFP", "Brightfield"],
) as dataset:
# create and write to positions
for i, (row, col) in enumerate(position_list):
position = dataset.create_position(row, col)
# Following usage (set the data property) is more intuitive. Can we implement this?
# position.data = i*np.ones((2, 3, 5, 32, 32)).astype(np.uint16)
position["0"] = i*np.ones((2, 3, 5, 32, 32)).astype(np.uint16)
# 2 timepoints, 3 channels, 5 z-slices, 32x32 image at each position
# print dataset summary
dataset.print_tree()
# Try viewing the tiles.zarr dataset in napari or each position individually.

0 comments on commit 61237f9

Please sign in to comment.