diff --git a/pyproject.toml b/pyproject.toml index 65d30d95..5fc7fde0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -58,6 +58,11 @@ cov-report = [ "- coverage combine", "coverage report", ] +cov-html = [ + "test-cov", + "- coverage combine", + "coverage html", +] cov = [ "test-cov", "cov-report", diff --git a/src/faim_ipa/hcs/converter.py b/src/faim_ipa/hcs/converter.py index 59449d7a..32c07665 100644 --- a/src/faim_ipa/hcs/converter.py +++ b/src/faim_ipa/hcs/converter.py @@ -43,7 +43,6 @@ def __init__( self, ngff_plate: NGFFPlate, yx_binning: int = 1, - stitching_yx_chunk_size_factor: int = 1, warp_func: Callable = stitching_utils.translate_tiles_2d, fuse_func: Callable = stitching_utils.fuse_mean, client: Client = None, @@ -67,7 +66,6 @@ def __init__( ), "yx_binning must be an integer >= 1." self._ngff_plate = ngff_plate self._yx_binning = yx_binning - self._stitching_yx_chunk_size_factor = stitching_yx_chunk_size_factor self._warp_func = warp_func self._fuse_func = fuse_func self._client = client @@ -159,6 +157,7 @@ def run( plate, well_acquisition, well_sub_group, + add_to_well_images=not build_acquisition_mask, ) group = well_group[well_sub_group] self._write_stitched_image( @@ -365,11 +364,21 @@ def _stitch_well_image( ) return image_da - def _create_well_group(self, plate, well_acquisition, well_sub_group): + def _create_well_group( + self, plate, well_acquisition, well_sub_group, add_to_well_images=True + ): row, col = well_acquisition.get_row_col() well_group = plate.require_group(row).require_group(col) well_group.require_group(well_sub_group) - write_well_metadata(well_group, [{"path": well_sub_group}]) + if add_to_well_images: + zattrs = well_group.attrs.asdict() + if "well" in zattrs.keys() and "images" in zattrs["well"].keys(): + existing_images = well_group.attrs.asdict()["well"]["images"] + else: + existing_images = [] + write_well_metadata( + well_group, existing_images + [{"path": well_sub_group}] + ) return well_group @staticmethod diff --git a/tests/hcs/test_converter.py b/tests/hcs/test_converter.py index cd4662e6..1add6df9 100644 --- a/tests/hcs/test_converter.py +++ b/tests/hcs/test_converter.py @@ -181,6 +181,30 @@ def test__create_well_group(tmp_dir, plate_acquisition, hcs_plate): assert exists(join(tmp_dir, "plate_name.zarr", "D", "08", "0")) assert isinstance(well_group, zarr.Group) + mask_group = converter._create_well_group( + plate=zarr_plate, + well_acquisition=plate_acquisition.get_well_acquisitions()[0], + well_sub_group="0/mask", + add_to_well_images=False, + ) + assert exists(join(tmp_dir, "plate_name.zarr", "D", "08", "0", "mask")) + assert isinstance(mask_group, zarr.Group) + + assert mask_group.attrs.asdict()["well"]["images"] == [{"path": "0"}] + + another_group = converter._create_well_group( + plate=zarr_plate, + well_acquisition=plate_acquisition.get_well_acquisitions()[0], + well_sub_group="0/another", + add_to_well_images=True, + ) + assert exists(join(tmp_dir, "plate_name.zarr", "D", "08", "0", "another")) + assert isinstance(another_group, zarr.Group) + assert another_group.attrs.asdict()["well"]["images"] == [ + {"path": "0"}, + {"path": "0/another"}, + ] + def test__stitch_well_image_2d(tmp_dir, plate_acquisition_2d, hcs_plate): converter = ConvertToNGFFPlate(hcs_plate)