Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .isort.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[settings]
known_third_party = dask,napari,numpy,ome_zarr,pytest,zarr
known_third_party = dask,magicgui,napari,numpy,ome_zarr,pytest,zarr
32 changes: 32 additions & 0 deletions napari_ome_zarr/_widgets.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import magicgui


@magicgui.magic_factory(
call_button="Import",
ome_zarr_url={"label": "OME-ZARR URL"},
)
def import_from_url(ome_zarr_url: str) -> None:
"""Import an OME-Zarr from a URL."""
from napari import current_viewer
from napari.utils.notifications import show_warning

from napari_ome_zarr._reader import napari_get_reader

viewer = current_viewer()

if viewer is None:
return

reader = napari_get_reader(ome_zarr_url)
if reader is None:
Comment thread
jo-mueller marked this conversation as resolved.
show_warning(f"No reader found for {ome_zarr_url}")
return None

layer_data = reader(ome_zarr_url)
Comment thread
jo-mueller marked this conversation as resolved.
for layer in layer_data:
if layer[2] == "image":
viewer.add_image(layer[0], **layer[1])
elif layer[2] == "labels":
viewer.add_labels(layer[0], **layer[1])
else:
pass
Comment thread
jo-mueller marked this conversation as resolved.
Comment thread
jo-mueller marked this conversation as resolved.
11 changes: 10 additions & 1 deletion napari_ome_zarr/napari.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
---
name: napari-ome-zarr
schema_version: 0.1.0
contributions:
commands:
- id: napari-ome-zarr.get_reader
title: Get Reader
python_name: napari_ome_zarr._reader:napari_get_reader
- id: napari-ome-zarr.url_importer
title: Import OME-ZARR from URL
python_name: napari_ome_zarr._widgets:import_from_url
readers:
- command: napari-ome-zarr.get_reader
filename_patterns:
- "*.zarr"
- "*.zarr*"
accepts_directories: true
menus:
napari/file/io_utilities:
- command: napari-ome-zarr.url_importer
display_name: Import OME-ZARR from URL
widgets:
- command: napari-ome-zarr.url_importer
display_name: Import OME-ZARR from URL
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[project]
name = "napari-ome-zarr"
description = "A reader for zarr backed OME-Zarr images."
dynamic = ["version", "entry-points"]
dynamic = ["version"]
license = "BSD-3-Clause"
readme = "README.md"
requires-python = ">=3.11"
Expand Down Expand Up @@ -37,3 +37,6 @@ build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
version_file = "napari_ome_zarr/_version.py"

Comment thread
jo-mueller marked this conversation as resolved.
[project.entry-points."napari.manifest"]
napari-ome-zarr = "napari_ome_zarr:napari.yaml"
Loading