Skip to content

Commit 8ade241

Browse files
committed
feat(starrynight: modules): add sbs preprocess cli
1 parent 664973e commit 8ade241

File tree

2 files changed

+94
-0
lines changed

2 files changed

+94
-0
lines changed

starrynight/src/starrynight/cli/main.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from starrynight.cli.illum import illum
88
from starrynight.cli.index import index
99
from starrynight.cli.inv import inventory
10+
from starrynight.cli.preprocess import preprocess
1011
from starrynight.cli.presegcheck import presegcheck
1112
from starrynight.cli.segcheck import segcheck
1213

@@ -24,3 +25,4 @@ def main() -> None:
2425
main.add_command(presegcheck)
2526
main.add_command(segcheck)
2627
main.add_command(align)
28+
main.add_command(preprocess)
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
"""Preprocess module cli wrapper."""
2+
3+
import click
4+
from cloudpathlib import AnyPath
5+
6+
from starrynight.algorithms.preprocess import (
7+
gen_preprocess_cppipe_by_batch_plate,
8+
gen_preprocess_load_data_by_batch_plate,
9+
)
10+
11+
12+
@click.command(name="loaddata")
13+
@click.option("-i", "--index", required=True)
14+
@click.option("-o", "--out", required=True)
15+
@click.option("-c", "--corr_images", required=True)
16+
@click.option("-a", "--align_images", required=True)
17+
@click.option("-n", "--nuclei", required=True)
18+
@click.option("-m", "--path_mask", default=None)
19+
def gen_preprocess_load_data(
20+
index: str,
21+
out: str,
22+
corr_images: str,
23+
align_images: str,
24+
nuclei: str,
25+
path_mask: str | None,
26+
) -> None:
27+
"""Generate preprocess loaddata file.
28+
29+
Parameters
30+
----------
31+
index : str | None
32+
Index path. Can be local or a cloud path.
33+
out : str
34+
Output dir. Can be local or a cloud path.
35+
corr_images : str
36+
Corrected images dir. Can be local or a cloud path.
37+
align_images : str
38+
Aligned images dir. Can be local or a cloud path.
39+
nuclei : str
40+
Channel to use for nuceli segmentation
41+
path_mask : str | Mask
42+
Path prefix mask to use. Can be local or a cloud path.
43+
44+
"""
45+
gen_preprocess_load_data_by_batch_plate(
46+
AnyPath(index),
47+
AnyPath(out),
48+
path_mask,
49+
nuclei,
50+
AnyPath(corr_images),
51+
AnyPath(align_images),
52+
)
53+
54+
55+
@click.command(name="cppipe")
56+
@click.option("-l", "--loaddata", required=True)
57+
@click.option("-o", "--out", required=True)
58+
@click.option("-w", "--workspace", required=True)
59+
@click.option("-b", "--barcode", required=True)
60+
@click.option("-n", "--nuclei", required=True)
61+
def gen_preprocess_cppipe(
62+
loaddata: str, out: str, workspace: str, barcode: str, nuclei: str
63+
) -> None:
64+
"""Generate preprocess cppipe file.
65+
66+
Parameters
67+
----------
68+
loaddata : str
69+
Loaddata dir path. Can be local or a cloud path.
70+
out : str
71+
Path to output directory. Can be local or a cloud path.
72+
workspace : str
73+
Path to workspace directory. Can be local or a cloud path.
74+
barcode : str
75+
Path to barcode csv. Can be local or a cloud path.
76+
nuclei : str
77+
Channel to use for nuceli segmentation
78+
79+
"""
80+
gen_preprocess_cppipe_by_batch_plate(
81+
AnyPath(loaddata), AnyPath(out), AnyPath(workspace), AnyPath(barcode), nuclei
82+
)
83+
84+
85+
@click.group()
86+
def preprocess() -> None:
87+
"""Preprocess commands."""
88+
pass
89+
90+
91+
preprocess.add_command(gen_preprocess_load_data)
92+
preprocess.add_command(gen_preprocess_cppipe)

0 commit comments

Comments
 (0)