Skip to content

Commit

Permalink
mobie: expand test to cover add_labels_view
Browse files Browse the repository at this point in the history
  • Loading branch information
imagejan committed Oct 16, 2023
1 parent d88b6eb commit ba86e32
Showing 1 changed file with 47 additions and 8 deletions.
55 changes: 47 additions & 8 deletions tests/test_mobie.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,16 @@
)
from mobie.metadata.project_metadata import add_dataset, create_project_metadata
from mobie.validation import validate_project
from skimage.measure import label

from faim_hcs.io.MolecularDevicesImageXpress import parse_single_plane_multi_fields
from faim_hcs.MetaSeriesUtils import get_well_image_CYX
from faim_hcs.mobie import add_wells_to_project
from faim_hcs.Zarr import build_zarr_scaffold, write_cyx_image_to_well
from faim_hcs.mobie import add_labels_view, add_wells_to_project
from faim_hcs.Zarr import (
build_zarr_scaffold,
write_cyx_image_to_well,
write_labels_to_group,
)

ROOT_DIR = Path(__file__).parent.parent

Expand All @@ -23,7 +28,12 @@ def files():


@pytest.fixture
def zarr_group(files, zarr_dir):
def threshold():
return 10000


@pytest.fixture
def zarr_group(files, zarr_dir, threshold):
plate = build_zarr_scaffold(
root_dir=zarr_dir,
files=files,
Expand All @@ -39,6 +49,12 @@ def zarr_group(files, zarr_dir):
)
field = plate[well[0]][str(int(well[1:]))][0]
write_cyx_image_to_well(img, hists, ch_metadata, metadata, field)
labels = label(img > threshold)
write_labels_to_group(
labels=labels,
labels_name="simple_threshold",
parent_group=field,
)
return plate


Expand All @@ -52,7 +68,7 @@ def zarr_dir(tmp_path_factory):
return tmp_path_factory.mktemp("zarr")


def test_add_wells_to_project(zarr_group, mobie_project_folder):
def test_full_mobie_project(zarr_group, mobie_project_folder):
# setup OME-ZARR folder
# setup MoBIE project
dataset_name = "mobie_test_dataset"
Expand Down Expand Up @@ -84,7 +100,23 @@ def test_add_wells_to_project(zarr_group, mobie_project_folder):
view_name="default",
)

# assert
# validate 1
validate_project(
root=mobie_project_folder,
)

# add_labels_view
add_labels_view(
plate=zarr_group,
dataset_folder=(mobie_project_folder / dataset_name),
well_group="0",
channel=0,
label_name="simple_threshold",
view_name="default",
extra_properties=("area", "bbox"),
)

# validate 2
validate_project(
root=mobie_project_folder,
)
Expand All @@ -99,11 +131,18 @@ def test_add_wells_to_project(zarr_group, mobie_project_folder):
assert "sourceDisplays" in json_data["views"]["default"]
assert "sourceTransforms" in json_data["views"]["default"]

# wells table
table_path: Path = (
mobie_project_folder / dataset_name / "tables" / "wells" / "default.tsv"
)
assert table_path.exists()


def test_add_labels_view():
pass
# segmentation table for E07
label_table_path: Path = (
mobie_project_folder
/ dataset_name
/ "tables"
/ "E07_simple_threshold"
/ "default.tsv"
)
assert label_table_path.exists()

0 comments on commit ba86e32

Please sign in to comment.