Skip to content

Commit 71bf2d0

Browse files
committed
Support other names than METADATA.ome.xml
1 parent 47ebb38 commit 71bf2d0

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/omero_zarr/extinfo.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616

1717
# Regex to match well positions (eg. A1)
1818
WELL_POS_RE = re.compile(r"(?P<row>\D+)(?P<col>\d+)")
19-
19+
# Regex to match the metadata.xml (could be any xml under xyz.zarr/ directory,
20+
# not only xyz.zarr/OME/METADATA.ome.xml)
21+
METADATA_XML_RE = re.compile(r".+\.zarr\/(.+\.xml)")
2022

2123
def get_extinfo(conn: BlitzGateway, image: ImageWrapper) -> ExternalInfoI:
2224
"""
@@ -186,19 +188,20 @@ def set_external_info(
186188
path = lsid
187189
else:
188190
path = _get_path(conn, img.id)
189-
if path.endswith("OME/METADATA.ome.xml"):
191+
if METADATA_XML_RE.match(path):
192+
metadata_xml = METADATA_XML_RE.match(path).group(1)
190193
if well:
191194
match = WELL_POS_RE.match(well)
192195
if match:
193196
col = match.group("col")
194197
row = match.group("row")
195-
path = path.replace("OME/METADATA.ome.xml", f"{row}")
198+
path = path.replace(metadata_xml, f"{row}")
196199
path = f"/{path}/{col}/{idx}"
197200
else:
198201
raise ValueError(f"Couldn't parse well position: {well}")
199202
else:
200203
series = img.getSeries()._val
201-
path = path.replace("OME/METADATA.ome.xml", f"{series}")
204+
path = path.replace(metadata_xml, f"{series}")
202205
path = f"/{path}"
203206
else:
204207
raise ValueError(

0 commit comments

Comments
 (0)