Skip to content

Commit

Permalink
Add support for matching 1536 well names
Browse files Browse the repository at this point in the history
  • Loading branch information
jluethi committed Oct 8, 2024
1 parent 51b79a0 commit 026ea49
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/napari_ome_zarr_navigator/img_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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]

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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}
Expand Down
2 changes: 1 addition & 1 deletion src/napari_ome_zarr_navigator/roi_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 026ea49

Please sign in to comment.