View OME-ZARR plates in Vizarr

This tutorial demonstrates how to load data generated with Fractal into Vizarr.

import zarr
import vizarr
import fsspec
import requests
import zipfile
import io
from pathlib import Path
from typing import Optional

def zarr_from_zip(zarr_root: str, row: Optional[str]=None, col: Optional[str]=None):
    with requests.get(zarr_root, stream=True) as r:
        r.raise_for_status()
        with zipfile.ZipFile(io.BytesIO(r.content)) as z:
            z.extractall()
            stem = Path(zarr_root).stem
            if (row is not None) & (col is not None):
                zarr_url = f"{stem}/{row}/{col}"
            else:
                zarr_url = stem
            store = fsspec.get_mapper(zarr_url)
            root = zarr.open(store, mode='r')
            return(root)
zip_url = "https://zenodo.org/records/13998404/files/operetta_plate.zarr.zip"
zarr_plate = zarr_from_zip(zip_url, "C", "3")
viewer = vizarr.Viewer()
viewer.add_image(source=zarr_plate)
viewer