Nuclei-seeded watershed plugin
See Cells from a membrane stain.
patchworks.plugins.watershed.watershed_fn(*, boundary_sigma: Any = 1.0, nuclei_sigma: Any = 1.0, nuclei_threshold: float | None = None, nuclei_min_size: int = 50, foreground: str | float | None = 'otsu', foreground_sigma: Any = 2.0, max_radius_um: float | None = None, compactness: float = 0.0, min_size: int = 0, sigma_units: str = 'px', seeds: str = 'channel', voxel_size: dict[str, float] | None = None) -> Callable[[np.ndarray], np.ndarray]
Return a nuclei-seeded watershed for tile_process.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
boundary_sigma
|
Any
|
Smoothing of the membrane channel before flooding it. |
1.0
|
nuclei_sigma
|
Any
|
How the nuclei are found: see :func: |
1.0
|
nuclei_threshold
|
Any
|
How the nuclei are found: see :func: |
1.0
|
nuclei_min_size
|
Any
|
How the nuclei are found: see :func: |
1.0
|
foreground
|
str | float | None
|
Tissue mask from the membrane channel: |
'otsu'
|
foreground_sigma
|
str | float | None
|
Tissue mask from the membrane channel: |
'otsu'
|
max_radius_um
|
float | None
|
Furthest a cell reaches from its nucleus, in micrometres (needs
voxel_size; the workflow passes it). |
None
|
compactness
|
float
|
|
0.0
|
min_size
|
int
|
Drop cells smaller than this many voxels. |
0
|
sigma_units
|
str
|
|
'px'
|
seeds
|
str
|
|
'channel'
|
voxel_size
|
dict[str, float] | None
|
|
None
|
Returns:
| Type | Description |
|---|---|
Callable[[ndarray], ndarray]
|
Picklable |
Source code in src/patchworks/plugins/watershed.py
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 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 | |
patchworks.plugins.watershed.nuclei_seeds(nuclei: np.ndarray, *, sigma: Any = 1.0, threshold: float | None = None, min_size: int = 50) -> np.ndarray
Label the nuclei of a nuclear-dye image, to seed the cells with.
Smooth, threshold (Otsu unless threshold is given, in the image's own intensity units), fill holes, drop specks below min_size voxels and label what is left.
Two touching nuclei come out as one seed, so the two cells around them
as one cell: raise threshold if that happens, or give the seeds from a
nuclei model (:func:seeded_watershed takes any label image).
Source code in src/patchworks/plugins/watershed.py
patchworks.plugins.watershed.foreground_mask(membrane: np.ndarray, seeds: np.ndarray, *, foreground: str | float | None = 'otsu', sigma: Any = 2.0, max_radius: tuple[float, ...] | None = None) -> np.ndarray | None
Where cells may grow: tissue and/or near a seed. None: anywhere.
foreground "otsu" (or an intensity) keeps what the smoothed
membrane signal covers, holes filled -- the cell interiors are dark in a
membrane stain but enclosed by it. max_radius (pixels per axis) keeps
what lies within that distance of a nucleus, so a cell on the tissue's
edge stops instead of flooding the empty space beyond it.
Source code in src/patchworks/plugins/watershed.py
patchworks.plugins.watershed.seeded_watershed(boundaries: np.ndarray, seeds: np.ndarray, *, mask: np.ndarray | None = None, compactness: float = 0.0, min_size: int = 0) -> np.ndarray
Flood boundaries (high on cell walls) from the labelled seeds.
Every seed becomes exactly one cell; with mask, cells stop at its edge. compactness > 0 favours rounder cells where a wall is missing. Cells smaller than min_size voxels are dropped (a seed in a speck of tissue).