|
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 | + """ |
2 | 17 | # NOTE: Let's try for one link first, we can generalize it later. |
3 | 18 | url = "https://public.czbiohub.org/royerlab/ultrack/zebrafish_embryo.ome.zarr" |
4 | 19 |
|
5 | | - from ome_zarr.reader import Reader |
6 | | - from ome_zarr.io import parse_url |
7 | | - |
8 | 20 | reader = Reader(parse_url(url)) # Prepare a reader. |
9 | 21 | nodes = list(reader()) # Might include multiple stuff |
10 | 22 | image_node = nodes[0] # First node is expecte to be image pixel data. |
11 | 23 |
|
12 | 24 | dask_data = image_node.data # Get the daskified data. |
13 | 25 |
|
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() |
16 | 40 |
|
17 | | - # Load using napari |
18 | | - import napari |
19 | | - viewer = napari.view_image(curr_data, channel_axis=0) |
20 | | - napari.run() |
| 41 | + return curr_data |
21 | 42 |
|
22 | 43 |
|
23 | 44 | def main(): |
24 | | - get_czi_zebrafish_data() |
| 45 | + image = get_czi_zebrafish_data(view=False) |
| 46 | + print(image.shape) |
25 | 47 |
|
26 | 48 |
|
27 | 49 | if __name__ == "__main__": |
|
0 commit comments