Skip to content

Commit

Permalink
Merge pull request #142 from fmi-faim/channel_metadata
Browse files Browse the repository at this point in the history
Add test for ImageXpress transmitted light
  • Loading branch information
imagejan authored Jun 18, 2024
2 parents fa082de + a42892e commit 39861ce
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ classifiers = [
dependencies = [
"pydantic",
"distributed",
"numpy",
"numpy<2",
"matplotlib",
"scikit-image",
"pandas",
Expand Down
Binary file not shown.
16 changes: 8 additions & 8 deletions src/faim_ipa/io/ChannelMetadata.py
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion src/faim_ipa/io/MetaSeriesTiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
32 changes: 32 additions & 0 deletions tests/io/test_ChannelMetadata.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 39861ce

Please sign in to comment.