Skip to content

Commit 03bde3a

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent f01f471 commit 03bde3a

File tree

3 files changed

+26
-29
lines changed

3 files changed

+26
-29
lines changed

.isort.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[settings]
2-
known_third_party = dask,numpy,ome_zarr,omero,omero_zarr,setuptools,skimage,zarr
2+
known_third_party = dask,numpy,ome_zarr,omero,omero_sys_ParametersI,omero_zarr,setuptools,skimage,zarr

src/omero_zarr/cli.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
from zarr.hierarchy import open_group
3030
from zarr.storage import FSStore
3131

32+
from .extinfo import get_images, set_external_info
3233
from .masks import (
3334
MASK_DTYPE_SIZE,
3435
MaskSaver,
@@ -41,10 +42,6 @@
4142
image_to_zarr,
4243
plate_to_zarr,
4344
)
44-
from .extinfo import (
45-
get_images,
46-
set_external_info,
47-
)
4845

4946
HELP = """Export data in zarr format.
5047
@@ -114,6 +111,7 @@
114111

115112
EXTINFO_HELP = """Set the external info path for an ome.zarr image."""
116113

114+
117115
def gateway_required(func: Callable) -> Callable:
118116
"""
119117
Decorator which initializes a client (self.client),
@@ -290,9 +288,9 @@ def _configure(self, parser: Parser) -> None:
290288
)
291289

292290
exinfo = parser.add(sub, self.extinfo, EXTINFO_HELP)
293-
exinfo.add_argument("object",
294-
type=ProxyStringType(),
295-
help="Object in Class:ID format")
291+
exinfo.add_argument(
292+
"object", type=ProxyStringType(), help="Object in Class:ID format"
293+
)
296294

297295
for subcommand in (polygons, masks, export):
298296
subcommand.add_argument(
@@ -352,10 +350,13 @@ def extinfo(self, args: argparse.Namespace) -> None:
352350
try:
353351
img = set_external_info(self.gateway, img, well, idx)
354352
img = self.gateway.getUpdateService().saveAndReturnObject(img)
355-
self.ctx.out(f"Set path to '{img.details.externalInfo.lsid._val}' for image {img.id._val}")
353+
self.ctx.out(
354+
f"Set path to '{img.details.externalInfo.lsid._val}' for image {img.id._val}"
355+
)
356356
except Exception as e:
357-
self.ctx.err(f"Failed to set external info for image {img.id._val}: {e}")
358-
357+
self.ctx.err(
358+
f"Failed to set external info for image {img.id._val}: {e}"
359+
)
359360

360361
def _lookup(
361362
self, gateway: BlitzGateway, otype: str, oid: int

src/omero_zarr/extinfo.py

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
1-
from omero.gateway import BlitzGateway
2-
from omero.gateway import BlitzObjectWrapper
3-
from omero.model import ExternalInfoI, ImageI
4-
from omero.rtypes import rstring, rlong
5-
from omero_sys_ParametersI import ParametersI
6-
from omero.model import Image
7-
from omero.model import Plate
8-
from omero.model import Screen
9-
from omero.model import Dataset
10-
from omero.model import Project
111
import re
122

3+
from omero.gateway import BlitzGateway, BlitzObjectWrapper
4+
from omero.model import Dataset, ExternalInfoI, Image, ImageI, Plate, Project, Screen
5+
from omero.rtypes import rlong, rstring
6+
from omero_sys_ParametersI import ParametersI
137

148
# Regex to match well positions (eg. A1)
159
WELL_POS_RE = re.compile(r"(?P<row>\D+)(?P<col>\d+)")
@@ -65,7 +59,9 @@ def _lookup(conn: BlitzGateway, type: str, oid: int) -> BlitzObjectWrapper:
6559
return obj
6660

6761

68-
def get_images(conn: BlitzGateway, object) -> tuple[BlitzObjectWrapper, str | None, int | None]:
62+
def get_images(
63+
conn: BlitzGateway, object
64+
) -> tuple[BlitzObjectWrapper, str | None, int | None]:
6965
"""
7066
Generator that yields images from any OMERO container object.
7167
@@ -117,30 +113,30 @@ def get_images(conn: BlitzGateway, object) -> tuple[BlitzObjectWrapper, str | No
117113
def set_external_info(conn: BlitzGateway, img: ImageI, well: str, idx: int) -> ImageI:
118114
"""
119115
Set external info for an image to enable omero zarr pixel buffer handling.
120-
116+
121117
This function configures an image for use with the omero-zarr-pixel-buffer by:
122118
1. Retrieving the original file path
123119
2. Converting it to point to the 5d multiscale image directory
124120
3. Setting up the external info with the path and metadata
125-
121+
126122
For plate-based images (with wells), the path structure follows:
127123
/<base_path>/<row>/<column>/<field index>
128-
124+
129125
For regular images:
130126
/<base_path>/0
131-
127+
132128
Args:
133129
conn (BlitzGateway): Active OMERO gateway connection
134130
img (ImageI): OMERO image object to modify
135131
well (str): Well position (e.g., 'A1', 'B2') for plate-based images, or None
136132
idx (int): Well sample / field index for plate-based images, or None
137-
133+
138134
Returns:
139135
ImageI: Modified image object with updated external info
140-
136+
141137
Raises:
142138
ValueError: If the image path is not an OME-Zarr format or if well position is invalid
143-
139+
144140
Note:
145141
The external info is configured with entity type 'com.glencoesoftware.ngff:multiscales'
146142
and entity ID 3, which are required by the omero-zarr-pixel-buffer.

0 commit comments

Comments
 (0)