CAREamics denoising plugin
See Denoising first.
patchworks.plugins.careamics.denoise_fn(fn: Callable[[np.ndarray], np.ndarray], model: str, *, nuclei_model: str | None = None, tile_size: Sequence[int] | None = None, tile_overlap: Sequence[int] | None = None, batch_size: int = 1) -> Callable[[np.ndarray], np.ndarray]
Wrap fn so every tile is denoised before fn segments it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fn
|
Callable[[ndarray], ndarray]
|
Any per-tile segmentation function. |
required |
model
|
str
|
CAREamics model for the segmented channel: a checkpoint ( |
required |
nuclei_model
|
str | None
|
Model for the nuclear channel ( |
None
|
tile_size
|
Sequence[int] | None
|
CAREamics' own tiling inside a patchworks tile (VRAM). Defaults:
:data: |
None
|
tile_overlap
|
Sequence[int] | None
|
CAREamics' own tiling inside a patchworks tile (VRAM). Defaults:
:data: |
None
|
batch_size
|
int
|
CAREamics tiles per forward pass. |
1
|
Returns:
| Type | Description |
|---|---|
Callable[[ndarray], ndarray]
|
Picklable |
Source code in src/patchworks/plugins/careamics.py
patchworks.plugins.careamics.denoise(tile: np.ndarray, **kwargs: Any) -> np.ndarray
Just the denoised tile (float32), e.g. to look at it before
segmenting with it. Takes :func:denoise_fn's keyword arguments.
Source code in src/patchworks/plugins/careamics.py
patchworks.plugins.careamics.train_n2v(store: str | Path, out: str | Path, *, channel: int = 0, level: int = 0, crop_shape: Sequence[int] = (32, 512, 512), n_crops: int = 4, patch_size: Sequence[int] | None = None, batch_size: int = 8, epochs: int = 30, n2v2: bool = False, work_dir: str | Path | None = None) -> Path
Train a Noise2Void model on crops of one channel of store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
store
|
str | Path
|
OME-Zarr image (the workflow's |
required |
out
|
str | Path
|
Where to write the trained checkpoint ( |
required |
channel
|
int
|
Channel and pyramid level -- the ones the segmentation reads. |
0
|
level
|
int
|
Channel and pyramid level -- the ones the segmentation reads. |
0
|
crop_shape
|
Sequence[int]
|
What to train on: the n_crops brightest crops of that shape
(:func: |
(32, 512, 512)
|
n_crops
|
Sequence[int]
|
What to train on: the n_crops brightest crops of that shape
(:func: |
(32, 512, 512)
|
patch_size
|
Sequence[int] | None
|
Training patch, |
None
|
batch_size
|
int
|
Training length. 30 epochs takes minutes to an hour on one GPU. |
8
|
epochs
|
int
|
Training length. 30 epochs takes minutes to an hour on one GPU. |
8
|
n2v2
|
bool
|
Noise2Void2 (fewer checkerboard artefacts on structured noise). |
False
|
work_dir
|
str | Path | None
|
Where CAREamics keeps its logs and intermediate checkpoints. |
None
|
Returns:
| Type | Description |
|---|---|
Path
|
out. |
Source code in src/patchworks/plugins/careamics.py
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 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 | |
patchworks.plugins.careamics.training_crops(store: str | Path, *, channel: int = 0, level: int = 0, crop_shape: Sequence[int] = (32, 512, 512), n_crops: int = 4) -> list[np.ndarray]
The n_crops brightest crops of a channel, to train a denoiser on.
Ranked on the store's coarsest pyramid level, so picking them reads almost nothing; empty background (nothing to learn the noise of structure from) is skipped that way too.