Skip to content

Commit

Permalink
reader handles axes as None, List of str or List of dict
Browse files Browse the repository at this point in the history
  • Loading branch information
will-moore committed Oct 28, 2021
1 parent 9ba63a6 commit c8b80bc
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions ome_zarr/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,17 +275,14 @@ def matches(zarr: ZarrLocation) -> bool:
def __init__(self, node: Node) -> None:
super().__init__(node)

axes_values = {"t", "c", "z", "y", "x"}
try:
multiscales = self.lookup("multiscales", [])
version = multiscales[0].get(
"version", "0.1"
) # should this be matched with Format.version?
datasets = multiscales[0]["datasets"]
# axes field was introduced in 0.3, before all data was 5d
axes = tuple(multiscales[0].get("axes", ["t", "c", "z", "y", "x"]))
if len(set(axes) - axes_values) > 0:
raise RuntimeError(f"Invalid axes names: {set(axes) - axes_values}")
axes = multiscales[0].get("axes")
# TODO - convert each axis to dictionary (if str or None)?
node.metadata["axes"] = axes
datasets = [d["path"] for d in datasets]
self.datasets: List[str] = datasets
Expand All @@ -301,6 +298,10 @@ def __init__(self, node: Node) -> None:
for c in data.chunks
]
LOGGER.info("resolution: %s", resolution)
if axes is not None:
axes = tuple(
axis if isinstance(axis, str) else axis.get("name") for axis in axes
)
LOGGER.info(" - shape %s = %s", axes, data.shape)
LOGGER.info(" - chunks = %s", chunk_sizes)
LOGGER.info(" - dtype = %s", data.dtype)
Expand Down

0 comments on commit c8b80bc

Please sign in to comment.