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
4 changes: 2 additions & 2 deletions ome_zarr/classes/scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,8 +449,8 @@ def _ozmp_tf_to_tnd(
tnd_sub_transforms = [
tnd.transforms.by_dimension.SubTransform(
transform=self._ozmp_tf_to_tnd(sub_tf.transformation),
input_axes=sub_tf.input_axes,
output_axes=sub_tf.output_axes,
input_axes=sub_tf.inputAxes,
output_axes=sub_tf.outputAxes,
)
for sub_tf in sub_transformations
]
Expand Down
10 changes: 9 additions & 1 deletion ome_zarr/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
# Not needed with python 3.15+? https://github.com/python/cpython/issues/86809
from RangeHTTPServer import RangeRequestHandler

from . import USE_DASK_ARRAY_KWARGS
from . import USE_DASK_ARRAY_KWARGS, OMEZarrScene
from .format import format_from_version
from .io import parse_url
from .reader import Multiscales, Node, Reader
Expand Down Expand Up @@ -333,6 +333,14 @@ def download(input_path: str, output_dir: str = ".") -> None:
location = parse_url(input_path)
assert location, f"not a zarr: {location}"

if "scene" in location.root_attrs:
# ponytail: scene coordinate systems/axes vary by version; the
# ome_zarr_models-backed OMEZarrScene already handles this round-trip.
name = Path(location.path).name or "scene.zarr"
scene = OMEZarrScene.from_ome_zarr(location.store)
scene.to_ome_zarr(Path(output_dir) / name, overwrite=True)
return

reader = Reader(location)
nodes: list[Node] = list()
paths: list[list[str]] = list()
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ dependencies = [
"toolz",
"rangehttpserver",
"transformnd>=0.6.0,<0.8.0",
"ome-zarr-models>=1.8.0",
"ome-zarr-models>=1.8.1",
"Deprecated",
]
classifiers = [
Expand Down
24 changes: 19 additions & 5 deletions tests/test_scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from pydantic import TypeAdapter

from ome_zarr import OMEZarrImage, OMEZarrMultiscale, OMEZarrScene
from ome_zarr.utils import download

transform_adapter = TypeAdapter(AnyTransform)

Expand All @@ -29,13 +30,13 @@
"type": "byDimension",
"transformations": [
{
"input_axes": [1],
"output_axes": [1],
"inputAxes": [1],
"outputAxes": [1],
"transformation": {"type": "translation", "translation": (0.0,)},
},
{
"input_axes": [0],
"output_axes": [0],
"inputAxes": [0],
"outputAxes": [0],
"transformation": {"type": "scale", "scale": (1.0,)},
},
],
Expand Down Expand Up @@ -125,7 +126,12 @@ def test_create_scene_without_coordinate_systems(test_data_dir, transform):
coordinate_transformations=[transform],
)

scene.to_ome_zarr("test_scene.zarr", overwrite=True)
scene.to_ome_zarr(test_data_dir / "test_scene.zarr", overwrite=True)

# test "downloading" the scene elsewhere
download(
test_data_dir / "test_scene.zarr", test_data_dir / "test_scene_downloaded.zarr"
)

# check that the graph is created correctly
assert scene._graph is not None
Expand Down Expand Up @@ -250,6 +256,14 @@ def test_create_scene_with_coordinate_systems(test_data_dir, transform):
assert len(scene._graph.graph.nodes) == 4

scene.to_ome_zarr(str(test_data_dir / "test_scene_with_cs.zarr"), overwrite=True)

# test "downloading" the scene elsewhere
download(
test_data_dir / "test_scene_with_cs.zarr",
test_data_dir / "test_scene_with_cs_downloaded.zarr",
)

# read in saved scene and check everything's there
scene_read = OMEZarrScene.from_ome_zarr(
str(test_data_dir / "test_scene_with_cs.zarr")
)
Expand Down
Loading