Skip to content

Commit

Permalink
Add image for v05
Browse files Browse the repository at this point in the history
  • Loading branch information
dstansby committed Jan 23, 2025
1 parent 08ca7e0 commit 82663a5
Show file tree
Hide file tree
Showing 6 changed files with 165 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/ome_zarr_models/_v05/axes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from ome_zarr_models.v04.axes import Axes, Axis, AxisType

__all__ = ["Axes", "Axis", "AxisType"]
21 changes: 21 additions & 0 deletions src/ome_zarr_models/_v05/coordinate_transformations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from ome_zarr_models.v04.coordinate_transformations import (
Identity,
PathScale,
PathTranslation,
ScaleTransform,
TranslationTransform,
VectorScale,
VectorTransform,
VectorTranslation,
)

__all__ = [
"Identity",
"PathScale",
"PathTranslation",
"ScaleTransform",
"TranslationTransform",
"VectorScale",
"VectorTransform",
"VectorTranslation",
]
16 changes: 16 additions & 0 deletions src/ome_zarr_models/_v05/image.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from pydantic_zarr.v2 import ArraySpec, GroupSpec

from ome_zarr_models._v05.base import BaseGroupv05, BaseOMEAttrs
from ome_zarr_models.v04.image import ImageAttrs

__all__ = ["Image", "ImageAttrs"]


class OMEImageAttrs(BaseOMEAttrs):
ome: ImageAttrs


class Image(GroupSpec[OMEImageAttrs, ArraySpec | GroupSpec], BaseGroupv05): # type: ignore[misc]
"""
An OME-Zarr image dataset.
"""
3 changes: 3 additions & 0 deletions src/ome_zarr_models/_v05/multiscales.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from ome_zarr_models.v04.multiscales import Dataset, Multiscale

__all__ = ["Dataset", "Multiscale"]
60 changes: 60 additions & 0 deletions tests/v05/data/image_example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"ome": {
"version": "0.5",
"multiscales": [
{
"name": "example",
"axes": [
{ "name": "t", "type": "time", "unit": "millisecond" },
{ "name": "c", "type": "channel" },
{ "name": "z", "type": "space", "unit": "micrometer" },
{ "name": "y", "type": "space", "unit": "micrometer" },
{ "name": "x", "type": "space", "unit": "micrometer" }
],
"datasets": [
{
"path": "0",
"coordinateTransformations": [
{
"type": "scale",
"scale": [1.0, 1.0, 0.5, 0.5, 0.5]
}
]
},
{
"path": "1",
"coordinateTransformations": [
{
"type": "scale",
"scale": [1.0, 1.0, 1.0, 1.0, 1.0]
}
]
},
{
"path": "2",
"coordinateTransformations": [
{
"type": "scale",
"scale": [1.0, 1.0, 2.0, 2.0, 2.0]
}
]
}
],
"coordinateTransformations": [
{
"type": "scale",
"scale": [0.1, 1.0, 1.0, 1.0, 1.0]
}
],
"type": "gaussian",
"metadata": {
"description": "the fields in metadata depend on the downscaling implementation. Here, the parameters passed to the skimage function are given",
"method": "skimage.transform.pyramid_gaussian",
"version": "0.16.1",
"args": "[true]",
"kwargs": { "multichannel": true }
}
}
]
}
}
62 changes: 62 additions & 0 deletions tests/v05/test_image.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
from ome_zarr_models._v05.axes import Axis
from ome_zarr_models._v05.coordinate_transformations import VectorScale
from ome_zarr_models._v05.image import Image, ImageAttrs
from ome_zarr_models._v05.multiscales import Dataset, Multiscale
from tests.v05.conftest import json_to_zarr_group


def test_image() -> None:
zarr_group = json_to_zarr_group(json_fname="image_example.json")
ome_group = Image.from_zarr(zarr_group)
assert ome_group.ome_attributes == ImageAttrs(
multiscales=[
Multiscale(
axes=[
Axis(name="t", type="time", unit="millisecond"),
Axis(name="c", type="channel", unit=None),
Axis(name="z", type="space", unit="micrometer"),
Axis(name="y", type="space", unit="micrometer"),
Axis(name="x", type="space", unit="micrometer"),
],
datasets=(
Dataset(
path="0",
coordinateTransformations=(
VectorScale(type="scale", scale=[1.0, 1.0, 0.5, 0.5, 0.5]),
),
),
Dataset(
path="1",
coordinateTransformations=(
VectorScale(type="scale", scale=[1.0, 1.0, 1.0, 1.0, 1.0]),
),
),
Dataset(
path="2",
coordinateTransformations=(
VectorScale(type="scale", scale=[1.0, 1.0, 2.0, 2.0, 2.0]),
),
),
),
version=None,
coordinateTransformations=(
VectorScale(type="scale", scale=[0.1, 1.0, 1.0, 1.0, 1.0]),
),
metadata={
"description": (
"the fields in metadata depend on the downscaling "
"implementation. Here, the parameters passed to the "
"skimage function are given"
),
"method": "skimage.transform.pyramid_gaussian",
"version": "0.16.1",
"args": "[true]",
"kwargs": {"multichannel": True},
},
name="example",
type="gaussian",
)
],
omero=None,
version="0.5",
)

0 comments on commit 82663a5

Please sign in to comment.