Skip to content

Commit 794e46c

Browse files
committed
Finalize data loading for multiple resolutions
1 parent f83e27f commit 794e46c

File tree

1 file changed

+33
-11
lines changed

1 file changed

+33
-11
lines changed

development/prepare_czi_zebrafish_data.py

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,49 @@
1-
def get_czi_zebrafish_data():
1+
from ome_zarr.io import parse_url
2+
from ome_zarr.reader import Reader
3+
4+
import dask.array as da
5+
6+
7+
def get_czi_zebrafish_data(view: bool = False) -> da.Array:
8+
"""Gets the CZI ZebraFish light-sheet microscopy data.
9+
NOTE: Currently, we support only the raw data.
10+
11+
Args:
12+
view: Whether to view the dask array via napari.
13+
14+
Returns:
15+
The daskified chunky array.
16+
"""
217
# NOTE: Let's try for one link first, we can generalize it later.
318
url = "https://public.czbiohub.org/royerlab/ultrack/zebrafish_embryo.ome.zarr"
419

5-
from ome_zarr.reader import Reader
6-
from ome_zarr.io import parse_url
7-
820
reader = Reader(parse_url(url)) # Prepare a reader.
921
nodes = list(reader()) # Might include multiple stuff
1022
image_node = nodes[0] # First node is expecte to be image pixel data.
1123

1224
dask_data = image_node.data # Get the daskified data.
1325

14-
# HACK: Try it for one dask array with lowest resolution.
15-
curr_data = dask_data[-1]
26+
# HACK: Try it for one dask array with lowest resolution (there exists four resolutions in this data).
27+
curr_data = dask_data[-1] # TODO: Control dimensions from here, the highest res starts at the first index.
28+
29+
# We don't care about the over-time information. Let's get the 3d info for now!
30+
# I am removing the channel dimension here (OG dimension style: (T, C, Z, Y, X))
31+
curr_data = curr_data[:, 0] # TODO: Parse values in the time or z-dimension to parse limited slices?
32+
33+
# NOTE: The following line of code brings the entire dask array in memory.
34+
# curr_data = curr_data.compute()
35+
36+
if view:
37+
import napari
38+
napari.view_image(curr_data)
39+
napari.run()
1640

17-
# Load using napari
18-
import napari
19-
viewer = napari.view_image(curr_data, channel_axis=0)
20-
napari.run()
41+
return curr_data
2142

2243

2344
def main():
24-
get_czi_zebrafish_data()
45+
image = get_czi_zebrafish_data(view=False)
46+
print(image.shape)
2547

2648

2749
if __name__ == "__main__":

0 commit comments

Comments
 (0)