OmeZarrContainer: API Documentation¶
Open an OME-Zarr Container¶
ngio.open_ome_zarr_container
¶
open_ome_zarr_container(
store: StoreOrGroup,
cache: bool = False,
mode: AccessModeLiteral = "r+",
validate_arrays: bool = True,
) -> OmeZarrContainer
Open an OME-Zarr image.
Source code in ngio/images/_ome_zarr_container.py
674 675 676 677 678 679 680 681 682 683 684 685 |
|
Create an OME-Zarr Container¶
ngio.create_empty_ome_zarr
¶
create_empty_ome_zarr(
store: StoreOrGroup,
shape: Collection[int],
xy_pixelsize: float,
z_spacing: float = 1.0,
time_spacing: float = 1.0,
levels: int | list[str] = 5,
xy_scaling_factor: float = 2,
z_scaling_factor: float = 1.0,
space_unit: SpaceUnits = DefaultSpaceUnit,
time_unit: TimeUnits = DefaultTimeUnit,
axes_names: Collection[str] | None = None,
name: str | None = None,
chunks: Collection[int] | None = None,
dtype: str = "uint16",
channel_labels: list[str] | None = None,
channel_wavelengths: list[str] | None = None,
channel_colors: Collection[str] | None = None,
channel_active: Collection[bool] | None = None,
overwrite: bool = False,
version: NgffVersions = DefaultNgffVersion,
) -> OmeZarrContainer
Create an empty OME-Zarr image with the given shape and metadata.
Parameters:
-
store
(StoreOrGroup
) –The Zarr store or group to create the image in.
-
shape
(Collection[int]
) –The shape of the image.
-
xy_pixelsize
(float
) –The pixel size in x and y dimensions.
-
z_spacing
(float
, default:1.0
) –The spacing between z slices. Defaults to 1.0.
-
time_spacing
(float
, default:1.0
) –The spacing between time points. Defaults to 1.0.
-
levels
(int | list[str]
, default:5
) –The number of levels in the pyramid or a list of level names. Defaults to 5.
-
xy_scaling_factor
(float
, default:2
) –The down-scaling factor in x and y dimensions. Defaults to 2.0.
-
z_scaling_factor
(float
, default:1.0
) –The down-scaling factor in z dimension. Defaults to 1.0.
-
space_unit
(SpaceUnits
, default:DefaultSpaceUnit
) –The unit of space. Defaults to DefaultSpaceUnit.
-
time_unit
(TimeUnits
, default:DefaultTimeUnit
) –The unit of time. Defaults to DefaultTimeUnit.
-
axes_names
(Collection[str] | None
, default:None
) –The names of the axes. If None the canonical names are used. Defaults to None.
-
name
(str | None
, default:None
) –The name of the image. Defaults to None.
-
chunks
(Collection[int] | None
, default:None
) –The chunk shape. If None the shape is used. Defaults to None.
-
dtype
(str
, default:'uint16'
) –The data type of the image. Defaults to "uint16".
-
channel_labels
(list[str] | None
, default:None
) –The labels of the channels. Defaults to None.
-
channel_wavelengths
(list[str] | None
, default:None
) –The wavelengths of the channels. Defaults to None.
-
channel_colors
(Collection[str] | None
, default:None
) –The colors of the channels. Defaults to None.
-
channel_active
(Collection[bool] | None
, default:None
) –Whether the channels are active. Defaults to None.
-
overwrite
(bool
, default:False
) –Whether to overwrite an existing image. Defaults to True.
-
version
(NgffVersion
, default:DefaultNgffVersion
) –The version of the OME-Zarr specification. Defaults to DefaultNgffVersion.
Source code in ngio/images/_ome_zarr_container.py
759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 |
|
ngio.create_ome_zarr_from_array
¶
create_ome_zarr_from_array(
store: StoreOrGroup,
array: ndarray,
xy_pixelsize: float,
z_spacing: float = 1.0,
time_spacing: float = 1.0,
levels: int | list[str] = 5,
xy_scaling_factor: float = 2.0,
z_scaling_factor: float = 1.0,
space_unit: SpaceUnits = DefaultSpaceUnit,
time_unit: TimeUnits = DefaultTimeUnit,
axes_names: Collection[str] | None = None,
channel_labels: list[str] | None = None,
channel_wavelengths: list[str] | None = None,
percentiles: tuple[float, float] | None = (0.1, 99.9),
channel_colors: Collection[str] | None = None,
channel_active: Collection[bool] | None = None,
name: str | None = None,
chunks: Collection[int] | None = None,
overwrite: bool = False,
version: NgffVersions = DefaultNgffVersion,
) -> OmeZarrContainer
Create an OME-Zarr image from a numpy array.
Parameters:
-
store
(StoreOrGroup
) –The Zarr store or group to create the image in.
-
array
(ndarray
) –The image data.
-
xy_pixelsize
(float
) –The pixel size in x and y dimensions.
-
z_spacing
(float
, default:1.0
) –The spacing between z slices. Defaults to 1.0.
-
time_spacing
(float
, default:1.0
) –The spacing between time points. Defaults to 1.0.
-
levels
(int | list[str]
, default:5
) –The number of levels in the pyramid or a list of level names. Defaults to 5.
-
xy_scaling_factor
(float
, default:2.0
) –The down-scaling factor in x and y dimensions. Defaults to 2.0.
-
z_scaling_factor
(float
, default:1.0
) –The down-scaling factor in z dimension. Defaults to 1.0.
-
space_unit
(SpaceUnits
, default:DefaultSpaceUnit
) –The unit of space. Defaults to DefaultSpaceUnit.
-
time_unit
(TimeUnits
, default:DefaultTimeUnit
) –The unit of time. Defaults to DefaultTimeUnit.
-
axes_names
(Collection[str] | None
, default:None
) –The names of the axes. If None the canonical names are used. Defaults to None.
-
name
(str | None
, default:None
) –The name of the image. Defaults to None.
-
chunks
(Collection[int] | None
, default:None
) –The chunk shape. If None the shape is used. Defaults to None.
-
channel_labels
(list[str] | None
, default:None
) –The labels of the channels. Defaults to None.
-
channel_wavelengths
(list[str] | None
, default:None
) –The wavelengths of the channels. Defaults to None.
-
percentiles
(tuple[float, float] | None
, default:(0.1, 99.9)
) –The percentiles of the channels. Defaults to None.
-
channel_colors
(Collection[str] | None
, default:None
) –The colors of the channels. Defaults to None.
-
channel_active
(Collection[bool] | None
, default:None
) –Whether the channels are active. Defaults to None.
-
overwrite
(bool
, default:False
) –Whether to overwrite an existing image. Defaults to True.
-
version
(str
, default:DefaultNgffVersion
) –The version of the OME-Zarr specification. Defaults to DefaultNgffVersion.
Source code in ngio/images/_ome_zarr_container.py
849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 |
|
OmeZarrContainer Class¶
ngio.OmeZarrContainer
¶
OmeZarrContainer(
group_handler: ZarrGroupHandler,
table_container: TablesContainer | None = None,
label_container: LabelsContainer | None = None,
validate_paths: bool = False,
)
This class is an object representation of an OME-Zarr image.
It provides methods to access
- The multiscale image metadata
- To open images at different levels of resolution
- To access labels and tables associated with the image.
- To derive new images, labels, and add tables to the image.
- To modify the image metadata, such as axes units and channel metadata.
Attributes:
-
images_container
(ImagesContainer
) –The container for the images.
-
labels_container
(LabelsContainer
) –The container for the labels.
-
tables_container
(TablesContainer
) –The container for the tables.
Initialize the OmeZarrContainer.
Parameters:
-
group_handler
(ZarrGroupHandler
) –The Zarr group handler.
-
table_container
(TablesContainer | None
, default:None
) –The tables container.
-
label_container
(LabelsContainer | None
, default:None
) –The labels container.
-
validate_paths
(bool
, default:False
) –Whether to validate the paths of the image multiscale
Source code in ngio/images/_ome_zarr_container.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
|
images_container
property
¶
images_container: ImagesContainer
wavelength_ids
property
¶
Return the list of wavelength of the image.
get_channel_idx
¶
Get the index of a channel by its label or wavelength ID.
Source code in ngio/images/_ome_zarr_container.py
235 236 237 238 239 240 241 242 |
|
set_channel_meta
¶
set_channel_meta(
labels: Collection[str] | int | None = None,
wavelength_id: Collection[str] | None = None,
percentiles: tuple[float, float] | None = None,
colors: Collection[str] | None = None,
active: Collection[bool] | None = None,
**omero_kwargs: dict,
) -> None
Create a ChannelsMeta object with the default unit.
Source code in ngio/images/_ome_zarr_container.py
244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 |
|
set_channel_percentiles
¶
Update the percentiles of the image.
Source code in ngio/images/_ome_zarr_container.py
263 264 265 266 267 268 269 270 271 |
|
set_axes_units
¶
set_axes_units(
space_unit: SpaceUnits = DefaultSpaceUnit,
time_unit: TimeUnits = DefaultTimeUnit,
set_labels: bool = True,
) -> None
Set the units of the image.
Parameters:
-
space_unit
(SpaceUnits
, default:DefaultSpaceUnit
) –The unit of space.
-
time_unit
(TimeUnits
, default:DefaultTimeUnit
) –The unit of time.
-
set_labels
(bool
, default:True
) –Whether to set the units for the labels as well.
Source code in ngio/images/_ome_zarr_container.py
273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 |
|
get_image
¶
get_image(
path: str | None = None,
pixel_size: PixelSize | None = None,
strict: bool = False,
) -> Image
Get an image at a specific level.
Parameters:
-
path
(str | None
, default:None
) –The path to the image in the ome_zarr file.
-
pixel_size
(PixelSize | None
, default:None
) –The pixel size of the image.
-
strict
(bool
, default:False
) –Only used if the pixel size is provided. If True, the pixel size must match the image pixel size exactly. If False, the closest pixel size level will be returned.
Source code in ngio/images/_ome_zarr_container.py
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 |
|
get_masked_image
¶
get_masked_image(
masking_label_name: str,
masking_table_name: str | None = None,
path: str | None = None,
pixel_size: PixelSize | None = None,
strict: bool = False,
) -> MaskedImage
Get a masked image at a specific level.
Parameters:
-
masking_label_name
(str
) –The name of the label.
-
masking_table_name
(str | None
, default:None
) –The name of the masking table.
-
path
(str | None
, default:None
) –The path to the image in the ome_zarr file.
-
pixel_size
(PixelSize | None
, default:None
) –The pixel size of the image.
-
strict
(bool
, default:False
) –Only used if the pixel size is provided. If True, the pixel size must match the image pixel size exactly. If False, the closest pixel size level will be returned.
Source code in ngio/images/_ome_zarr_container.py
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 |
|
derive_image
¶
derive_image(
store: StoreOrGroup,
ref_path: str | None = None,
shape: Collection[int] | None = None,
labels: Collection[str] | None = None,
pixel_size: PixelSize | None = None,
axes_names: Collection[str] | None = None,
name: str | None = None,
chunks: Collection[int] | None = None,
dtype: str | None = None,
copy_labels: bool = False,
copy_tables: bool = False,
overwrite: bool = False,
) -> OmeZarrContainer
Create an empty OME-Zarr container from an existing image.
Parameters:
-
store
(StoreOrGroup
) –The Zarr store or group to create the image in.
-
ref_path
(str | None
, default:None
) –The path to the reference image in the image container.
-
shape
(Collection[int] | None
, default:None
) –The shape of the new image.
-
labels
(Collection[str] | None
, default:None
) –The labels of the new image.
-
pixel_size
(PixelSize | None
, default:None
) –The pixel size of the new image.
-
axes_names
(Collection[str] | None
, default:None
) –The axes names of the new image.
-
chunks
(Collection[int] | None
, default:None
) –The chunk shape of the new image.
-
dtype
(str | None
, default:None
) –The data type of the new image.
-
name
(str | None
, default:None
) –The name of the new image.
-
copy_labels
(bool
, default:False
) –Whether to copy the labels from the reference image.
-
copy_tables
(bool
, default:False
) –Whether to copy the tables from the reference image.
-
overwrite
(bool
, default:False
) –Whether to overwrite an existing image.
Returns:
-
OmeZarrContainer
(OmeZarrContainer
) –The new image container.
Source code in ngio/images/_ome_zarr_container.py
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 |
|
list_tables
¶
list_tables(
filter_types: TypedTable | str | None = None,
) -> list[str]
List all tables in the image.
Source code in ngio/images/_ome_zarr_container.py
418 419 420 421 422 423 424 425 426 |
|
list_roi_tables
¶
List all ROI tables in the image.
Source code in ngio/images/_ome_zarr_container.py
428 429 430 431 432 433 434 435 436 |
|
get_roi_table
¶
Get a ROI table from the image.
Parameters:
-
name
(str
) –The name of the table.
Source code in ngio/images/_ome_zarr_container.py
438 439 440 441 442 443 444 445 446 447 |
|
get_masking_roi_table
¶
get_masking_roi_table(name: str) -> MaskingRoiTable
Get a masking ROI table from the image.
Parameters:
-
name
(str
) –The name of the table.
Source code in ngio/images/_ome_zarr_container.py
449 450 451 452 453 454 455 456 457 458 459 460 |
|
get_feature_table
¶
get_feature_table(name: str) -> FeatureTable
Get a feature table from the image.
Parameters:
-
name
(str
) –The name of the table.
Source code in ngio/images/_ome_zarr_container.py
462 463 464 465 466 467 468 469 470 471 472 473 |
|
get_generic_roi_table
¶
get_generic_roi_table(name: str) -> GenericRoiTable
Get a generic ROI table from the image.
Parameters:
-
name
(str
) –The name of the table.
Source code in ngio/images/_ome_zarr_container.py
475 476 477 478 479 480 481 482 483 484 485 486 |
|
get_condition_table
¶
get_condition_table(name: str) -> ConditionTable
Get a condition table from the image.
Parameters:
-
name
(str
) –The name of the table.
Source code in ngio/images/_ome_zarr_container.py
488 489 490 491 492 493 494 495 496 497 498 499 |
|
get_table
¶
get_table(
name: str, check_type: TypedTable | None = None
) -> Table
Get a table from the image.
Parameters:
-
name
(str
) –The name of the table.
-
check_type
(TypedTable | None
, default:None
) –Deprecated. Please use 'get_table_as' instead, or one of the type specific get_*table() methods.
Source code in ngio/images/_ome_zarr_container.py
501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 |
|
get_table_as
¶
get_table_as(
name: str,
table_cls: type[TableType],
backend: TableBackend | None = None,
) -> TableType
Get a table from the image as a specific type.
Parameters:
-
name
(str
) –The name of the table.
-
table_cls
(type[TableType]
) –The type of the table.
-
backend
(TableBackend | None
, default:None
) –The backend to use. If None, the default backend is used.
Source code in ngio/images/_ome_zarr_container.py
521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 |
|
build_image_roi_table
¶
Compute the ROI table for an image.
Source code in ngio/images/_ome_zarr_container.py
541 542 543 |
|
build_masking_roi_table
¶
build_masking_roi_table(label: str) -> MaskingRoiTable
Compute the masking ROI table for a label.
Source code in ngio/images/_ome_zarr_container.py
545 546 547 |
|
add_table
¶
add_table(
name: str,
table: Table,
backend: TableBackend = DefaultTableBackend,
overwrite: bool = False,
) -> None
Add a table to the image.
Source code in ngio/images/_ome_zarr_container.py
549 550 551 552 553 554 555 556 557 558 559 |
|
list_labels
¶
List all labels in the image.
Source code in ngio/images/_ome_zarr_container.py
561 562 563 564 565 566 |
|
get_label
¶
get_label(
name: str,
path: str | None = None,
pixel_size: PixelSize | None = None,
strict: bool = False,
) -> Label
Get a label from the group.
Parameters:
-
name
(str
) –The name of the label.
-
path
(str | None
, default:None
) –The path to the image in the ome_zarr file.
-
pixel_size
(PixelSize | None
, default:None
) –The pixel size of the image.
-
strict
(bool
, default:False
) –Only used if the pixel size is provided. If True, the pixel size must match the image pixel size exactly. If False, the closest pixel size level will be returned.
Source code in ngio/images/_ome_zarr_container.py
568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 |
|
get_masked_label
¶
get_masked_label(
label_name: str,
masking_label_name: str,
masking_table_name: str | None = None,
path: str | None = None,
pixel_size: PixelSize | None = None,
strict: bool = False,
) -> MaskedLabel
Get a masked image at a specific level.
Parameters:
-
label_name
(str
) –The name of the label.
-
masking_label_name
(str
) –The name of the masking label.
-
masking_table_name
(str | None
, default:None
) –The name of the masking table.
-
path
(str | None
, default:None
) –The path to the image in the ome_zarr file.
-
pixel_size
(PixelSize | None
, default:None
) –The pixel size of the image.
-
strict
(bool
, default:False
) –Only used if the pixel size is provided. If True, the pixel size must match the image pixel size exactly. If False, the closest pixel size level will be returned.
Source code in ngio/images/_ome_zarr_container.py
589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 |
|
derive_label
¶
derive_label(
name: str,
ref_image: Image | Label | None = None,
shape: Collection[int] | None = None,
pixel_size: PixelSize | None = None,
axes_names: Collection[str] | None = None,
chunks: Collection[int] | None = None,
dtype: str | None = None,
overwrite: bool = False,
) -> Label
Create an empty OME-Zarr label from a reference image.
And add the label to the /labels group.
Parameters:
-
name
(str
) –The name of the new image.
-
ref_image
(Image | Label | None
, default:None
) –A reference image that will be used to create the new image.
-
shape
(Collection[int] | None
, default:None
) –The shape of the new image.
-
pixel_size
(PixelSize | None
, default:None
) –The pixel size of the new image.
-
axes_names
(Collection[str] | None
, default:None
) –The axes names of the new image. For labels, the channel axis is not allowed.
-
chunks
(Collection[int] | None
, default:None
) –The chunk shape of the new image.
-
dtype
(str | None
, default:None
) –The data type of the new image.
-
overwrite
(bool
, default:False
) –Whether to overwrite an existing image.
Returns:
-
Label
(Label
) –The new label.
Source code in ngio/images/_ome_zarr_container.py
629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 |
|