Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HCS: add Plate spec #56

Closed
wants to merge 2 commits into from
Closed
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
33 changes: 33 additions & 0 deletions ome_zarr/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import logging
from abc import ABC
from string import ascii_uppercase
from typing import Any, Dict, Iterator, List, Optional, Type, Union, cast

import dask.array as da
Expand Down Expand Up @@ -48,6 +49,8 @@ def __init__(
self.specs.append(Multiscales(self))
if OMERO.matches(zarr):
self.specs.append(OMERO(self))
if Plate.matches(zarr):
self.specs.append(Plate(self))

@property
def visible(self) -> bool:
Expand Down Expand Up @@ -336,6 +339,36 @@ def __init__(self, node: Node) -> None:
LOGGER.error(f"failed to parse metadata: {e}")


class Plate(Spec):
@staticmethod
def matches(zarr: BaseZarrLocation) -> bool:
return bool("plate" in zarr.root_attrs)

def __init__(self, node: Node) -> None:
super().__init__(node)
# TODO: start checking metadata version
self.plate_data = self.lookup("plate", {})
self.rows = self.plate_data.get("rows", 0)
self.cols = self.plate_data.get("columns", 0)

# FIXME: shouldn't hard code
self.acquisitions = ["PlateAcquisition Name 0"]
self.fields = ["Field_1", "Field_2", "Field_3", "Field_4"]
self.row_labels = ascii_uppercase[0 : self.rows]
self.col_labels = range(1, self.cols + 1)

visibility = True
for acq in self.acquisitions:
for row in self.row_labels:
for col in self.col_labels:
for field in self.fields:
path = f"{acq}/{row}/{col}/{field}"
child_zarr = self.zarr.create(path)
if child_zarr.exists():
node.add(child_zarr, visibility=visibility)
visibility = False


class Reader:
"""Parses the given Zarr instance into a collection of Nodes properly ordered
depending on context.
Expand Down