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.
Files changed (61) hide show
  1. ngio/__init__.py +6 -0
  2. ngio/common/__init__.py +50 -48
  3. ngio/common/_array_io_pipes.py +549 -0
  4. ngio/common/_array_io_utils.py +508 -0
  5. ngio/common/_dimensions.py +63 -27
  6. ngio/common/_masking_roi.py +38 -10
  7. ngio/common/_pyramid.py +9 -7
  8. ngio/common/_roi.py +571 -72
  9. ngio/common/_synt_images_utils.py +101 -0
  10. ngio/common/_zoom.py +17 -12
  11. ngio/common/transforms/__init__.py +5 -0
  12. ngio/common/transforms/_label.py +12 -0
  13. ngio/common/transforms/_zoom.py +109 -0
  14. ngio/experimental/__init__.py +5 -0
  15. ngio/experimental/iterators/__init__.py +17 -0
  16. ngio/experimental/iterators/_abstract_iterator.py +170 -0
  17. ngio/experimental/iterators/_feature.py +151 -0
  18. ngio/experimental/iterators/_image_processing.py +169 -0
  19. ngio/experimental/iterators/_rois_utils.py +127 -0
  20. ngio/experimental/iterators/_segmentation.py +278 -0
  21. ngio/hcs/_plate.py +41 -36
  22. ngio/images/__init__.py +22 -1
  23. ngio/images/_abstract_image.py +247 -117
  24. ngio/images/_create.py +15 -15
  25. ngio/images/_create_synt_container.py +128 -0
  26. ngio/images/_image.py +425 -62
  27. ngio/images/_label.py +33 -30
  28. ngio/images/_masked_image.py +396 -122
  29. ngio/images/_ome_zarr_container.py +203 -66
  30. ngio/{common → images}/_table_ops.py +41 -41
  31. ngio/ome_zarr_meta/ngio_specs/__init__.py +2 -8
  32. ngio/ome_zarr_meta/ngio_specs/_axes.py +151 -128
  33. ngio/ome_zarr_meta/ngio_specs/_channels.py +55 -18
  34. ngio/ome_zarr_meta/ngio_specs/_dataset.py +7 -7
  35. ngio/ome_zarr_meta/ngio_specs/_ngio_hcs.py +3 -3
  36. ngio/ome_zarr_meta/ngio_specs/_ngio_image.py +11 -68
  37. ngio/ome_zarr_meta/v04/_v04_spec_utils.py +1 -1
  38. ngio/resources/20200812-CardiomyocyteDifferentiation14-Cycle1_B03/mask.png +0 -0
  39. ngio/resources/20200812-CardiomyocyteDifferentiation14-Cycle1_B03/nuclei.png +0 -0
  40. ngio/resources/20200812-CardiomyocyteDifferentiation14-Cycle1_B03/raw.jpg +0 -0
  41. ngio/resources/__init__.py +54 -0
  42. ngio/resources/resource_model.py +35 -0
  43. ngio/tables/backends/_abstract_backend.py +5 -6
  44. ngio/tables/backends/_anndata.py +1 -1
  45. ngio/tables/backends/_anndata_utils.py +3 -3
  46. ngio/tables/backends/_non_zarr_backends.py +1 -1
  47. ngio/tables/backends/_table_backends.py +0 -1
  48. ngio/tables/backends/_utils.py +3 -3
  49. ngio/tables/v1/_roi_table.py +156 -69
  50. ngio/utils/__init__.py +2 -3
  51. ngio/utils/_logger.py +19 -0
  52. ngio/utils/_zarr_utils.py +1 -5
  53. {ngio-0.3.5.dist-info → ngio-0.4.0a1.dist-info}/METADATA +3 -1
  54. ngio-0.4.0a1.dist-info/RECORD +76 -0
  55. ngio/common/_array_pipe.py +0 -288
  56. ngio/common/_axes_transforms.py +0 -64
  57. ngio/common/_common_types.py +0 -5
  58. ngio/common/_slicer.py +0 -96
  59. ngio-0.3.5.dist-info/RECORD +0 -61
  60. {ngio-0.3.5.dist-info → ngio-0.4.0a1.dist-info}/WHEEL +0 -0
  61. {ngio-0.3.5.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 Collection
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: Collection[TableWithExtras], index_key: str | None = None
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: Collection[TableWithExtras], index_key: str | None = None
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: Collection[TableWithExtras],
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: Collection[OmeZarrContainer],
151
- extras: Collection[dict[str, str]],
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: Collection[OmeZarrContainer],
163
- extras: Collection[dict[str, str]],
164
- table_name: str,
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 table_name not in image.list_tables():
175
+ if not strict and name not in image.list_tables():
176
176
  continue
177
- table = image.get_table(table_name)
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: Collection[OmeZarrContainer],
190
- extras: Collection[dict[str, str]],
191
- table_name: str,
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
- table_name: The name of the table to concatenate.
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
- table_name=table_name,
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: Collection[OmeZarrContainer],
223
- extras: Collection[dict[str, str]],
224
- table_name: str,
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
- table_name: The name of the table to concatenate.
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
- table_name=table_name,
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: Collection[OmeZarrContainer],
262
- extras: Collection[dict[str, str]],
263
- table_name: str,
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
- table_name: str,
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 table_name not in image.list_tables():
280
+ if not strict and name not in image.list_tables():
281
281
  return None
282
- _table = image.get_table(table_name)
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
- table_name=table_name,
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: Collection[OmeZarrContainer],
319
- extras: Collection[dict[str, str]],
320
- table_name: str,
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
- table_name: The name of the table to concatenate.
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
- table_name=table_name,
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: Collection[OmeZarrContainer],
352
- extras: Collection[dict[str, str]],
353
- table_name: str,
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
- table_name: The name of the table to concatenate.
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
- table_name=table_name,
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 _table_names in tables_names for name in _table_names]
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: Collection[OmeZarrContainer],
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: Collection[OmeZarrContainer],
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",