From ffbae6a3f6b831894d04a92ab753d2223dd9a48b Mon Sep 17 00:00:00 2001 From: Jan Eglinger Date: Tue, 18 Jun 2024 13:35:33 +0200 Subject: [PATCH 1/2] Pin to numpy<2 With numpy 2.0.0, we get errors like: ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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", From a42892e7b22ba431379fab35c7e52405324e2673 Mon Sep 17 00:00:00 2001 From: Jan Eglinger Date: Tue, 18 Jun 2024 13:26:48 +0200 Subject: [PATCH 2/2] Add test for ImageXpress transmitted light When using transmitted light acquisition, the "wavelength" metadata gets set to "0.0". While fix ChannelMetadata to account for this, we also disallow 'str' to make behavior consistent between Windows and Linux. (Previously, we got 0.0 [float] on Linux and "0.0" [str] on Windows.) --- ...mbA6B0784C-19ED-4F35-9E6A-0A306794BB11.tif | Bin 0 -> 15802 bytes src/faim_ipa/io/ChannelMetadata.py | 16 ++++----- src/faim_ipa/io/MetaSeriesTiff.py | 2 +- tests/io/test_ChannelMetadata.py | 32 ++++++++++++++++++ 4 files changed, 41 insertions(+), 9 deletions(-) create mode 100644 resources/ImageXpress/exp126-d0_C03_thumbA6B0784C-19ED-4F35-9E6A-0A306794BB11.tif create mode 100644 tests/io/test_ChannelMetadata.py 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 0000000000000000000000000000000000000000..aa01e51840f2f7f9946f98a09f63253fe9f399db GIT binary patch literal 15802 zcmbt*1$&GjTL9ko^Pu`z?eh7B1E*I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KIdm}Jw$g#!#HUCEP*s0Iix+7O 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