Skip to content
Merged
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
13 changes: 1 addition & 12 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -e ".[test,dask-image,itk,cli]"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -e ".[test,dask-image,itk]"
python -m pip install itkwasm-image-io

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -e ".[test,dask-image,itk,cli]"
python -m pip install -e ".[test,dask-image,itk,cli,validate]"

- name: Test with pytest
if: ${{ matrix.os != 'ubuntu-22.04' && matrix.os != 'macos-14' }}
Expand Down
2 changes: 2 additions & 0 deletions ngff_zarr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from .to_multiscales import to_multiscales
from .to_ngff_image import to_ngff_image
from .to_ngff_zarr import to_ngff_zarr
from .validate import validate
from .zarr_metadata import (
AxesType,
SpatialDims,
Expand Down Expand Up @@ -51,6 +52,7 @@
"detect_cli_io_backend",
"ConversionBackend",
"cli_input_to_ngff_image",
"validate",
"Metadata",
"AxesType",
"SpatialDims",
Expand Down
6 changes: 6 additions & 0 deletions ngff_zarr/from_ngff_zarr.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,21 @@
from .ngff_image import NgffImage
from .to_multiscales import Multiscales
from .zarr_metadata import Axis, Dataset, Metadata, Scale, Translation
from .validate import validate as validate_ngff


def from_ngff_zarr(
store: Union[MutableMapping, str, Path, BaseStore],
validate: bool = False,
) -> Multiscales:
"""
Read an OME-Zarr NGFF Multiscales data structure from a Zarr store.

store : MutableMapping, str or Path, zarr.storage.BaseStore
Store or path to directory in file system.

validate : bool
If True, validate the NGFF metadata against the schema.

Returns
-------
Expand All @@ -29,6 +33,8 @@ def from_ngff_zarr(
"""

root = zarr.open_group(store, mode="r")
if validate:
validate_ngff(root.attrs.asdict())
metadata = root.attrs["multiscales"][0]

dims = [a["name"] for a in metadata["axes"]]
Expand Down
4 changes: 4 additions & 0 deletions ngff_zarr/spec/0.4/copyright.include
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Copyright © 2020-[YEAR]
<a href="https://www.openmicroscopy.org/"><abbr title="Open Microscopy Environment">OME</abbr></a><sup>®</sup>
(<a href="https://dundee.ac.uk/"><abbr title="University of Dundee">U. Dundee</abbr></a>).
OME trademark rules apply.
14 changes: 14 additions & 0 deletions ngff_zarr/spec/0.4/schemas/bf2raw.schema
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://ngff.openmicroscopy.org/latest/schemas/bf2raw.schema",
"title": "NGFF container produced by bioformats2raw",
"description": "JSON from OME-NGFF .zattrs",
"type": "object",
"properties": {
"bioformats2raw.layout": {
"description": "The top-level identifier metadata added by bioformats2raw",
"type": "number",
"enum": [3]
}
}
}
233 changes: 233 additions & 0 deletions ngff_zarr/spec/0.4/schemas/image.schema
Original file line number Diff line number Diff line change
@@ -0,0 +1,233 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://ngff.openmicroscopy.org/0.4/schemas/image.schema",
"title": "NGFF Image",
"description": "JSON from OME-NGFF .zattrs",
"type": "object",
"properties": {
"multiscales": {
"description": "The multiscale datasets for this image",
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"datasets": {
"type": "array",
"minItems": 1,
"items": {
"type": "object",
"properties": {
"path": {
"type": "string"
},
"coordinateTransformations": {
"$ref": "#/$defs/coordinateTransformations"
}
},
"required": ["path", "coordinateTransformations"]
}
},
"version": {
"type": "string",
"enum": [
"0.4"
]
},
"axes": {
"$ref": "#/$defs/axes"
},
"coordinateTransformations": {
"$ref": "#/$defs/coordinateTransformations"
}
},
"required": [
"datasets", "axes"
]
},
"minItems": 1,
"uniqueItems": true
},
"omero": {
"type": "object",
"properties": {
"channels": {
"type": "array",
"items": {
"type": "object",
"properties": {
"window": {
"type": "object",
"properties": {
"end": {
"type": "number"
},
"max": {
"type": "number"
},
"min": {
"type": "number"
},
"start": {
"type": "number"
}
},
"required": [
"start",
"min",
"end",
"max"
]
},
"label": {
"type": "string"
},
"family": {
"type": "string"
},
"color": {
"type": "string"
},
"active": {
"type": "boolean"
}
},
"required": [
"window",
"color"
]
}
}
},
"required": [
"channels"
]
}
},
"required": [ "multiscales" ],

"$defs": {
"axes": {
"type": "array",
"uniqueItems": true,
"minItems": 2,
"maxItems": 5,
"contains": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"type": {
"type": "string",
"enum": ["space"]
},
"unit": {
"type": "string"
}
}
},
"minContains": 2,
"maxContains": 3,
"items": {
"oneOf": [
{
"type": "object",
"properties": {
"name": {
"type": "string"
},
"type": {
"type": "string",
"enum": ["channel", "time", "space"]
}
},
"required": ["name", "type"]
},
{
"type": "object",
"properties": {
"name": {
"type": "string"
},
"type": {
"type": "string",
"not": {
"enum": ["space", "time", "channel"]
}
}
},
"required": ["name"]
}
]
}
},
"coordinateTransformations": {
"type": "array",
"minItems": 1,
"contains": {
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"scale"
]
},
"scale": {
"type": "array",
"minItems": 2,
"items": {
"type": "number"
}
}
}
},
"maxContains": 1,
"items": {
"oneOf": [
{
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"scale"
]
},
"scale": {
"type": "array",
"minItems": 2,
"items": {
"type": "number"
}
}
},
"required": ["type", "scale"]
},
{
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"translation"
]
},
"translation": {
"type": "array",
"minItems": 2,
"items": {
"type": "number"
}
}
},
"required": ["type", "translation"]
}
]
}
}
}
}
77 changes: 77 additions & 0 deletions ngff_zarr/spec/0.4/schemas/label.schema
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://ngff.openmicroscopy.org/0.4/schemas/label.schema",
"title": "OME-NGFF labelled image schema",
"description": "JSON from OME-NGFF .zattrs",
"type": "object",
"properties": {
"image-label": {
"type": "object",
"properties": {
"colors": {
"description": "The colors for this label image",
"type": "array",
"items": {
"type": "object",
"properties": {
"label-value": {
"description": "The value of the label",
"type": "number"
},
"rgba": {
"description": "The RGBA color stored as an array of four integers between 0 and 255",
"type": "array",
"items": {
"type": "integer",
"minimum": 0,
"maximum": 255
},
"minItems": 4,
"maxItems": 4
}
},
"required": [
"label-value"
]
},
"minItems": 1,
"uniqueItems": true
},
"properties": {
"description": "The properties for this label image",
"type": "array",
"items": {
"type": "object",
"properties": {
"label-value": {
"description": "The pixel value for this label",
"type": "integer"
}
},
"required": [
"label-value"
]
},
"minItems": 1,
"uniqueItems": true
},
"source": {
"description": "The source of this label image",
"type": "object",
"properties": {
"image": {
"type": "string"
}
}
},
"version": {
"description": "The version of the specification",
"type": "string",
"enum": [
"0.4"
]
}
}
}
}
}
Loading
Loading