diff --git a/pyproject.toml b/pyproject.toml index ea798241..98a9a57a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,7 +27,7 @@ classifiers = [ dependencies = [ "pydantic", "distributed", - "numpy", + "numpy<2", "matplotlib", "scikit-image", "pandas", diff --git a/resources/ImageXpress/exp126-d0_C03_thumbA6B0784C-19ED-4F35-9E6A-0A306794BB11.tif b/resources/ImageXpress/exp126-d0_C03_thumbA6B0784C-19ED-4F35-9E6A-0A306794BB11.tif new file mode 100644 index 00000000..aa01e518 Binary files /dev/null and b/resources/ImageXpress/exp126-d0_C03_thumbA6B0784C-19ED-4F35-9E6A-0A306794BB11.tif differ diff --git a/src/faim_ipa/io/ChannelMetadata.py b/src/faim_ipa/io/ChannelMetadata.py index 94a55743..451c9473 100644 --- a/src/faim_ipa/io/ChannelMetadata.py +++ b/src/faim_ipa/io/ChannelMetadata.py @@ -1,17 +1,17 @@ -from typing import Optional, Union +from typing import Optional -from pydantic import BaseModel, NonNegativeInt, PositiveFloat, PositiveInt +from pydantic import BaseModel, NonNegativeInt, PositiveFloat class ChannelMetadata(BaseModel): channel_index: NonNegativeInt channel_name: str display_color: str - spatial_calibration_x: float - spatial_calibration_y: float + spatial_calibration_x: PositiveFloat + spatial_calibration_y: PositiveFloat spatial_calibration_units: str - z_spacing: Optional[PositiveFloat] - wavelength: Union[PositiveInt, str] - exposure_time: Optional[PositiveFloat] - exposure_time_unit: Optional[str] + z_spacing: Optional[PositiveFloat] = None + wavelength: NonNegativeInt + exposure_time: Optional[PositiveFloat] = None + exposure_time_unit: Optional[str] = None objective: str diff --git a/src/faim_ipa/io/MetaSeriesTiff.py b/src/faim_ipa/io/MetaSeriesTiff.py index 5dedcf66..efc2c39e 100644 --- a/src/faim_ipa/io/MetaSeriesTiff.py +++ b/src/faim_ipa/io/MetaSeriesTiff.py @@ -4,7 +4,7 @@ from tifffile import tifffile -def load_metaseries_tiff_metadata(path: Path) -> tuple[ArrayLike, dict]: +def load_metaseries_tiff_metadata(path: Path) -> dict: """Load parts of the metadata of a metaseries tiff file. The following metadata is collected: diff --git a/tests/io/test_ChannelMetadata.py b/tests/io/test_ChannelMetadata.py new file mode 100644 index 00000000..5dbd0c83 --- /dev/null +++ b/tests/io/test_ChannelMetadata.py @@ -0,0 +1,32 @@ +from faim_ipa.io.MetaSeriesTiff import load_metaseries_tiff_metadata +from faim_ipa.io.ChannelMetadata import ChannelMetadata + +from pathlib import Path +import pytest + + +@pytest.fixture +def transmission_sample_image_path(): + return ( + Path(__file__).parent.parent.parent + / "resources" + / "ImageXpress" + / "exp126-d0_C03_thumbA6B0784C-19ED-4F35-9E6A-0A306794BB11.tif" + ) + + +def test_transmission_metadata(transmission_sample_image_path): + metadata = load_metaseries_tiff_metadata(transmission_sample_image_path) + channel_metadata = ChannelMetadata( + channel_index=0, + channel_name="test_channel", + display_color="FFFFFF", + spatial_calibration_x=metadata["spatial-calibration-x"], + spatial_calibration_y=metadata["spatial-calibration-y"], + spatial_calibration_units=metadata["spatial-calibration-units"], + objective="4x", + **metadata, + ) + assert channel_metadata.spatial_calibration_x == 43.3613 + assert channel_metadata.spatial_calibration_y == 54.2016 + assert channel_metadata.wavelength == 0