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
741 742 743 744 745 746 747 748 749 750 751 752 | |
Create an OME-Zarr Container¶
ngio.create_empty_ome_zarr
¶
create_empty_ome_zarr(
store: StoreOrGroup,
shape: Sequence[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: Sequence[str] | None = None,
name: str | None = None,
chunks: Sequence[int] | None = None,
dtype: str = "uint16",
dimension_separator: DIMENSION_SEPARATOR = "/",
compressor="default",
channel_labels: list[str] | None = None,
channel_wavelengths: list[str] | None = None,
channel_colors: Sequence[str] | None = None,
channel_active: Sequence[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(Sequence[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(Sequence[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(Sequence[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".
-
dimension_separator(DIMENSION_SEPARATOR, default:'/') –The dimension separator to use. Defaults to "/".
-
compressor–The compressor to use. Defaults to "default".
-
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(Sequence[str] | None, default:None) –The colors of the channels. Defaults to None.
-
channel_active(Sequence[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
826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 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 | |
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: Sequence[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: Sequence[str] | None = None,
channel_active: Sequence[bool] | None = None,
name: str | None = None,
chunks: Sequence[int] | None = None,
dimension_separator: DIMENSION_SEPARATOR = "/",
compressor: str = "default",
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(Sequence[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(Sequence[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(Sequence[str] | None, default:None) –The colors of the channels. Defaults to None.
-
channel_active(Sequence[bool] | None, default:None) –Whether the channels are active. Defaults to None.
-
dimension_separator(DIMENSION_SEPARATOR, default:'/') –The separator to use for dimensions. Defaults to "/".
-
compressor(str, default:'default') –The compressor to use. Defaults to "default".
-
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
923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 | |
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
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
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
236 237 238 239 240 241 242 243 | |
set_channel_meta
¶
set_channel_meta(
labels: Sequence[str] | int | None = None,
wavelength_id: Sequence[str] | None = None,
percentiles: tuple[float, float] | None = None,
colors: Sequence[str] | None = None,
active: Sequence[bool] | None = None,
**omero_kwargs: dict,
) -> None
Create a ChannelsMeta object with the default unit.
Source code in ngio/images/_ome_zarr_container.py
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | |
set_channel_percentiles
¶
Update the percentiles of the image.
Source code in ngio/images/_ome_zarr_container.py
266 267 268 269 270 271 272 273 274 | |
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
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 | |
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
296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 | |
get_masked_image
¶
get_masked_image(
masking_label_name: str | None = None,
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 | None, default:None) –The name of the masking label to use. If None, the masking table must be provided.
-
masking_table_name(str | None, default:None) –The name of the masking table to use. If None, the masking label must be provided.
-
path(str | None, default:None) –The path to the image in the ome_zarr file. If None, the first level will be used.
-
pixel_size(PixelSize | None, default:None) –The pixel size of the image. This is only used if path is None.
-
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
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 | |
derive_image
¶
derive_image(
store: StoreOrGroup,
ref_path: str | None = None,
shape: Sequence[int] | None = None,
labels: Sequence[str] | None = None,
pixel_size: PixelSize | None = None,
axes_names: Sequence[str] | None = None,
name: str | None = None,
chunks: Sequence[int] | None = None,
dtype: str | None = None,
dimension_separator: DIMENSION_SEPARATOR | None = None,
compressor=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(Sequence[int] | None, default:None) –The shape of the new image.
-
labels(Sequence[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(Sequence[str] | None, default:None) –The axes names of the new image.
-
chunks(Sequence[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.
-
dimension_separator(DIMENSION_SEPARATOR | None, default:None) –The dimension separator to use. If None, the dimension separator of the reference image will be used.
-
compressor–The compressor to use. If None, the compressor of the reference image will be used.
-
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
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 469 470 471 472 473 474 475 476 477 | |
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
479 480 481 482 483 484 485 486 487 | |
list_roi_tables
¶
List all ROI tables in the image.
Source code in ngio/images/_ome_zarr_container.py
489 490 491 492 493 494 495 496 497 | |
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
499 500 501 502 503 504 505 506 507 508 | |
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
510 511 512 513 514 515 516 517 518 519 520 521 | |
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
523 524 525 526 527 528 529 530 531 532 533 534 | |
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
536 537 538 539 540 541 542 543 544 545 546 547 | |
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
549 550 551 552 553 554 555 556 557 558 559 560 | |
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
562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 | |
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
582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 | |
build_image_roi_table
¶
Compute the ROI table for an image.
Source code in ngio/images/_ome_zarr_container.py
602 603 604 | |
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
606 607 608 | |
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
610 611 612 613 614 615 616 617 618 619 620 | |
list_labels
¶
List all labels in the image.
Source code in ngio/images/_ome_zarr_container.py
622 623 624 625 626 627 | |
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
629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 | |
get_masked_label
¶
get_masked_label(
label_name: str,
masking_label_name: str | None = None,
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 | None, default:None) –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
650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 | |
derive_label
¶
derive_label(
name: str,
ref_image: Image | Label | None = None,
shape: Sequence[int] | None = None,
pixel_size: PixelSize | None = None,
axes_names: Sequence[str] | None = None,
chunks: Sequence[int] | None = None,
dtype: str = "uint32",
dimension_separator: DIMENSION_SEPARATOR | None = None,
compressor=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(Sequence[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(Sequence[str] | None, default:None) –The axes names of the new image. For labels, the channel axis is not allowed.
-
chunks(Sequence[int] | None, default:None) –The chunk shape of the new image.
-
dtype(str, default:'uint32') –The data type of the new label.
-
dimension_separator(DIMENSION_SEPARATOR | None, default:None) –The dimension separator to use. If None, the dimension separator of the reference image will be used.
-
compressor–The compressor to use. If None, the compressor of the reference image will be used.
-
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
687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 | |