From c6ac8efd37ae60ed085eae49182dcc4a44cda493 Mon Sep 17 00:00:00 2001 From: Ziwen Liu Date: Fri, 6 Dec 2024 21:09:32 -0800 Subject: [PATCH] labels fixture --- tests/conftest.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 3b0c9327..b6e9e68c 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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 @@ -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, @@ -30,7 +32,9 @@ 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), ) @@ -38,7 +42,7 @@ def _build_hcs( 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} @@ -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