From 7a811ab20c7bff2284b97369ed9afd21bd7e082f Mon Sep 17 00:00:00 2001 From: lorenzo Date: Fri, 4 Oct 2024 17:29:28 +0200 Subject: [PATCH] add masking roi tables to table group --- src/ngio/tables/tables_group.py | 11 +---------- src/ngio/tables/v1/__init__.py | 3 ++- src/ngio/tables/v1/masking_roi_tables.py | 2 +- tests/tables/test_table_group.py | 14 +++++++++++++- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/ngio/tables/tables_group.py b/src/ngio/tables/tables_group.py index 6f670be..05eb9aa 100644 --- a/src/ngio/tables/tables_group.py +++ b/src/ngio/tables/tables_group.py @@ -9,16 +9,7 @@ from ngio.io import StoreLike from ngio.pydantic_utils import BaseWithExtraFields -from ngio.tables.v1 import FeatureTableV1, ROITableV1 - - -class MaskingROITableV1: - """Placeholder for Masking ROI Table V1.""" - - def __init__(self, group: zarr.Group) -> None: - """Initialize the class from an existing group.""" - raise NotImplementedError("Masking ROI Table V1 not implemented.") - +from ngio.tables.v1 import FeatureTableV1, MaskingROITableV1, ROITableV1 ROITable = ROITableV1 IMPLEMENTED_ROI_TABLES = {"1": ROITableV1} diff --git a/src/ngio/tables/v1/__init__.py b/src/ngio/tables/v1/__init__.py index 1f2ffba..05e4794 100644 --- a/src/ngio/tables/v1/__init__.py +++ b/src/ngio/tables/v1/__init__.py @@ -1,6 +1,7 @@ """This module contains the objects to handle the fractal tables V1.""" from ngio.tables.v1.feature_tables import FeatureTableV1 +from ngio.tables.v1.masking_roi_tables import MaskingROITableV1 from ngio.tables.v1.roi_tables import ROITableV1 -__all__ = ["ROITableV1", "FeatureTableV1"] +__all__ = ["ROITableV1", "FeatureTableV1", "MaskingROITableV1"] diff --git a/src/ngio/tables/v1/masking_roi_tables.py b/src/ngio/tables/v1/masking_roi_tables.py index 64cd287..4ccbb42 100644 --- a/src/ngio/tables/v1/masking_roi_tables.py +++ b/src/ngio/tables/v1/masking_roi_tables.py @@ -19,7 +19,7 @@ class MaskingROITableV1Meta(BaseModel): """Metadata for the ROI table.""" fractal_table_version: Literal["1"] = "1" - type: Literal["roi_table"] = "masking_roi_table" + type: Literal["masking_roi_table"] = "masking_roi_table" region: dict[Literal["path"], str] instance_key: str = "label" diff --git a/tests/tables/test_table_group.py b/tests/tables/test_table_group.py index dc57426..3926fc0 100644 --- a/tests/tables/test_table_group.py +++ b/tests/tables/test_table_group.py @@ -17,6 +17,18 @@ def test_table_group(self, ome_zarr_image_v04_path): overwrite=False, ) - assert ngff_image.table.list() == ["feat_table", "roi_table"] + ngff_image.table.new( + name="masking_roi_table", + table_type="masking_roi_table", + label_image="region", + overwrite=False, + ) + + assert ngff_image.table.list() == [ + "feat_table", + "roi_table", + "masking_roi_table", + ] assert ngff_image.table.list(type="roi_table") == ["roi_table"] assert ngff_image.table.list(type="feature_table") == ["feat_table"] + assert ngff_image.table.list(type="masking_roi_table") == ["masking_roi_table"]