From 0d365183023d0afb4a87b14bfec14bf5442e4883 Mon Sep 17 00:00:00 2001 From: BrianWhitneyAI Date: Wed, 24 Jul 2024 10:30:13 -0700 Subject: [PATCH 1/2] feature/time_interval --- bioio_base/image_container.py | 7 ++++++- bioio_base/reader.py | 18 +++++++++++++++++- bioio_base/test_utilities.py | 4 ++++ bioio_base/types.py | 4 ++++ 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/bioio_base/image_container.py b/bioio_base/image_container.py index 69d7736..1306c9e 100644 --- a/bioio_base/image_container.py +++ b/bioio_base/image_container.py @@ -9,7 +9,7 @@ import xarray as xr from .dimensions import Dimensions -from .types import ImageLike, PhysicalPixelSizes +from .types import ImageLike, PhysicalPixelSizes, TimeInterval ############################################################################### @@ -119,3 +119,8 @@ def channel_names(self) -> Optional[List[str]]: @abstractmethod def physical_pixel_sizes(self) -> PhysicalPixelSizes: pass + + @property + @abstractmethod + def time_interval(self) -> TimeInterval: + pass diff --git a/bioio_base/reader.py b/bioio_base/reader.py index f32a5b1..6637a3c 100644 --- a/bioio_base/reader.py +++ b/bioio_base/reader.py @@ -15,7 +15,7 @@ from .dimensions import DEFAULT_DIMENSION_ORDER, DimensionNames, Dimensions from .image_container import ImageContainer from .io import pathlike_to_fs -from .types import PhysicalPixelSizes +from .types import PhysicalPixelSizes, TimeInterval ############################################################################### @@ -863,6 +863,22 @@ def physical_pixel_sizes(self) -> PhysicalPixelSizes: """ return PhysicalPixelSizes(None, None, None) + @property + def time_interval(self) -> TimeInterval: + """ + Returns + ------- + sizes: PhysicalPixelSizes + Using available metadata, the floats representing physical pixel sizes for + dimensions Z, Y, and X. + + Notes + ----- + We currently do not handle unit attachment to these values. Please see the file + metadata for unit information. + """ + return TimeInterval(None) + def get_mosaic_tile_position( self, mosaic_tile_index: int, **kwargs: int ) -> Tuple[int, int]: diff --git a/bioio_base/test_utilities.py b/bioio_base/test_utilities.py index 600db4c..19acb83 100644 --- a/bioio_base/test_utilities.py +++ b/bioio_base/test_utilities.py @@ -66,6 +66,7 @@ def run_image_container_checks( expected_physical_pixel_sizes: Tuple[ Optional[float], Optional[float], Optional[float] ], + expected_time_interval: Tuple[Optional[float]], expected_metadata_type: Union[type, Tuple[Union[type, Tuple[Any, ...]], ...]], set_resolution_level: int = 0, expected_current_resolution_level: int = 0, @@ -99,6 +100,7 @@ def run_image_container_checks( assert image_container.dims.shape == expected_shape assert image_container.channel_names == expected_channel_names assert image_container.physical_pixel_sizes == expected_physical_pixel_sizes + assert image_container.time_interval == expected_time_interval assert isinstance(image_container.metadata, expected_metadata_type) # Read different chunks @@ -167,6 +169,7 @@ def run_image_file_checks( expected_physical_pixel_sizes: Tuple[ Optional[float], Optional[float], Optional[float] ], + expected_time_interval: Tuple[Optional[float]], expected_metadata_type: Union[type, Tuple[Union[type, Tuple[Any, ...]], ...]], set_resolution_level: int = 0, expected_current_resolution_level: int = 0, @@ -192,6 +195,7 @@ def run_image_file_checks( expected_dims_order=expected_dims_order, expected_channel_names=expected_channel_names, expected_physical_pixel_sizes=expected_physical_pixel_sizes, + expected_time_interval=expected_time_interval, expected_metadata_type=expected_metadata_type, ) diff --git a/bioio_base/types.py b/bioio_base/types.py index 78d76b1..c5c50aa 100644 --- a/bioio_base/types.py +++ b/bioio_base/types.py @@ -24,3 +24,7 @@ class PhysicalPixelSizes(NamedTuple): Z: Optional[float] Y: Optional[float] X: Optional[float] + + +class TimeInterval(NamedTuple): + T: Optional[float] From 4593c26c4a010d277dfa89100568fa51cb474e68 Mon Sep 17 00:00:00 2001 From: BrianWhitneyAI Date: Wed, 24 Jul 2024 10:39:06 -0700 Subject: [PATCH 2/2] update docstring --- bioio_base/reader.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bioio_base/reader.py b/bioio_base/reader.py index 6637a3c..65eed85 100644 --- a/bioio_base/reader.py +++ b/bioio_base/reader.py @@ -868,9 +868,9 @@ def time_interval(self) -> TimeInterval: """ Returns ------- - sizes: PhysicalPixelSizes - Using available metadata, the floats representing physical pixel sizes for - dimensions Z, Y, and X. + sizes: Time Interval + Using available metadata, the floats representing time interval sizes for + dimension T. Notes -----