Skip to content

Commit b9a2cd5

Browse files
committed
wip
1 parent 0e3c635 commit b9a2cd5

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ dependencies = [
3131
"confuse",
3232
"rich",
3333
"scikit-image",
34+
"scyjava",
3435
"tqdm",
3536
"typer"
3637
]

src/faim_wako_searchfirst/segment.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,25 @@ def cellpose(
7272
**kwargs,
7373
)
7474
return mask
75+
76+
77+
def weka_classifier(
78+
img,
79+
classifier_path: Path,
80+
logger=logging,
81+
):
82+
"""Apply a classifier.model file.
83+
84+
Use Trainable Weka Segmentation (via pyimagej)
85+
to apply a trained classifier to the input image.
86+
"""
87+
# initialize imagej
88+
import imagej
89+
90+
ij = imagej.init("sc.fiji:fiji:2.15.0")
91+
assert ij is not None
92+
# convert img to_java
93+
# call WekaSegmentation API
94+
# get result imp
95+
# convert imp from_java
96+
return ij.getVersion()

tests/test_weka_classifier.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# SPDX-FileCopyrightText: 2024 Friedrich Miescher Institute for Biomedical Research (FMI), Basel (Switzerland)
2+
#
3+
# SPDX-License-Identifier: MIT
4+
"""Test segment.weka_classifier functionality."""
5+
from faim_wako_searchfirst.segment import weka_classifier
6+
7+
8+
def test_weka_classifier():
9+
"""Directly call weka_classifier."""
10+
version = weka_classifier(None, None)
11+
assert version == "2.15.0/1.54f"

0 commit comments

Comments
 (0)