Skip to content

Commit a911b33

Browse files
fix proseg command line usage
1 parent 35ee3d0 commit a911b33

File tree

3 files changed

+11
-30
lines changed

3 files changed

+11
-30
lines changed

sopa/cli/segmentation.py

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,7 @@ def comseg(
215215
default=None,
216216
help="Index of the patch on which the segmentation method should be run.",
217217
),
218-
min_area: float = typer.Option(
219-
default=0,
220-
help="Minimum area (in micron^2) for a cell to be considered as valid",
221-
),
218+
min_area: float = typer.Option(default=0, help="Minimum area (in micron^2) for a cell to be considered as valid"),
222219
):
223220
"""Perform ComSeg segmentation. This can be done on all patches directly, or on one individual patch."""
224221
from sopa.io.standardize import read_zarr_standardized
@@ -243,10 +240,7 @@ def baysor(
243240
default=None,
244241
help="Index of the patch on which the segmentation method should be run. By default, run on all patches.",
245242
),
246-
min_area: float = typer.Option(
247-
default=0,
248-
help="Minimum area (in micron^2) for a cell to be considered as valid",
249-
),
243+
min_area: float = typer.Option(default=0, help="Minimum area (in micron^2) for a cell to be considered as valid"),
250244
scale: float = typer.Option(default=None, help="Baysor scale parameter (for config inference)"),
251245
):
252246
"""Perform Baysor segmentation. This can be done on all patches directly, or on one individual patch."""
@@ -259,13 +253,7 @@ def baysor(
259253
sdata = read_zarr_standardized(sdata_path)
260254

261255
try:
262-
baysor(
263-
sdata,
264-
config=config,
265-
min_area=min_area,
266-
patch_index=patch_index,
267-
scale=scale,
268-
)
256+
baysor(sdata, config=config, min_area=min_area, patch_index=patch_index, scale=scale)
269257
except CalledProcessError as e:
270258
sys.exit(e.returncode)
271259

@@ -275,17 +263,13 @@ def baysor(
275263
@app_segmentation.command()
276264
def proseg(
277265
sdata_path: str = typer.Argument(help=SDATA_HELPER),
278-
input_technology: str = typer.Option(
279-
"merscope",
280-
help="Type of input data. Proseg is compatible with multiple technology inputs, it just needs to be passed as an option. Supported methods are 'merscope', 'cosmx-micron', 'xenium'",
281-
),
282-
prior_shapes_key: str = typer.Option(
283-
default=None,
284-
help="Name of the prior shapes key to use for segmentation. If None, no prior shapes will be used.",
266+
command_line_suffix: str = typer.Option(
267+
"",
268+
help="String suffix to add to the proseg command line. This can be used to add extra parameters to the proseg command line.",
285269
),
286270
):
287271
"""Perform Proseg segmentation. This needs to be done on a single
288-
patch as proseg is fast enough and doesn't require parallelization."""
272+
patch as proseg is fast enough and doesn't require parallelization."""
289273
import sys
290274
from subprocess import CalledProcessError
291275

@@ -295,15 +279,11 @@ def proseg(
295279
sdata = read_zarr_standardized(sdata_path)
296280

297281
try:
298-
proseg(
299-
sdata,
300-
input_technology=input_technology,
301-
prior_shapes_key=prior_shapes_key,
302-
)
282+
proseg(sdata, command_line_suffix=command_line_suffix)
303283
except CalledProcessError as e:
304284
sys.exit(e.returncode)
305285

306-
# _log_whether_to_resolve(patch_index)
286+
_log_whether_to_resolve(None)
307287

308288

309289
@app_segmentation.command()

sopa/patches/_patches.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def __init__(
8989
patch_width: Width of the patches (in the unit of the coordinate system of the element). If `None`, only one patch will be created
9090
patch_overlap: Overlap width between the patches
9191
"""
92-
patch_width = patch_width or float("inf")
92+
patch_width = float("inf") if (patch_width is None or patch_width == -1) else patch_width
9393

9494
assert patch_width > patch_overlap, f"Argument {patch_width=} must be greater than {patch_overlap=}"
9595

sopa/utils/utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ def get_boundaries(
5454
return get_spatial_element(sdata.shapes, key=key, return_key=return_key)
5555

5656
VALID_BOUNDARIES = [
57+
SopaKeys.PROSEG_BOUNDARIES,
5758
SopaKeys.BAYSOR_BOUNDARIES,
5859
SopaKeys.STARDIST_BOUNDARIES,
5960
SopaKeys.COMSEG_BOUNDARIES,

0 commit comments

Comments
 (0)