You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the command above we are also installing the [napari-ome-zarr](https://github.com/ome/napari-ome-zarr) plugin to facilitate accessing the miroscopy (OME) metadata from the zarr files.
11
12
12
-
You can then use the following code to load the CMU-1 zarr and labels zarr into napari:
Note the `/0` at the end of the path, indicating that napari should open the first (and only in this case) image multiscale/pyramid group. You can also subsitute the path to your local copy of `CMU-1_Crop.ome.zarr`, making sure to append the `/0`.
22
18
23
-
We will load the zarr data as a list of dask arrays, so napari understands that we have multiscale/pyramidal data.
24
-
The list of data arrays must be in order from largest to smallest, following the downsampling of the pyramid.
25
-
For convenience, we will squeeze out the singleton arrays (by default OME-Zarr store images as 5D arrays) and move the channel axis to the end of the array shape, such that we get RGB images.
26
-
27
-
```python
28
-
img_zarr_group = zarr.open(img_path, mode="r")
29
-
# use the first (and only) image multiscale/pyramid group
30
-
dask_stack = [da.from_zarr(img_zarr_group[0][level]).squeeze() for level in img_zarr_group[0]]
31
-
rgb_dask_stack = [da.moveaxis(arr, 0, -1) for arr in dask_stack]
Once the viewer loads, you can then drag-and-drop the labels zarr folder (`CMU-1_Crop_labels_cellpose_cyto3.zarr`) into the napari viewer to add the labels layer. When prompted, select `napari-ome-zarr` plugin. Once the layer loads, you will need to right-click on the labels layer (named "C") in the layer list on the left side of the viewer and select "Convert to labels" to get the correct rendering of the labels.
45
20
46
21
After zooming in a bit, you should see something like this:
47
22

48
23
49
-
Optionally, you can also install the [napari-ome-zarr](https://github.com/ome/napari-ome-zarr) plugin to facilitate accessing the miroscopy (OME) metadata from the zarr files:
In this case, you can simply launch napari from the command line and open the zarr image using:
56
-
```bash
57
-
napari path/to/CMU-1_Crop.ome.zarr/0
58
-
```
59
-
Note the `/0` at the end of the path, indicating that napari should open the first (and only in this case) image multiscale/pyramid group
60
-
With the viewer open, you can then drag-and-drop the labels zarr folder into the napari viewer to add the labels layer. When prompted, select `napari-ome-zarr` plugin. However, you will need to right-click on the layer with the labels data and select "Convert to labels" to get the correct rendering of the labels.
61
-
62
24
Or you can do it programmatically as follows:
63
25
```python
64
26
import napari
65
27
66
28
# path to the first (only) image multiscale/pyramid group
67
-
img_path ="path/to/CMU-1_Crop.ome.zarr/0"
29
+
# again, you can replace the URL with your local path
Note: If you want to run these snippets as scripts, append `napari.run()` at the end of the script to start the napari event loop.
39
+
Note: If you want to run this snippet as a script, append `napari.run()` at the end of the script to start the napari event loop.
77
40
78
-
Final tip: if you want to use napari with full size whole-slide images or remote zarr data, we recommend using the "Render Images Asynchronously" option in napari settings (under "Experimental"). You can also set this using the environment variable `NAPARI_ASYNC=1`.
41
+
Final tip: if you want to use napari with full size whole-slide images or remote zarr data, we recommend using the "Render Images Asynchronously" option in napari settings (under "Experimental"). You can also set this using the environment variable `NAPARI_ASYNC=1`, e.g.:
0 commit comments