-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# SPDX-FileCopyrightText: 2024 Friedrich Miescher Institute for Biomedical Research (FMI), Basel (Switzerland) | ||
# | ||
# SPDX-License-Identifier: MIT | ||
"""Test segment.weka_classifier functionality.""" | ||
from pathlib import Path | ||
|
||
import numpy as np | ||
import pytest | ||
from faim_wako_searchfirst.segment import weka_classifier | ||
from skimage.io import imread | ||
|
||
SAMPLE_IMAGE_NAME = "worms_C01.tif" | ||
|
||
|
||
@pytest.fixture | ||
def _classifier_path(): | ||
return Path("tests/resources/classifier.model") | ||
|
||
|
||
@pytest.fixture | ||
def _sample_image(): | ||
return imread(Path("tests/resources/worms") / SAMPLE_IMAGE_NAME) | ||
|
||
|
||
def test_weka_classifier(_sample_image, _classifier_path): | ||
"""Directly call weka_classifier.""" | ||
result = weka_classifier(_sample_image, _classifier_path) | ||
assert result.shape == (442, 442) | ||
assert np.count_nonzero(result == 1) == 3 | ||
assert np.count_nonzero(result == 2) == 8 | ||
assert np.count_nonzero(result == 3) == 831 |