From 8dc1bede8231c5290ff8fff458a6b41909119f25 Mon Sep 17 00:00:00 2001 From: jluethi Date: Tue, 1 Oct 2024 16:20:52 +0200 Subject: [PATCH] Add initial version of calculate_well_positions with optional plate translation --- src/napari_ome_zarr_navigator/util.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/napari_ome_zarr_navigator/util.py b/src/napari_ome_zarr_navigator/util.py index f96676c..6589bc1 100644 --- a/src/napari_ome_zarr_navigator/util.py +++ b/src/napari_ome_zarr_navigator/util.py @@ -56,7 +56,7 @@ def add_features_to_labels( pass -def calculate_well_positions(plate_url, row, col): +def calculate_well_positions(plate_url, row, col, plate=True): dataset = 0 level = 0 zarr_url = f"{plate_url}/{row}/{col}/{dataset}" @@ -70,10 +70,16 @@ def calculate_well_positions(plate_url, row, col): row = rows.index(row) col = cols.index(col) - top_left_corner = [row * scale[0] * shape[0], col * scale[1] * shape[1]] + if plate: + top_left_corner = [ + row * scale[0] * shape[0], + col * scale[1] * shape[1], + ] + else: + top_left_corner = [0, 0] bottom_right_corner = [ - (row + 1) * scale[0] * shape[0], - (col + 1) * scale[1] * shape[1], + top_left_corner[0] + scale[0] * shape[0], + top_left_corner[1] + scale[1] * shape[1], ] return top_left_corner, bottom_right_corner