From 026ea49e5f68034fcaa13e12b7f4f647553e1e3a Mon Sep 17 00:00:00 2001 From: jluethi Date: Tue, 8 Oct 2024 09:38:45 +0200 Subject: [PATCH] Add support for matching 1536 well names --- src/napari_ome_zarr_navigator/img_browser.py | 12 ++++++------ src/napari_ome_zarr_navigator/roi_loader.py | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/napari_ome_zarr_navigator/img_browser.py b/src/napari_ome_zarr_navigator/img_browser.py index f1ad904..c3b5271 100644 --- a/src/napari_ome_zarr_navigator/img_browser.py +++ b/src/napari_ome_zarr_navigator/img_browser.py @@ -218,7 +218,7 @@ def filter_df(self): def load_roi(self): matches = [ - re.match(r"([A-Z]+)(\d+)", well) for well in self.well.value + re.match(r"([A-Z][a-z]*)(\d+)", well) for well in self.well.value ] row_alpha = [m.group(1) for m in matches] col_str = [m.group(2) for m in matches] @@ -248,7 +248,7 @@ def load_roi(self): def load_default_roi(self): matches = [ - re.match(r"([A-Z]+)(\d+)", well) for well in self.well.value + re.match(r"([A-Z][a-z]*)(\d+)", well) for well in self.well.value ] wells = [(m.group(1), m.group(2)) for m in matches] @@ -282,13 +282,13 @@ def load_default_roi(self): def go_to_well(self): matches = [ - re.match(r"([A-Z]+)(\d+)", well) for well in self.well.value + re.match(r"([A-Z][a-z]*)(\d+)", well) for well in self.well.value ] wells = [(m.group(1), m.group(2)) for m in matches] for layer in self.viewer.layers: if type(layer) == napari.layers.Shapes and re.match( - r"([A-Z]+)(\d+)", layer.name + r"([a-z]*)(\d+)", layer.name ): self.viewer.layers.remove(layer) @@ -424,12 +424,12 @@ def _validate_wells( """ if wells is not None: wells = [wells] if isinstance(wells, str) else wells - matches = [re.match(r"([A-Z]+)(\d+)", well) for well in wells] + matches = [re.match(r"([A-Z][a-z]*)(\d+)", well) for well in wells] wells = {(m.group(1), m.group(2)) for m in matches} else: with zarr.open(zarr_url) as metadata: matches = [ - re.match(r"([A-Z]+)/(\d+)", well["path"]) + re.match(r"([A-Z][a-z]*)/(\d+)", well["path"]) for well in metadata.attrs["plate"]["wells"] ] wells = {(m.group(1), m.group(2)) for m in matches} diff --git a/src/napari_ome_zarr_navigator/roi_loader.py b/src/napari_ome_zarr_navigator/roi_loader.py index db43b31..57e8560 100644 --- a/src/napari_ome_zarr_navigator/roi_loader.py +++ b/src/napari_ome_zarr_navigator/roi_loader.py @@ -545,6 +545,6 @@ def remove_existing_label_layers(viewer): for layer in viewer.layers: # FIXME: Generalize well name catching if type(layer) == napari.layers.Labels and re.match( - r"[A-Z]\d+_*", layer.name + r"[A-Z][a-z]*\d+_*", layer.name ): viewer.layers.remove(layer)