ngio 0.3.5__py3-none-any.whl → 0.4.0a1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ngio/__init__.py +6 -0
- ngio/common/__init__.py +50 -48
- ngio/common/_array_io_pipes.py +549 -0
- ngio/common/_array_io_utils.py +508 -0
- ngio/common/_dimensions.py +63 -27
- ngio/common/_masking_roi.py +38 -10
- ngio/common/_pyramid.py +9 -7
- ngio/common/_roi.py +571 -72
- ngio/common/_synt_images_utils.py +101 -0
- ngio/common/_zoom.py +17 -12
- ngio/common/transforms/__init__.py +5 -0
- ngio/common/transforms/_label.py +12 -0
- ngio/common/transforms/_zoom.py +109 -0
- ngio/experimental/__init__.py +5 -0
- ngio/experimental/iterators/__init__.py +17 -0
- ngio/experimental/iterators/_abstract_iterator.py +170 -0
- ngio/experimental/iterators/_feature.py +151 -0
- ngio/experimental/iterators/_image_processing.py +169 -0
- ngio/experimental/iterators/_rois_utils.py +127 -0
- ngio/experimental/iterators/_segmentation.py +278 -0
- ngio/hcs/_plate.py +41 -36
- ngio/images/__init__.py +22 -1
- ngio/images/_abstract_image.py +247 -117
- ngio/images/_create.py +15 -15
- ngio/images/_create_synt_container.py +128 -0
- ngio/images/_image.py +425 -62
- ngio/images/_label.py +33 -30
- ngio/images/_masked_image.py +396 -122
- ngio/images/_ome_zarr_container.py +203 -66
- ngio/{common → images}/_table_ops.py +41 -41
- ngio/ome_zarr_meta/ngio_specs/__init__.py +2 -8
- ngio/ome_zarr_meta/ngio_specs/_axes.py +151 -128
- ngio/ome_zarr_meta/ngio_specs/_channels.py +55 -18
- ngio/ome_zarr_meta/ngio_specs/_dataset.py +7 -7
- ngio/ome_zarr_meta/ngio_specs/_ngio_hcs.py +3 -3
- ngio/ome_zarr_meta/ngio_specs/_ngio_image.py +11 -68
- ngio/ome_zarr_meta/v04/_v04_spec_utils.py +1 -1
- ngio/resources/20200812-CardiomyocyteDifferentiation14-Cycle1_B03/mask.png +0 -0
- ngio/resources/20200812-CardiomyocyteDifferentiation14-Cycle1_B03/nuclei.png +0 -0
- ngio/resources/20200812-CardiomyocyteDifferentiation14-Cycle1_B03/raw.jpg +0 -0
- ngio/resources/__init__.py +54 -0
- ngio/resources/resource_model.py +35 -0
- ngio/tables/backends/_abstract_backend.py +5 -6
- ngio/tables/backends/_anndata.py +1 -1
- ngio/tables/backends/_anndata_utils.py +3 -3
- ngio/tables/backends/_non_zarr_backends.py +1 -1
- ngio/tables/backends/_table_backends.py +0 -1
- ngio/tables/backends/_utils.py +3 -3
- ngio/tables/v1/_roi_table.py +156 -69
- ngio/utils/__init__.py +2 -3
- ngio/utils/_logger.py +19 -0
- ngio/utils/_zarr_utils.py +1 -5
- {ngio-0.3.5.dist-info → ngio-0.4.0a1.dist-info}/METADATA +3 -1
- ngio-0.4.0a1.dist-info/RECORD +76 -0
- ngio/common/_array_pipe.py +0 -288
- ngio/common/_axes_transforms.py +0 -64
- ngio/common/_common_types.py +0 -5
- ngio/common/_slicer.py +0 -96
- ngio-0.3.5.dist-info/RECORD +0 -61
- {ngio-0.3.5.dist-info → ngio-0.4.0a1.dist-info}/WHEEL +0 -0
- {ngio-0.3.5.dist-info → ngio-0.4.0a1.dist-info}/licenses/LICENSE +0 -0
ngio/hcs/_plate.py
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
"""A module for handling the Plate
|
|
1
|
+
"""A module for handling the Plate Sequence in an OME-Zarr file."""
|
|
2
2
|
|
|
3
3
|
import asyncio
|
|
4
4
|
import warnings
|
|
5
|
-
from collections.abc import
|
|
5
|
+
from collections.abc import Sequence
|
|
6
6
|
from typing import Literal
|
|
7
7
|
|
|
8
|
-
from ngio.
|
|
8
|
+
from ngio.images import (
|
|
9
|
+
OmeZarrContainer,
|
|
9
10
|
concatenate_image_tables,
|
|
10
11
|
concatenate_image_tables_as,
|
|
11
12
|
concatenate_image_tables_as_async,
|
|
@@ -13,7 +14,6 @@ from ngio.common import (
|
|
|
13
14
|
list_image_tables,
|
|
14
15
|
list_image_tables_async,
|
|
15
16
|
)
|
|
16
|
-
from ngio.images import OmeZarrContainer
|
|
17
17
|
from ngio.ome_zarr_meta import (
|
|
18
18
|
ImageInWellPath,
|
|
19
19
|
NgffVersions,
|
|
@@ -67,7 +67,7 @@ class MockLock:
|
|
|
67
67
|
|
|
68
68
|
|
|
69
69
|
class OmeZarrWell:
|
|
70
|
-
"""A class to handle the Well
|
|
70
|
+
"""A class to handle the Well Sequence in an OME-Zarr file."""
|
|
71
71
|
|
|
72
72
|
def __init__(self, group_handler: ZarrGroupHandler) -> None:
|
|
73
73
|
"""Initialize the LabelGroupHandler.
|
|
@@ -190,7 +190,7 @@ class OmeZarrWell:
|
|
|
190
190
|
acquisition_id (int | None): The acquisition id to filter the images.
|
|
191
191
|
strict (bool): Whether to check if the acquisition id is already exists
|
|
192
192
|
in the well. Defaults to True. If False this might lead to
|
|
193
|
-
|
|
193
|
+
acquisition in a well that does not exist at the plate level.
|
|
194
194
|
"""
|
|
195
195
|
return self._add_image(
|
|
196
196
|
image_path=image_path,
|
|
@@ -200,11 +200,11 @@ class OmeZarrWell:
|
|
|
200
200
|
)
|
|
201
201
|
|
|
202
202
|
|
|
203
|
-
def _build_extras(paths:
|
|
203
|
+
def _build_extras(paths: Sequence[str]) -> list[dict[str, str]]:
|
|
204
204
|
"""Build the extras for the images.
|
|
205
205
|
|
|
206
206
|
Args:
|
|
207
|
-
paths (
|
|
207
|
+
paths (Sequence[str]): The paths of the images.
|
|
208
208
|
|
|
209
209
|
Returns:
|
|
210
210
|
list[dict[str, str]]: The extras for the images.
|
|
@@ -223,7 +223,7 @@ def _build_extras(paths: Collection[str]) -> list[dict[str, str]]:
|
|
|
223
223
|
|
|
224
224
|
|
|
225
225
|
class OmeZarrPlate:
|
|
226
|
-
"""A class to handle the Plate
|
|
226
|
+
"""A class to handle the Plate Sequence in an OME-Zarr file."""
|
|
227
227
|
|
|
228
228
|
def __init__(
|
|
229
229
|
self,
|
|
@@ -382,7 +382,8 @@ class OmeZarrPlate:
|
|
|
382
382
|
"""
|
|
383
383
|
wells = self._group_handler.get_from_cache("wells")
|
|
384
384
|
if wells is not None:
|
|
385
|
-
|
|
385
|
+
assert isinstance(wells, dict)
|
|
386
|
+
return wells
|
|
386
387
|
|
|
387
388
|
def process_well(well_path):
|
|
388
389
|
group_handler = self._group_handler.derive_handler(well_path)
|
|
@@ -410,7 +411,8 @@ class OmeZarrPlate:
|
|
|
410
411
|
"""
|
|
411
412
|
wells = self._group_handler.get_from_cache("wells")
|
|
412
413
|
if wells is not None:
|
|
413
|
-
|
|
414
|
+
assert isinstance(wells, dict)
|
|
415
|
+
return wells
|
|
414
416
|
|
|
415
417
|
def process_well(well_path):
|
|
416
418
|
group_handler = self._group_handler.derive_handler(well_path)
|
|
@@ -442,7 +444,8 @@ class OmeZarrPlate:
|
|
|
442
444
|
"""
|
|
443
445
|
images = self._group_handler.get_from_cache("images")
|
|
444
446
|
if images is not None:
|
|
445
|
-
|
|
447
|
+
assert isinstance(images, dict)
|
|
448
|
+
return images
|
|
446
449
|
|
|
447
450
|
paths = await self.images_paths_async(acquisition=acquisition)
|
|
448
451
|
|
|
@@ -473,7 +476,8 @@ class OmeZarrPlate:
|
|
|
473
476
|
"""
|
|
474
477
|
images = self._group_handler.get_from_cache("images")
|
|
475
478
|
if images is not None:
|
|
476
|
-
|
|
479
|
+
assert isinstance(images, dict)
|
|
480
|
+
return images
|
|
477
481
|
paths = self.images_paths(acquisition=acquisition)
|
|
478
482
|
|
|
479
483
|
def process_image(image_path):
|
|
@@ -969,9 +973,9 @@ class OmeZarrPlate:
|
|
|
969
973
|
If 'common', return only common tables between all images.
|
|
970
974
|
If 'all', return all tables. Defaults to 'common'.
|
|
971
975
|
"""
|
|
972
|
-
images = self.get_images(acquisition=acquisition)
|
|
976
|
+
images = tuple(self.get_images(acquisition=acquisition).values())
|
|
973
977
|
return list_image_tables(
|
|
974
|
-
images=images
|
|
978
|
+
images=images,
|
|
975
979
|
filter_types=filter_types,
|
|
976
980
|
mode=mode,
|
|
977
981
|
)
|
|
@@ -993,15 +997,16 @@ class OmeZarrPlate:
|
|
|
993
997
|
If 'all', return all tables. Defaults to 'common'.
|
|
994
998
|
"""
|
|
995
999
|
images = await self.get_images_async(acquisition=acquisition)
|
|
1000
|
+
images = tuple(images.values())
|
|
996
1001
|
return await list_image_tables_async(
|
|
997
|
-
images=images
|
|
1002
|
+
images=images,
|
|
998
1003
|
filter_types=filter_types,
|
|
999
1004
|
mode=mode,
|
|
1000
1005
|
)
|
|
1001
1006
|
|
|
1002
1007
|
def concatenate_image_tables(
|
|
1003
1008
|
self,
|
|
1004
|
-
|
|
1009
|
+
name: str,
|
|
1005
1010
|
acquisition: int | None = None,
|
|
1006
1011
|
strict: bool = True,
|
|
1007
1012
|
index_key: str | None = None,
|
|
@@ -1010,7 +1015,7 @@ class OmeZarrPlate:
|
|
|
1010
1015
|
"""Concatenate tables from all images in the plate.
|
|
1011
1016
|
|
|
1012
1017
|
Args:
|
|
1013
|
-
|
|
1018
|
+
name: The name of the table to concatenate.
|
|
1014
1019
|
index_key: The key to use for the index of the concatenated table.
|
|
1015
1020
|
acquisition: The acquisition id to filter the images.
|
|
1016
1021
|
strict: If True, raise an error if the table is not found in the image.
|
|
@@ -1021,11 +1026,11 @@ class OmeZarrPlate:
|
|
|
1021
1026
|
if 'lazy', the table will be loaded as a lazy frame.
|
|
1022
1027
|
"""
|
|
1023
1028
|
images = self.get_images(acquisition=acquisition)
|
|
1024
|
-
extras = _build_extras(images.keys())
|
|
1029
|
+
extras = _build_extras(tuple(images.keys()))
|
|
1025
1030
|
return concatenate_image_tables(
|
|
1026
|
-
images=images.values(),
|
|
1031
|
+
images=tuple(images.values()),
|
|
1027
1032
|
extras=extras,
|
|
1028
|
-
|
|
1033
|
+
name=name,
|
|
1029
1034
|
index_key=index_key,
|
|
1030
1035
|
strict=strict,
|
|
1031
1036
|
mode=mode,
|
|
@@ -1033,7 +1038,7 @@ class OmeZarrPlate:
|
|
|
1033
1038
|
|
|
1034
1039
|
def concatenate_image_tables_as(
|
|
1035
1040
|
self,
|
|
1036
|
-
|
|
1041
|
+
name: str,
|
|
1037
1042
|
table_cls: type[TableType],
|
|
1038
1043
|
acquisition: int | None = None,
|
|
1039
1044
|
index_key: str | None = None,
|
|
@@ -1043,7 +1048,7 @@ class OmeZarrPlate:
|
|
|
1043
1048
|
"""Concatenate tables from all images in the plate as a specific type.
|
|
1044
1049
|
|
|
1045
1050
|
Args:
|
|
1046
|
-
|
|
1051
|
+
name: The name of the table to concatenate.
|
|
1047
1052
|
table_cls: The type of the table to concatenate.
|
|
1048
1053
|
index_key: The key to use for the index of the concatenated table.
|
|
1049
1054
|
acquisition: The acquisition id to filter the images.
|
|
@@ -1055,11 +1060,11 @@ class OmeZarrPlate:
|
|
|
1055
1060
|
if 'lazy', the table will be loaded as a lazy frame.
|
|
1056
1061
|
"""
|
|
1057
1062
|
images = self.get_images(acquisition=acquisition)
|
|
1058
|
-
extras = _build_extras(images.keys())
|
|
1063
|
+
extras = _build_extras(tuple(images.keys()))
|
|
1059
1064
|
return concatenate_image_tables_as(
|
|
1060
|
-
images=images.values(),
|
|
1065
|
+
images=tuple(images.values()),
|
|
1061
1066
|
extras=extras,
|
|
1062
|
-
|
|
1067
|
+
name=name,
|
|
1063
1068
|
table_cls=table_cls,
|
|
1064
1069
|
index_key=index_key,
|
|
1065
1070
|
strict=strict,
|
|
@@ -1068,7 +1073,7 @@ class OmeZarrPlate:
|
|
|
1068
1073
|
|
|
1069
1074
|
async def concatenate_image_tables_async(
|
|
1070
1075
|
self,
|
|
1071
|
-
|
|
1076
|
+
name: str,
|
|
1072
1077
|
acquisition: int | None = None,
|
|
1073
1078
|
index_key: str | None = None,
|
|
1074
1079
|
strict: bool = True,
|
|
@@ -1077,7 +1082,7 @@ class OmeZarrPlate:
|
|
|
1077
1082
|
"""Concatenate tables from all images in the plate asynchronously.
|
|
1078
1083
|
|
|
1079
1084
|
Args:
|
|
1080
|
-
|
|
1085
|
+
name: The name of the table to concatenate.
|
|
1081
1086
|
index_key: The key to use for the index of the concatenated table.
|
|
1082
1087
|
acquisition: The acquisition id to filter the images.
|
|
1083
1088
|
index_key: If a string is provided, a new index column will be created
|
|
@@ -1088,11 +1093,11 @@ class OmeZarrPlate:
|
|
|
1088
1093
|
if 'lazy', the table will be loaded as a lazy frame.
|
|
1089
1094
|
"""
|
|
1090
1095
|
images = await self.get_images_async(acquisition=acquisition)
|
|
1091
|
-
extras = _build_extras(images.keys())
|
|
1096
|
+
extras = _build_extras(tuple(images.keys()))
|
|
1092
1097
|
return await concatenate_image_tables_async(
|
|
1093
|
-
images=images.values(),
|
|
1098
|
+
images=tuple(images.values()),
|
|
1094
1099
|
extras=extras,
|
|
1095
|
-
|
|
1100
|
+
name=name,
|
|
1096
1101
|
index_key=index_key,
|
|
1097
1102
|
strict=strict,
|
|
1098
1103
|
mode=mode,
|
|
@@ -1100,7 +1105,7 @@ class OmeZarrPlate:
|
|
|
1100
1105
|
|
|
1101
1106
|
async def concatenate_image_tables_as_async(
|
|
1102
1107
|
self,
|
|
1103
|
-
|
|
1108
|
+
name: str,
|
|
1104
1109
|
table_cls: type[TableType],
|
|
1105
1110
|
acquisition: int | None = None,
|
|
1106
1111
|
index_key: str | None = None,
|
|
@@ -1110,7 +1115,7 @@ class OmeZarrPlate:
|
|
|
1110
1115
|
"""Concatenate tables from all images in the plate as a specific type.
|
|
1111
1116
|
|
|
1112
1117
|
Args:
|
|
1113
|
-
|
|
1118
|
+
name: The name of the table to concatenate.
|
|
1114
1119
|
table_cls: The type of the table to concatenate.
|
|
1115
1120
|
index_key: The key to use for the index of the concatenated table.
|
|
1116
1121
|
acquisition: The acquisition id to filter the images.
|
|
@@ -1122,11 +1127,11 @@ class OmeZarrPlate:
|
|
|
1122
1127
|
if 'lazy', the table will be loaded as a lazy frame.
|
|
1123
1128
|
"""
|
|
1124
1129
|
images = await self.get_images_async(acquisition=acquisition)
|
|
1125
|
-
extras = _build_extras(images.keys())
|
|
1130
|
+
extras = _build_extras(tuple(images.keys()))
|
|
1126
1131
|
return await concatenate_image_tables_as_async(
|
|
1127
|
-
images=images.values(),
|
|
1132
|
+
images=tuple(images.values()),
|
|
1128
1133
|
extras=extras,
|
|
1129
|
-
|
|
1134
|
+
name=name,
|
|
1130
1135
|
table_cls=table_cls,
|
|
1131
1136
|
index_key=index_key,
|
|
1132
1137
|
strict=strict,
|
ngio/images/__init__.py
CHANGED
|
@@ -1,23 +1,44 @@
|
|
|
1
1
|
"""OME-Zarr object models."""
|
|
2
2
|
|
|
3
|
-
from ngio.images.
|
|
3
|
+
from ngio.images._create_synt_container import create_synthetic_ome_zarr
|
|
4
|
+
from ngio.images._image import ChannelSelectionModel, Image, ImagesContainer
|
|
4
5
|
from ngio.images._label import Label, LabelsContainer
|
|
5
6
|
from ngio.images._ome_zarr_container import (
|
|
6
7
|
OmeZarrContainer,
|
|
7
8
|
create_empty_ome_zarr,
|
|
8
9
|
create_ome_zarr_from_array,
|
|
9
10
|
open_image,
|
|
11
|
+
open_label,
|
|
10
12
|
open_ome_zarr_container,
|
|
11
13
|
)
|
|
14
|
+
from ngio.images._table_ops import (
|
|
15
|
+
concatenate_image_tables,
|
|
16
|
+
concatenate_image_tables_as,
|
|
17
|
+
concatenate_image_tables_as_async,
|
|
18
|
+
concatenate_image_tables_async,
|
|
19
|
+
conctatenate_tables,
|
|
20
|
+
list_image_tables,
|
|
21
|
+
list_image_tables_async,
|
|
22
|
+
)
|
|
12
23
|
|
|
13
24
|
__all__ = [
|
|
25
|
+
"ChannelSelectionModel",
|
|
14
26
|
"Image",
|
|
15
27
|
"ImagesContainer",
|
|
16
28
|
"Label",
|
|
17
29
|
"LabelsContainer",
|
|
18
30
|
"OmeZarrContainer",
|
|
31
|
+
"concatenate_image_tables",
|
|
32
|
+
"concatenate_image_tables_as",
|
|
33
|
+
"concatenate_image_tables_as_async",
|
|
34
|
+
"concatenate_image_tables_async",
|
|
35
|
+
"conctatenate_tables",
|
|
19
36
|
"create_empty_ome_zarr",
|
|
20
37
|
"create_ome_zarr_from_array",
|
|
38
|
+
"create_synthetic_ome_zarr",
|
|
39
|
+
"list_image_tables",
|
|
40
|
+
"list_image_tables_async",
|
|
21
41
|
"open_image",
|
|
42
|
+
"open_label",
|
|
22
43
|
"open_ome_zarr_container",
|
|
23
44
|
]
|