Skip to content

Commit

Permalink
bring back create_name_plate_A01 for empty wells
Browse files Browse the repository at this point in the history
Co-authored-by: Silvia Barbiero <[email protected]>
Co-authored-by: Charlotte Soneson <[email protected]>
Co-authored-by: Michael Stadler <[email protected]>
  • Loading branch information
3 people committed Aug 22, 2024
1 parent 6ff305b commit f06f77e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/ez_zarr/ome_zarr.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"""

__all__ = ['Image', 'ImageList', 'create_name_row_col',
'import_plate']
'create_name_plate_A01', 'import_plate']
__version__ = '0.3.2'
__author__ = 'Silvia Barbiero, Michael Stadler, Charlotte Soneson'

Expand Down Expand Up @@ -42,6 +42,23 @@ def create_name_row_col(ri: int, ci: int) -> str:
"""
return f"{ri}_{ci}"

def create_name_plate_A01(ri: int, ci: int) -> str:
"""
Create name corresponding the wells in a microwell plate.
Parameters:
ri (int): Row index (1-based)
ci (int): Column index (1-based)
Returns:
str: Name (`ci` always using two digits, with pre-fixed zeros)
Examples:
>>> create_name_plate_A01(3, 4)
'C04'
"""
return f"{chr(ord('A') + ri - 1)}{ci:02}"

def import_plate(path: str, image_name: str = '0') -> "ImageList":
"""
Create an ImageList object from a OME-Zarr image set corresponding
Expand Down Expand Up @@ -115,7 +132,7 @@ def import_plate(path: str, image_name: str = '0') -> "ImageList":
# create ImageList object
imgL = ImageList(paths = img_paths, names = well_names,
layout=layout, nrow=nrow, ncol=ncol,
fallback_name_function=create_name_row_col)
fallback_name_function=create_name_plate_A01)

# return
return imgL
Expand Down
10 changes: 10 additions & 0 deletions tests/test_ome_zarr.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ def test_create_name_row_col():
assert ome_zarr.create_name_row_col(1, 2) == '1_2'
assert ome_zarr.create_name_row_col(3, 4) == '3_4'

def test_create_name_plate_A01():
"""Test `ome_zarr.create_name_plate_A01` function."""
with pytest.raises(Exception) as e_info:
ome_zarr.create_name_plate_A01(1)
with pytest.raises(Exception) as e_info:
ome_zarr.create_name_plate_A01(1, 2, 3)
assert ome_zarr.create_name_plate_A01(1, 2) == 'A02'
assert ome_zarr.create_name_plate_A01(3, 4) == 'C04'
assert ome_zarr.create_name_plate_A01(5, 11) == 'E11'

def test_import_plate(tmpdir: str):
"""Test `import_plate` function."""
with pytest.raises(Exception) as e_info:
Expand Down

0 comments on commit f06f77e

Please sign in to comment.