ngio 0.3.4__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 +6 -15
- 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 -2
- 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.4.dist-info → ngio-0.4.0a1.dist-info}/METADATA +12 -10
- 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.4.dist-info/RECORD +0 -61
- {ngio-0.3.4.dist-info → ngio-0.4.0a1.dist-info}/WHEEL +0 -0
- {ngio-0.3.4.dist-info → ngio-0.4.0a1.dist-info}/licenses/LICENSE +0 -0
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import asyncio
|
|
4
4
|
from collections import Counter
|
|
5
|
-
from collections.abc import
|
|
5
|
+
from collections.abc import Sequence
|
|
6
6
|
from dataclasses import dataclass, field
|
|
7
7
|
from typing import Literal
|
|
8
8
|
|
|
@@ -76,7 +76,7 @@ def _add_const_columns_pl(
|
|
|
76
76
|
|
|
77
77
|
|
|
78
78
|
def _pd_concat(
|
|
79
|
-
tables:
|
|
79
|
+
tables: Sequence[TableWithExtras], index_key: str | None = None
|
|
80
80
|
) -> pd.DataFrame:
|
|
81
81
|
"""Concatenate tables from different plates into a single table."""
|
|
82
82
|
if len(tables) == 0:
|
|
@@ -93,7 +93,7 @@ def _pd_concat(
|
|
|
93
93
|
|
|
94
94
|
|
|
95
95
|
def _pl_concat(
|
|
96
|
-
tables:
|
|
96
|
+
tables: Sequence[TableWithExtras], index_key: str | None = None
|
|
97
97
|
) -> pl.LazyFrame:
|
|
98
98
|
"""Concatenate tables from different plates into a single table."""
|
|
99
99
|
if len(tables) == 0:
|
|
@@ -113,7 +113,7 @@ def _pl_concat(
|
|
|
113
113
|
|
|
114
114
|
|
|
115
115
|
def conctatenate_tables(
|
|
116
|
-
tables:
|
|
116
|
+
tables: Sequence[TableWithExtras],
|
|
117
117
|
mode: Literal["eager", "lazy"] = "eager",
|
|
118
118
|
index_key: str | None = None,
|
|
119
119
|
table_cls: type[TableType] | None = None,
|
|
@@ -147,8 +147,8 @@ def conctatenate_tables(
|
|
|
147
147
|
|
|
148
148
|
|
|
149
149
|
def _check_images_and_extras(
|
|
150
|
-
images:
|
|
151
|
-
extras:
|
|
150
|
+
images: Sequence[OmeZarrContainer],
|
|
151
|
+
extras: Sequence[dict[str, str]],
|
|
152
152
|
) -> None:
|
|
153
153
|
"""Check if the images and extras are valid."""
|
|
154
154
|
if len(images) == 0:
|
|
@@ -159,9 +159,9 @@ def _check_images_and_extras(
|
|
|
159
159
|
|
|
160
160
|
|
|
161
161
|
def _concatenate_image_tables(
|
|
162
|
-
images:
|
|
163
|
-
extras:
|
|
164
|
-
|
|
162
|
+
images: Sequence[OmeZarrContainer],
|
|
163
|
+
extras: Sequence[dict[str, str]],
|
|
164
|
+
name: str,
|
|
165
165
|
table_cls: type[TableType] | None = None,
|
|
166
166
|
index_key: str | None = None,
|
|
167
167
|
strict: bool = True,
|
|
@@ -172,9 +172,9 @@ def _concatenate_image_tables(
|
|
|
172
172
|
|
|
173
173
|
tables = []
|
|
174
174
|
for image, extra in zip(images, extras, strict=True):
|
|
175
|
-
if not strict and
|
|
175
|
+
if not strict and name not in image.list_tables():
|
|
176
176
|
continue
|
|
177
|
-
table = image.get_table(
|
|
177
|
+
table = image.get_table(name)
|
|
178
178
|
tables.append(TableWithExtras(table=table, extras=extra))
|
|
179
179
|
|
|
180
180
|
return conctatenate_tables(
|
|
@@ -186,9 +186,9 @@ def _concatenate_image_tables(
|
|
|
186
186
|
|
|
187
187
|
|
|
188
188
|
def concatenate_image_tables(
|
|
189
|
-
images:
|
|
190
|
-
extras:
|
|
191
|
-
|
|
189
|
+
images: Sequence[OmeZarrContainer],
|
|
190
|
+
extras: Sequence[dict[str, str]],
|
|
191
|
+
name: str,
|
|
192
192
|
index_key: str | None = None,
|
|
193
193
|
strict: bool = True,
|
|
194
194
|
mode: Literal["eager", "lazy"] = "eager",
|
|
@@ -200,7 +200,7 @@ def concatenate_image_tables(
|
|
|
200
200
|
extras: A collection of extras dictionaries for each image.
|
|
201
201
|
this will be added as columns to the table, and will be
|
|
202
202
|
concatenated with the table index to create a new index.
|
|
203
|
-
|
|
203
|
+
name: The name of the table to concatenate.
|
|
204
204
|
index_key: The key to use for the index of the concatenated table.
|
|
205
205
|
strict: If True, raise an error if the table is not found in the image.
|
|
206
206
|
mode: The mode to use for concatenation. Can be 'eager' or 'lazy'.
|
|
@@ -210,7 +210,7 @@ def concatenate_image_tables(
|
|
|
210
210
|
return _concatenate_image_tables(
|
|
211
211
|
images=images,
|
|
212
212
|
extras=extras,
|
|
213
|
-
|
|
213
|
+
name=name,
|
|
214
214
|
table_cls=None,
|
|
215
215
|
index_key=index_key,
|
|
216
216
|
strict=strict,
|
|
@@ -219,9 +219,9 @@ def concatenate_image_tables(
|
|
|
219
219
|
|
|
220
220
|
|
|
221
221
|
def concatenate_image_tables_as(
|
|
222
|
-
images:
|
|
223
|
-
extras:
|
|
224
|
-
|
|
222
|
+
images: Sequence[OmeZarrContainer],
|
|
223
|
+
extras: Sequence[dict[str, str]],
|
|
224
|
+
name: str,
|
|
225
225
|
table_cls: type[TableType],
|
|
226
226
|
index_key: str | None = None,
|
|
227
227
|
strict: bool = True,
|
|
@@ -234,7 +234,7 @@ def concatenate_image_tables_as(
|
|
|
234
234
|
extras: A collection of extras dictionaries for each image.
|
|
235
235
|
this will be added as columns to the table, and will be
|
|
236
236
|
concatenated with the table index to create a new index.
|
|
237
|
-
|
|
237
|
+
name: The name of the table to concatenate.
|
|
238
238
|
table_cls: The output will be casted to this class, if the new table_cls is
|
|
239
239
|
compatible with the table_cls of the input tables.
|
|
240
240
|
index_key: The key to use for the index of the concatenated table.
|
|
@@ -246,7 +246,7 @@ def concatenate_image_tables_as(
|
|
|
246
246
|
table = _concatenate_image_tables(
|
|
247
247
|
images=images,
|
|
248
248
|
extras=extras,
|
|
249
|
-
|
|
249
|
+
name=name,
|
|
250
250
|
table_cls=table_cls,
|
|
251
251
|
index_key=index_key,
|
|
252
252
|
strict=strict,
|
|
@@ -258,9 +258,9 @@ def concatenate_image_tables_as(
|
|
|
258
258
|
|
|
259
259
|
|
|
260
260
|
async def _concatenate_image_tables_async(
|
|
261
|
-
images:
|
|
262
|
-
extras:
|
|
263
|
-
|
|
261
|
+
images: Sequence[OmeZarrContainer],
|
|
262
|
+
extras: Sequence[dict[str, str]],
|
|
263
|
+
name: str,
|
|
264
264
|
table_cls: type[TableType] | None = None,
|
|
265
265
|
index_key: str | None = None,
|
|
266
266
|
strict: bool = True,
|
|
@@ -271,15 +271,15 @@ async def _concatenate_image_tables_async(
|
|
|
271
271
|
|
|
272
272
|
def process_image(
|
|
273
273
|
image: OmeZarrContainer,
|
|
274
|
-
|
|
274
|
+
name: str,
|
|
275
275
|
extra: dict[str, str],
|
|
276
276
|
mode: Literal["eager", "lazy"] = "eager",
|
|
277
277
|
strict: bool = True,
|
|
278
278
|
) -> TableWithExtras | None:
|
|
279
279
|
"""Process a single image and return the table."""
|
|
280
|
-
if not strict and
|
|
280
|
+
if not strict and name not in image.list_tables():
|
|
281
281
|
return None
|
|
282
|
-
_table = image.get_table(
|
|
282
|
+
_table = image.get_table(name)
|
|
283
283
|
if mode == "lazy":
|
|
284
284
|
# make sure the table is loaded lazily
|
|
285
285
|
# It the backend is not lazy, this will be
|
|
@@ -299,7 +299,7 @@ async def _concatenate_image_tables_async(
|
|
|
299
299
|
task = asyncio.to_thread(
|
|
300
300
|
process_image,
|
|
301
301
|
image=image,
|
|
302
|
-
|
|
302
|
+
name=name,
|
|
303
303
|
extra=extra,
|
|
304
304
|
strict=strict,
|
|
305
305
|
)
|
|
@@ -315,9 +315,9 @@ async def _concatenate_image_tables_async(
|
|
|
315
315
|
|
|
316
316
|
|
|
317
317
|
async def concatenate_image_tables_async(
|
|
318
|
-
images:
|
|
319
|
-
extras:
|
|
320
|
-
|
|
318
|
+
images: Sequence[OmeZarrContainer],
|
|
319
|
+
extras: Sequence[dict[str, str]],
|
|
320
|
+
name: str,
|
|
321
321
|
index_key: str | None = None,
|
|
322
322
|
strict: bool = True,
|
|
323
323
|
mode: Literal["eager", "lazy"] = "eager",
|
|
@@ -329,7 +329,7 @@ async def concatenate_image_tables_async(
|
|
|
329
329
|
extras: A collection of extras dictionaries for each image.
|
|
330
330
|
this will be added as columns to the table, and will be
|
|
331
331
|
concatenated with the table index to create a new index.
|
|
332
|
-
|
|
332
|
+
name: The name of the table to concatenate.
|
|
333
333
|
index_key: The key to use for the index of the concatenated table.
|
|
334
334
|
strict: If True, raise an error if the table is not found in the image.
|
|
335
335
|
mode: The mode to use for concatenation. Can be 'eager' or 'lazy'.
|
|
@@ -339,7 +339,7 @@ async def concatenate_image_tables_async(
|
|
|
339
339
|
return await _concatenate_image_tables_async(
|
|
340
340
|
images=images,
|
|
341
341
|
extras=extras,
|
|
342
|
-
|
|
342
|
+
name=name,
|
|
343
343
|
table_cls=None,
|
|
344
344
|
index_key=index_key,
|
|
345
345
|
strict=strict,
|
|
@@ -348,9 +348,9 @@ async def concatenate_image_tables_async(
|
|
|
348
348
|
|
|
349
349
|
|
|
350
350
|
async def concatenate_image_tables_as_async(
|
|
351
|
-
images:
|
|
352
|
-
extras:
|
|
353
|
-
|
|
351
|
+
images: Sequence[OmeZarrContainer],
|
|
352
|
+
extras: Sequence[dict[str, str]],
|
|
353
|
+
name: str,
|
|
354
354
|
table_cls: type[TableType],
|
|
355
355
|
index_key: str | None = None,
|
|
356
356
|
strict: bool = True,
|
|
@@ -363,7 +363,7 @@ async def concatenate_image_tables_as_async(
|
|
|
363
363
|
extras: A collection of extras dictionaries for each image.
|
|
364
364
|
this will be added as columns to the table, and will be
|
|
365
365
|
concatenated with the table index to create a new index.
|
|
366
|
-
|
|
366
|
+
name: The name of the table to concatenate.
|
|
367
367
|
table_cls: The output will be casted to this class, if the new table_cls is
|
|
368
368
|
compatible with the table_cls of the input tables.
|
|
369
369
|
index_key: The key to use for the index of the concatenated table.
|
|
@@ -375,7 +375,7 @@ async def concatenate_image_tables_as_async(
|
|
|
375
375
|
table = await _concatenate_image_tables_async(
|
|
376
376
|
images=images,
|
|
377
377
|
extras=extras,
|
|
378
|
-
|
|
378
|
+
name=name,
|
|
379
379
|
table_cls=table_cls,
|
|
380
380
|
index_key=index_key,
|
|
381
381
|
strict=strict,
|
|
@@ -394,7 +394,7 @@ def _tables_names_coalesce(
|
|
|
394
394
|
if num_images == 0:
|
|
395
395
|
raise ValueError("No images to concatenate.")
|
|
396
396
|
|
|
397
|
-
names = [name for
|
|
397
|
+
names = [name for _names in tables_names for name in _names]
|
|
398
398
|
names_counts = Counter(names)
|
|
399
399
|
|
|
400
400
|
if mode == "common":
|
|
@@ -411,7 +411,7 @@ def _tables_names_coalesce(
|
|
|
411
411
|
|
|
412
412
|
|
|
413
413
|
def list_image_tables(
|
|
414
|
-
images:
|
|
414
|
+
images: Sequence[OmeZarrContainer],
|
|
415
415
|
filter_types: str | None = None,
|
|
416
416
|
mode: Literal["common", "all"] = "common",
|
|
417
417
|
) -> list[str]:
|
|
@@ -436,7 +436,7 @@ def list_image_tables(
|
|
|
436
436
|
|
|
437
437
|
|
|
438
438
|
async def list_image_tables_async(
|
|
439
|
-
images:
|
|
439
|
+
images: Sequence[OmeZarrContainer],
|
|
440
440
|
filter_types: str | None = None,
|
|
441
441
|
mode: Literal["common", "all"] = "common",
|
|
442
442
|
) -> list[str]:
|
|
@@ -7,16 +7,13 @@ This models can be tr
|
|
|
7
7
|
"""
|
|
8
8
|
|
|
9
9
|
from ngio.ome_zarr_meta.ngio_specs._axes import (
|
|
10
|
-
AxesExpand,
|
|
11
10
|
AxesMapper,
|
|
12
11
|
AxesSetup,
|
|
13
|
-
AxesSqueeze,
|
|
14
|
-
AxesTransformation,
|
|
15
|
-
AxesTranspose,
|
|
16
12
|
Axis,
|
|
17
13
|
AxisType,
|
|
18
14
|
DefaultSpaceUnit,
|
|
19
15
|
DefaultTimeUnit,
|
|
16
|
+
SlicingOps,
|
|
20
17
|
SpaceUnits,
|
|
21
18
|
TimeUnits,
|
|
22
19
|
canonical_axes_order,
|
|
@@ -47,12 +44,8 @@ from ngio.ome_zarr_meta.ngio_specs._ngio_image import (
|
|
|
47
44
|
from ngio.ome_zarr_meta.ngio_specs._pixel_size import PixelSize
|
|
48
45
|
|
|
49
46
|
__all__ = [
|
|
50
|
-
"AxesExpand",
|
|
51
47
|
"AxesMapper",
|
|
52
48
|
"AxesSetup",
|
|
53
|
-
"AxesSqueeze",
|
|
54
|
-
"AxesTransformation",
|
|
55
|
-
"AxesTranspose",
|
|
56
49
|
"Axis",
|
|
57
50
|
"AxisType",
|
|
58
51
|
"Channel",
|
|
@@ -72,6 +65,7 @@ __all__ = [
|
|
|
72
65
|
"NgioPlateMeta",
|
|
73
66
|
"NgioWellMeta",
|
|
74
67
|
"PixelSize",
|
|
68
|
+
"SlicingOps",
|
|
75
69
|
"SpaceUnits",
|
|
76
70
|
"TimeUnits",
|
|
77
71
|
"canonical_axes_order",
|