Skip to content

Commit

Permalink
labels fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
ziw-liu committed Dec 7, 2024
1 parent ac0643b commit c6ac8ef
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations
from typing import TYPE_CHECKING

from pathlib import Path
from typing import TYPE_CHECKING

import numpy as np
from iohub import open_ome_zarr
Expand All @@ -17,6 +18,7 @@ def _build_hcs(
channel_names: list[str],
zyx_shape: tuple[int, int, int],
dtype: DTypeLike,
max_value: int | float,
):
dataset = open_ome_zarr(
path,
Expand All @@ -30,15 +32,17 @@ def _build_hcs(
pos = dataset.create_position(row, col, fov)
pos.create_image(
"0",
np.random.rand(2, len(channel_names), *zyx_shape).astype(dtype),
(
np.random.rand(2, len(channel_names), *zyx_shape) * max_value
).astype(dtype),
)


@fixture(scope="session")
def preprocessed_hcs_dataset(tmp_path_factory: TempPathFactory) -> Path:
"""Provides a preprocessed HCS OME-Zarr dataset."""
dataset_path = tmp_path_factory.mktemp("preprocessed.zarr")
_build_hcs(dataset_path, channel_names, (12, 256, 256), np.float32)
_build_hcs(dataset_path, channel_names, (12, 256, 256), np.float32, 1.0)
# U[0, 1)
expected = {"mean": 0.5, "std": 1 / np.sqrt(12), "median": 0.5, "iqr": 0.5}
norm_meta = {channel: {"dataset_statistics": expected} for channel in channel_names}
Expand All @@ -53,5 +57,13 @@ def preprocessed_hcs_dataset(tmp_path_factory: TempPathFactory) -> Path:
def small_hcs_dataset(tmp_path_factory: TempPathFactory) -> Path:
"""Provides a small, not preprocessed HCS OME-Zarr dataset."""
dataset_path = tmp_path_factory.mktemp("small.zarr")
_build_hcs(dataset_path, channel_names, (12, 64, 64), np.uint16)
_build_hcs(dataset_path, channel_names, (12, 64, 64), np.uint16, 1)
return dataset_path


@fixture(scope="function")
def labels_hcs_dataset(tmp_path_factory: TempPathFactory) -> Path:
"""Provides a small, not preprocessed HCS OME-Zarr dataset."""
dataset_path = tmp_path_factory.mktemp("labels.zarr")
_build_hcs(dataset_path, ["DAPI"], (2, 16, 16), np.uint16, 3)
return dataset_path

0 comments on commit c6ac8ef

Please sign in to comment.