diff --git a/pyometiff/omereader.py b/pyometiff/omereader.py index 954767f..58ff0a0 100755 --- a/pyometiff/omereader.py +++ b/pyometiff/omereader.py @@ -35,7 +35,7 @@ def __init__(self, self.fpath = Path(fpath) self.imageseries = imageseries - def read(self) -> (np.ndarray, dict, str): + def read(self) -> tuple[np.ndarray, dict, str]: self.array, self.omexml_string = self._open_tiff(self.fpath) self.metadata = self.parse_metadata(self.omexml_string) return self.array, self.metadata, self.omexml_string @@ -72,6 +72,10 @@ def parse_metadata(self, omexml_string): metadata["PhysicalSizeY"] = self.ox.image(self.imageseries).Pixels.PhysicalSizeY metadata["PhysicalSizeZ"] = self.ox.image(self.imageseries).Pixels.PhysicalSizeZ + # time increment + metadata["TimeIncrement"] = self.ox.image(self.imageseries).Pixels.TimeIncrement + metadata["TimeIncrementUnit"] = self.ox.image(self.imageseries).Pixels.TimeIncrementUnit + # physical size unit metadata["PhysicalSizeXUnit"] = self.ox.image( self.imageseries diff --git a/pyometiff/omewriter.py b/pyometiff/omewriter.py index 7e6f8dd..5ad6e24 100755 --- a/pyometiff/omewriter.py +++ b/pyometiff/omewriter.py @@ -173,6 +173,15 @@ def _dim_or_1(dim): pixels.set_SizeZ(_dim_or_1("Z")) pixels.set_SizeY(_dim_or_1("Y")) pixels.set_SizeX(_dim_or_1("X")) + + # time increment + time_increment = pop_expected_keys.get("TimeIncrement", None) + time_increment_unit = pop_expected_keys.get("TimeIncrementUnit", None) + + if time_increment is not None: + pixels.set_TimeIncrement(time_increment) + if time_increment_unit is not None: + pixels.set_TimeIncrementUnit(time_increment_unit) # this is reversed of what dimensionality of the ometiff file is saved as pixels.set_DimensionOrder(self._dimension_order[::-1]) diff --git a/pyometiff/omexml.py b/pyometiff/omexml.py index c3e86cb..acdcb5f 100755 --- a/pyometiff/omexml.py +++ b/pyometiff/omexml.py @@ -988,6 +988,24 @@ def set_SizeC(self, value: int) -> None: SizeC = property(get_SizeC, set_SizeC) + def get_TimeIncrement(self) -> float: + """The time increment between T planes""" + return get_float_attr(self.node, "TimeIncrement") + + def set_TimeIncrement(self, value: float) -> None: + self.node.set("TimeIncrement", str(value)) + + TimeIncrement = property(get_TimeIncrement, set_TimeIncrement) + + def get_TimeIncrementUnit(self) -> str: + """The unit of the time increment""" + return self.node.get("TimeIncrementUnit") + + def set_TimeIncrementUnit(self, value: str) -> None: + self.node.set("TimeIncrementUnit", value) + + TimeIncrementUnit = property(get_TimeIncrementUnit, set_TimeIncrementUnit) + def get_channel_count(self) -> int: """The number of channels in the image