PlantSeg plugin
See Cells from a membrane stain.
patchworks.plugins.plantseg.plantseg_fn(model: str | None = 'generic_confocal_3D_unet', *, model_id: str | None = None, config_path: str | None = None, weights_path: str | None = None, segmentation: str = 'gasp', beta: float = 0.6, post_minsize: int = 100, ws_threshold: float = 0.5, ws_sigma_seeds: float = 2.0, ws_min_size: int = 50, ws_stacked: bool = False, nuclei_sigma: Any = 1.0, nuclei_threshold: float | None = None, nuclei_min_size: int = 50, foreground: str | float | None = None, foreground_sigma: Any = 2.0, max_radius_um: float | None = None, boundary_channel: int = 0, rescale: bool = True, patch: tuple[int, ...] | None = None, device: str = 'cuda', n_threads: int | None = None, seeds: str = 'channel', voxel_size: dict[str, float] | None = None, intensity_stats: 'tuple[float, float] | None' = None) -> Callable[[np.ndarray], np.ndarray]
Return a PlantSeg segmentation for tile_process.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
str | None
|
PlantSeg zoo model ( |
'generic_confocal_3D_unet'
|
model_id
|
str | None
|
Or a BioImage.IO model zoo id instead of model. |
None
|
config_path
|
str | None
|
Or your own trained U-Net (PlantSeg's training config and weights). |
None
|
weights_path
|
str | None
|
Or your own trained U-Net (PlantSeg's training config and weights). |
None
|
segmentation
|
str
|
One of :data: |
'gasp'
|
beta
|
float
|
Agglomeration bias: lower merges more (under-segments), higher splits more. PlantSeg's GUI default is 0.6. |
0.6
|
post_minsize
|
int
|
Cells smaller than this many voxels are merged into a neighbour. |
100
|
ws_threshold
|
float
|
The supervoxel watershed (PlantSeg's |
0.5
|
ws_sigma_seeds
|
float
|
The supervoxel watershed (PlantSeg's |
0.5
|
ws_min_size
|
float
|
The supervoxel watershed (PlantSeg's |
0.5
|
ws_stacked
|
float
|
The supervoxel watershed (PlantSeg's |
0.5
|
nuclei_sigma
|
Any
|
How nuclei are found in the nuclear channel, see
:func: |
1.0
|
nuclei_threshold
|
Any
|
How nuclei are found in the nuclear channel, see
:func: |
1.0
|
nuclei_min_size
|
Any
|
How nuclei are found in the nuclear channel, see
:func: |
1.0
|
foreground
|
str | float | None
|
Background masking, see
:func: |
None
|
foreground_sigma
|
str | float | None
|
Background masking, see
:func: |
None
|
max_radius_um
|
str | float | None
|
Background masking, see
:func: |
None
|
boundary_channel
|
int
|
Output channel holding the boundaries (0 for the boundary models). |
0
|
rescale
|
bool
|
Resample each tile to the model's training voxel size before predicting (and the prediction back), from voxel_size. The single biggest factor in a pretrained U-Net's quality. |
True
|
patch
|
tuple[int, ...] | None
|
U-Net patch shape (z, y, x). |
None
|
device
|
str
|
|
'cuda'
|
n_threads
|
int | None
|
Threads for the watershed and agglomeration. |
None
|
seeds
|
str
|
For the modes using nuclei: |
'channel'
|
voxel_size
|
dict[str, float] | None
|
|
None
|
intensity_stats
|
'tuple[float, float] | None'
|
|
None
|
Returns:
| Type | Description |
|---|---|
Callable[[ndarray], ndarray]
|
Picklable labeller: |
Source code in src/patchworks/plugins/plantseg.py
307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 | |
patchworks.plugins.plantseg.fetch_model(model: str = 'generic_confocal_3D_unet') -> None
Download a zoo model into $PLANTSEG_HOME now, not on a GPU node.
Compute nodes often have no internet access; the segment jobs then load the copy fetched here.
Source code in src/patchworks/plugins/plantseg.py
patchworks.plugins.plantseg.available_models() -> list[str]
Names in PlantSeg's model zoo (empty without PlantSeg).
patchworks.plugins.plantseg.rescale_factors(voxel_size: dict[str, float] | None, resolution: tuple[float, ...] | None, ndim: int) -> tuple[float, ...] | None
Zoom per axis taking the image to the model's training resolution.
None when either is unknown or every factor is within 10 % of 1.
Examples:
>>> rescale_factors({"z": 0.47, "y": 0.3, "x": 0.3}, (0.235, 0.15, 0.15), 3)
(2.0, 2.0, 2.0)
>>> rescale_factors({"z": 0.24, "y": 0.15, "x": 0.15}, (0.235, 0.15, 0.15), 3)