Skip to content

Commit 1772f98

Browse files
committed
Enable custom path also for plates
1 parent 71bf2d0 commit 1772f98

File tree

2 files changed

+31
-25
lines changed

2 files changed

+31
-25
lines changed

src/omero_zarr/cli.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -325,10 +325,10 @@ def _configure(self, parser: Parser) -> None:
325325
help="Set the ExternalInfo path",
326326
)
327327
extinfo.add_argument(
328-
"--lsid",
328+
"--zarrPath",
329329
default=None,
330330
help=(
331-
"Use a specific lsid (path) (default: Determine from "
331+
"Use a specific path (default: Determine from "
332332
"clientPath) (only used in combination with --set)"
333333
),
334334
)
@@ -424,7 +424,7 @@ def extinfo(self, args: argparse.Namespace) -> None:
424424
img,
425425
well,
426426
idx,
427-
args.lsid,
427+
args.zarrPath,
428428
args.entityType,
429429
int(args.entityId),
430430
)

src/omero_zarr/extinfo.py

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def set_external_info(
155155
img: ImageI,
156156
well: str,
157157
idx: int,
158-
lsid: str,
158+
overwrite_path: str,
159159
entityType: str,
160160
entityId: int
161161
) -> ImageI:
@@ -167,8 +167,8 @@ def set_external_info(
167167
img (ImageI): OMERO image
168168
well (str | None): Optional well position (e.g. 'A1')
169169
idx (int | None): Optional well sample / field index
170-
lsid (str | None): Optional custom LSID path. If None, path is
171-
derived from image's clientpath
170+
overwrite_path (str | None): Optional custom path. If None, path is
171+
derived from image's clientpath.
172172
entityType (str | None): Optional entity type. Defaults to
173173
'com.glencoesoftware.ngff:multiscales'
174174
entityId (int | None): Optional entity ID. Defaults to 3
@@ -184,30 +184,36 @@ def set_external_info(
184184
entityType = "com.glencoesoftware.ngff:multiscales"
185185
if not entityId:
186186
entityId = 3
187-
if lsid:
188-
path = lsid
187+
188+
img_path = _get_path(conn, img.id)
189+
if overwrite_path:
190+
if not overwrite_path.endswith("/"):
191+
path = f"{overwrite_path}/"
192+
else:
193+
path = overwrite_path
189194
else:
190-
path = _get_path(conn, img.id)
191-
if METADATA_XML_RE.match(path):
192-
metadata_xml = METADATA_XML_RE.match(path).group(1)
193-
if well:
194-
match = WELL_POS_RE.match(well)
195-
if match:
196-
col = match.group("col")
197-
row = match.group("row")
198-
path = path.replace(metadata_xml, f"{row}")
199-
path = f"/{path}/{col}/{idx}"
200-
else:
201-
raise ValueError(f"Couldn't parse well position: {well}")
202-
else:
203-
series = img.getSeries()._val
204-
path = path.replace(metadata_xml, f"{series}")
205-
path = f"/{path}"
195+
if METADATA_XML_RE.match(img_path):
196+
metadata_xml = METADATA_XML_RE.match(img_path).group(1)
197+
path = img_path.replace(metadata_xml,"")
198+
path = f"/{path}"
206199
else:
207200
raise ValueError(
208-
f"Doesn't seem to be an ome.zarr: {path}"
201+
f"Doesn't seem to be an ome.zarr: {img_path}"
209202
)
210203

204+
if well:
205+
match = WELL_POS_RE.match(well)
206+
if match:
207+
col = match.group("col")
208+
row = match.group("row")
209+
path = f"{path}{row}/{col}/{idx}"
210+
else:
211+
raise ValueError(f"Couldn't parse well position: {well}")
212+
else:
213+
series = img.getSeries()._val
214+
path = f"{path}{series}"
215+
216+
211217
info = ExternalInfoI()
212218
info.entityType = rstring(entityType)
213219
info.entityId = rlong(entityId)

0 commit comments

Comments
 (0)