napari viewer plugin
Open an OME-ZARR image and overlay the labels produced by
tile_process as a napari Labels layer in a single
call. Requires the optional napari extra (pip install "patchworks[napari]").
patchworks.plugins.napari.view_in_napari(image: Union[da.Array, str, Path], labels: Union[da.Array, str, Path, None] = None, *, channel: int | None = None, labels_component: str = 'labels', image_name: str = 'image', labels_name: str = 'labels', glasbey: bool = True, show: bool = True, **add_image_kwargs: Any)
Open image in napari and overlay labels as a Labels layer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
(Array, str or Path)
|
OME-ZARR store (multi-scale aware), any bioio-readable file, or an in-memory array. |
required |
labels
|
(Array, str, Path or None)
|
Label array to overlay. A plain |
None
|
channel
|
int or None
|
Channel to display from the image. |
None
|
labels_component
|
str
|
Array name inside a plain-zarr label store (default |
'labels'
|
image_name
|
str
|
Layer names shown in napari. |
'image'
|
labels_name
|
str
|
Layer names shown in napari. |
'image'
|
glasbey
|
bool
|
Colour the labels with a glasbey palette (many distinct, high-contrast
colours, tuned to read on the dark canvas) instead of napari's default.
Default |
True
|
show
|
bool
|
Start the napari event loop (blocking). Set |
True
|
**add_image_kwargs
|
Any
|
Extra keyword arguments forwarded to |
{}
|
Returns:
| Type | Description |
|---|---|
Viewer
|
The viewer instance (useful when |
Notes
In 3-D view (the cube icon, or viewer.dims.ndisplay = 3), napari
always shows the coarsest pyramid level — there is no automatic
zoom-based switching in 3-D, only in 2-D. To pin a specific resolution
(needs napari>=0.7.1)::
viewer.layers["labels"].locked_data_level = 0 # full resolution
viewer.layers["labels"].locked_data_level = None # back to coarsest
A widget for this is also in the layer controls panel in napari>=0.7.1.
Examples:
Source code in src/patchworks/plugins/napari.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 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 | |