Skip to content

Commit

Permalink
Populate OMERO and top-level metadata in bf2raw Zarr image
Browse files Browse the repository at this point in the history
Pass -profile black to isort pre-commit to solve incompatibility when committing
  • Loading branch information
sbesson committed Aug 18, 2021
1 parent 91bf1a1 commit 0835e4f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ repos:
rev: 5.9.3
hooks:
- id: isort
args: ["--profile", "black"]

- repo: https://github.com/psf/black
rev: 21.7b0
Expand Down
20 changes: 19 additions & 1 deletion src/omero_zarr/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,16 @@
from omero.cli import CLI, BaseControl, Parser, ProxyStringType
from omero.gateway import BlitzGateway, BlitzObjectWrapper
from omero.model import ImageI, PlateI
from zarr.hierarchy import open_group
from zarr.storage import FSStore

from .masks import MASK_DTYPE_SIZE, image_shapes_to_zarr, plate_shapes_to_zarr
from .raw_pixels import image_to_zarr, plate_to_zarr
from .raw_pixels import (
add_omero_metadata,
add_toplevel_metadata,
image_to_zarr,
plate_to_zarr,
)

HELP = """Export data in zarr format.
Expand Down Expand Up @@ -306,6 +313,17 @@ def _bf_export(self, image: BlitzObjectWrapper, args: argparse.Namespace) -> Non
target.rmdir()
self.ctx.out(f"Image exported to {image_target.resolve()}")

# Add OMERO metadata
store = FSStore(
str(image_target.resolve()),
auto_mkdir=False,
normalize_keys=False,
mode="w",
)
root = open_group(store)
add_omero_metadata(root, image)
add_toplevel_metadata(root)


try:
register("zarr", ZarrControl, HELP) # type: ignore
Expand Down

0 comments on commit 0835e4f

Please sign in to comment.