ngio 0.5.0a1__py3-none-any.whl → 0.5.0a3__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 +2 -2
- ngio/common/__init__.py +11 -6
- ngio/common/_masking_roi.py +12 -41
- ngio/common/_pyramid.py +218 -78
- ngio/common/_roi.py +257 -329
- ngio/experimental/iterators/_feature.py +3 -3
- ngio/experimental/iterators/_rois_utils.py +10 -11
- ngio/hcs/_plate.py +114 -123
- ngio/images/_abstract_image.py +417 -35
- ngio/images/_create_synt_container.py +36 -43
- ngio/images/_create_utils.py +423 -0
- ngio/images/_image.py +155 -177
- ngio/images/_label.py +144 -119
- ngio/images/_ome_zarr_container.py +361 -196
- ngio/io_pipes/_io_pipes.py +9 -9
- ngio/io_pipes/_io_pipes_masked.py +7 -7
- ngio/io_pipes/_io_pipes_roi.py +6 -6
- ngio/io_pipes/_io_pipes_types.py +3 -3
- ngio/io_pipes/_match_shape.py +5 -4
- ngio/io_pipes/_ops_slices_utils.py +8 -5
- ngio/ome_zarr_meta/__init__.py +15 -18
- ngio/ome_zarr_meta/_meta_handlers.py +334 -713
- ngio/ome_zarr_meta/ngio_specs/_axes.py +1 -0
- ngio/ome_zarr_meta/ngio_specs/_dataset.py +13 -22
- ngio/ome_zarr_meta/ngio_specs/_ngio_hcs.py +54 -61
- ngio/ome_zarr_meta/ngio_specs/_ngio_image.py +14 -68
- ngio/ome_zarr_meta/v04/__init__.py +1 -1
- ngio/ome_zarr_meta/v04/{_v04_spec_utils.py → _v04_spec.py} +16 -61
- ngio/ome_zarr_meta/v05/__init__.py +1 -1
- ngio/ome_zarr_meta/v05/{_v05_spec_utils.py → _v05_spec.py} +18 -61
- ngio/tables/_tables_container.py +25 -20
- ngio/tables/backends/_anndata.py +57 -8
- ngio/tables/backends/_anndata_utils.py +1 -6
- ngio/tables/backends/_csv.py +3 -19
- ngio/tables/backends/_json.py +10 -13
- ngio/tables/backends/_parquet.py +3 -31
- ngio/tables/backends/_py_arrow_backends.py +222 -0
- ngio/tables/v1/_roi_table.py +44 -27
- ngio/utils/__init__.py +6 -12
- ngio/utils/_cache.py +48 -0
- ngio/utils/_zarr_utils.py +285 -245
- {ngio-0.5.0a1.dist-info → ngio-0.5.0a3.dist-info}/METADATA +8 -4
- {ngio-0.5.0a1.dist-info → ngio-0.5.0a3.dist-info}/RECORD +45 -45
- {ngio-0.5.0a1.dist-info → ngio-0.5.0a3.dist-info}/WHEEL +1 -1
- ngio/images/_create.py +0 -283
- ngio/tables/backends/_non_zarr_backends.py +0 -196
- ngio/utils/_logger.py +0 -50
- {ngio-0.5.0a1.dist-info → ngio-0.5.0a3.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from ngio import Roi
|
|
1
|
+
from ngio import Roi
|
|
2
2
|
from ngio.images._abstract_image import AbstractImage
|
|
3
3
|
|
|
4
4
|
|
|
@@ -48,18 +48,17 @@ def grid(
|
|
|
48
48
|
for z in range(0, z_dim, stride_z):
|
|
49
49
|
for y in range(0, y_dim, stride_y):
|
|
50
50
|
for x in range(0, x_dim, stride_x):
|
|
51
|
-
roi =
|
|
51
|
+
roi = Roi.from_values(
|
|
52
52
|
name=base_name,
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
t_length=size_t,
|
|
53
|
+
slices={
|
|
54
|
+
"x": (x, size_x),
|
|
55
|
+
"y": (y, size_y),
|
|
56
|
+
"z": (z, size_z),
|
|
57
|
+
"t": (t, size_t),
|
|
58
|
+
},
|
|
59
|
+
space="pixel",
|
|
61
60
|
)
|
|
62
|
-
new_rois.append(roi.
|
|
61
|
+
new_rois.append(roi.to_world(pixel_size=ref_image.pixel_size))
|
|
63
62
|
|
|
64
63
|
return rois_product(rois, new_rois)
|
|
65
64
|
|
ngio/hcs/_plate.py
CHANGED
|
@@ -19,11 +19,11 @@ from ngio.ome_zarr_meta import (
|
|
|
19
19
|
NgffVersions,
|
|
20
20
|
NgioPlateMeta,
|
|
21
21
|
NgioWellMeta,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
get_plate_meta_handler,
|
|
25
|
-
get_well_meta_handler,
|
|
22
|
+
PlateMetaHandler,
|
|
23
|
+
WellMetaHandler,
|
|
26
24
|
path_in_well_validation,
|
|
25
|
+
update_ngio_plate_meta,
|
|
26
|
+
update_ngio_well_meta,
|
|
27
27
|
)
|
|
28
28
|
from ngio.tables import (
|
|
29
29
|
ConditionTable,
|
|
@@ -40,17 +40,23 @@ from ngio.tables import (
|
|
|
40
40
|
)
|
|
41
41
|
from ngio.utils import (
|
|
42
42
|
AccessModeLiteral,
|
|
43
|
+
NgioCache,
|
|
44
|
+
NgioError,
|
|
43
45
|
NgioValueError,
|
|
44
46
|
StoreOrGroup,
|
|
45
47
|
ZarrGroupHandler,
|
|
46
48
|
)
|
|
47
49
|
|
|
48
50
|
|
|
49
|
-
def
|
|
51
|
+
def _try_get_table_container(
|
|
52
|
+
handler: ZarrGroupHandler, create_mode: bool = True
|
|
53
|
+
) -> TablesContainer | None:
|
|
50
54
|
"""Return a default table container."""
|
|
51
|
-
|
|
52
|
-
|
|
55
|
+
try:
|
|
56
|
+
table_handler = handler.get_handler("tables", create_mode=create_mode)
|
|
53
57
|
return TablesContainer(table_handler)
|
|
58
|
+
except NgioError:
|
|
59
|
+
return None
|
|
54
60
|
|
|
55
61
|
|
|
56
62
|
# Mock lock class that does nothing
|
|
@@ -76,7 +82,7 @@ class OmeZarrWell:
|
|
|
76
82
|
group_handler: The Zarr group handler that contains the Well.
|
|
77
83
|
"""
|
|
78
84
|
self._group_handler = group_handler
|
|
79
|
-
self._meta_handler =
|
|
85
|
+
self._meta_handler = WellMetaHandler(group_handler)
|
|
80
86
|
|
|
81
87
|
def __repr__(self) -> str:
|
|
82
88
|
"""Return a string representation of the well."""
|
|
@@ -90,7 +96,7 @@ class OmeZarrWell:
|
|
|
90
96
|
@property
|
|
91
97
|
def meta(self):
|
|
92
98
|
"""Return the metadata."""
|
|
93
|
-
return self._meta_handler.
|
|
99
|
+
return self._meta_handler.get_meta()
|
|
94
100
|
|
|
95
101
|
@property
|
|
96
102
|
def acquisition_ids(self) -> list[int]:
|
|
@@ -136,7 +142,7 @@ class OmeZarrWell:
|
|
|
136
142
|
Returns:
|
|
137
143
|
OmeZarrContainer: The image.
|
|
138
144
|
"""
|
|
139
|
-
handler = self._group_handler.
|
|
145
|
+
handler = self._group_handler.get_handler(image_path)
|
|
140
146
|
return OmeZarrContainer(handler)
|
|
141
147
|
|
|
142
148
|
def _add_image(
|
|
@@ -158,7 +164,7 @@ class OmeZarrWell:
|
|
|
158
164
|
meta = self.meta.add_image(
|
|
159
165
|
path=image_path, acquisition=acquisition_id, strict=strict
|
|
160
166
|
)
|
|
161
|
-
self.meta_handler.
|
|
167
|
+
self.meta_handler.update_meta(meta)
|
|
162
168
|
self.meta_handler._group_handler.clean_cache()
|
|
163
169
|
|
|
164
170
|
return self._group_handler.get_group(image_path, create_mode=True)
|
|
@@ -237,8 +243,14 @@ class OmeZarrPlate:
|
|
|
237
243
|
table_container: The tables container that contains plate level tables.
|
|
238
244
|
"""
|
|
239
245
|
self._group_handler = group_handler
|
|
240
|
-
self._meta_handler =
|
|
246
|
+
self._meta_handler = PlateMetaHandler(group_handler)
|
|
241
247
|
self._tables_container = table_container
|
|
248
|
+
self._wells_cache: NgioCache[OmeZarrWell] = NgioCache(
|
|
249
|
+
use_cache=self._group_handler.use_cache
|
|
250
|
+
)
|
|
251
|
+
self._images_cache: NgioCache[OmeZarrContainer] = NgioCache(
|
|
252
|
+
use_cache=self._group_handler.use_cache
|
|
253
|
+
)
|
|
242
254
|
|
|
243
255
|
def __repr__(self) -> str:
|
|
244
256
|
"""Return a string representation of the plate."""
|
|
@@ -252,7 +264,7 @@ class OmeZarrPlate:
|
|
|
252
264
|
@property
|
|
253
265
|
def meta(self):
|
|
254
266
|
"""Return the metadata."""
|
|
255
|
-
return self._meta_handler.
|
|
267
|
+
return self._meta_handler.get_meta()
|
|
256
268
|
|
|
257
269
|
@property
|
|
258
270
|
def columns(self) -> list[str]:
|
|
@@ -356,6 +368,24 @@ class OmeZarrPlate:
|
|
|
356
368
|
well = self.get_well(row=row, column=column)
|
|
357
369
|
return well.get_image_acquisition_id(image_path=image_path)
|
|
358
370
|
|
|
371
|
+
def _get_well(self, well_path: str) -> OmeZarrWell:
|
|
372
|
+
"""Get a well from the plate by its path.
|
|
373
|
+
|
|
374
|
+
Args:
|
|
375
|
+
well_path (str): The path of the well.
|
|
376
|
+
|
|
377
|
+
Returns:
|
|
378
|
+
OmeZarrWell: The well.
|
|
379
|
+
|
|
380
|
+
"""
|
|
381
|
+
cached_well = self._wells_cache.get(well_path)
|
|
382
|
+
if cached_well is not None:
|
|
383
|
+
return cached_well
|
|
384
|
+
|
|
385
|
+
group_handler = self._group_handler.get_handler(well_path)
|
|
386
|
+
self._wells_cache.set(well_path, OmeZarrWell(group_handler))
|
|
387
|
+
return OmeZarrWell(group_handler)
|
|
388
|
+
|
|
359
389
|
def get_well(self, row: str, column: int | str) -> OmeZarrWell:
|
|
360
390
|
"""Get a well from the plate.
|
|
361
391
|
|
|
@@ -367,8 +397,7 @@ class OmeZarrPlate:
|
|
|
367
397
|
OmeZarrWell: The well.
|
|
368
398
|
"""
|
|
369
399
|
well_path = self._well_path(row=row, column=column)
|
|
370
|
-
|
|
371
|
-
return OmeZarrWell(group_handler)
|
|
400
|
+
return self._get_well(well_path=well_path)
|
|
372
401
|
|
|
373
402
|
async def get_wells_async(self) -> dict[str, OmeZarrWell]:
|
|
374
403
|
"""Get all wells in the plate asynchronously.
|
|
@@ -380,26 +409,17 @@ class OmeZarrPlate:
|
|
|
380
409
|
dict[str, OmeZarrWell]: A dictionary of wells, where the key is the well
|
|
381
410
|
path and the value is the well object.
|
|
382
411
|
"""
|
|
383
|
-
wells = self._group_handler.get_from_cache("wells")
|
|
384
|
-
if wells is not None:
|
|
385
|
-
assert isinstance(wells, dict)
|
|
386
|
-
return wells
|
|
387
|
-
|
|
388
|
-
def process_well(well_path):
|
|
389
|
-
group_handler = self._group_handler.derive_handler(well_path)
|
|
390
|
-
well = OmeZarrWell(group_handler)
|
|
391
|
-
return well_path, well
|
|
392
|
-
|
|
393
412
|
wells, tasks = {}, []
|
|
394
413
|
for well_path in self.wells_paths():
|
|
395
|
-
task = asyncio.to_thread(
|
|
414
|
+
task = asyncio.to_thread(
|
|
415
|
+
lambda well_path: (well_path, self._get_well(well_path)), well_path
|
|
416
|
+
)
|
|
396
417
|
tasks.append(task)
|
|
397
418
|
|
|
398
419
|
results = await asyncio.gather(*tasks)
|
|
399
420
|
for well_path, well in results:
|
|
400
421
|
wells[well_path] = well
|
|
401
422
|
|
|
402
|
-
self._group_handler.add_to_cache("wells", wells)
|
|
403
423
|
return wells
|
|
404
424
|
|
|
405
425
|
def get_wells(self) -> dict[str, OmeZarrWell]:
|
|
@@ -409,24 +429,25 @@ class OmeZarrPlate:
|
|
|
409
429
|
dict[str, OmeZarrWell]: A dictionary of wells, where the key is the well
|
|
410
430
|
path and the value is the well object.
|
|
411
431
|
"""
|
|
412
|
-
wells = self._group_handler.get_from_cache("wells")
|
|
413
|
-
if wells is not None:
|
|
414
|
-
assert isinstance(wells, dict)
|
|
415
|
-
return wells
|
|
416
|
-
|
|
417
|
-
def process_well(well_path):
|
|
418
|
-
group_handler = self._group_handler.derive_handler(well_path)
|
|
419
|
-
well = OmeZarrWell(group_handler)
|
|
420
|
-
return well_path, well
|
|
421
|
-
|
|
422
432
|
wells = {}
|
|
423
433
|
for well_path in self.wells_paths():
|
|
424
|
-
|
|
425
|
-
wells[well_path] = well
|
|
426
|
-
|
|
427
|
-
self._group_handler.add_to_cache("wells", wells)
|
|
434
|
+
wells[well_path] = self._get_well(well_path)
|
|
428
435
|
return wells
|
|
429
436
|
|
|
437
|
+
def _get_image(self, image_path: str) -> OmeZarrContainer:
|
|
438
|
+
"""Get an image from the plate by its path.
|
|
439
|
+
|
|
440
|
+
Args:
|
|
441
|
+
image_path (str): The path of the image.
|
|
442
|
+
"""
|
|
443
|
+
cached_image = self._images_cache.get(image_path)
|
|
444
|
+
if cached_image is not None:
|
|
445
|
+
return cached_image
|
|
446
|
+
img_group_handler = self._group_handler.get_handler(image_path)
|
|
447
|
+
image = OmeZarrContainer(img_group_handler)
|
|
448
|
+
self._images_cache.set(image_path, image)
|
|
449
|
+
return image
|
|
450
|
+
|
|
430
451
|
async def get_images_async(
|
|
431
452
|
self, acquisition: int | None = None
|
|
432
453
|
) -> dict[str, OmeZarrContainer]:
|
|
@@ -442,30 +463,19 @@ class OmeZarrPlate:
|
|
|
442
463
|
dict[str, OmeZarrContainer]: A dictionary of images, where the key is the
|
|
443
464
|
image path and the value is the image object.
|
|
444
465
|
"""
|
|
445
|
-
images = self._group_handler.get_from_cache("images")
|
|
446
|
-
if images is not None:
|
|
447
|
-
assert isinstance(images, dict)
|
|
448
|
-
return images
|
|
449
|
-
|
|
450
466
|
paths = await self.images_paths_async(acquisition=acquisition)
|
|
451
467
|
|
|
452
|
-
def process_image(image_path):
|
|
453
|
-
"""Process a single image and return the image path and image object."""
|
|
454
|
-
img_group_handler = self._group_handler.derive_handler(image_path)
|
|
455
|
-
image = OmeZarrContainer(img_group_handler)
|
|
456
|
-
return image_path, image
|
|
457
|
-
|
|
458
468
|
images, tasks = {}, []
|
|
459
469
|
for image_path in paths:
|
|
460
|
-
task = asyncio.to_thread(
|
|
470
|
+
task = asyncio.to_thread(
|
|
471
|
+
lambda image_path: (image_path, self._get_image(image_path)), image_path
|
|
472
|
+
)
|
|
461
473
|
tasks.append(task)
|
|
462
474
|
|
|
463
475
|
results = await asyncio.gather(*tasks)
|
|
464
476
|
|
|
465
477
|
for image_path, image in results:
|
|
466
478
|
images[image_path] = image
|
|
467
|
-
|
|
468
|
-
self._group_handler.add_to_cache("images", images)
|
|
469
479
|
return images
|
|
470
480
|
|
|
471
481
|
def get_images(self, acquisition: int | None = None) -> dict[str, OmeZarrContainer]:
|
|
@@ -474,24 +484,11 @@ class OmeZarrPlate:
|
|
|
474
484
|
Args:
|
|
475
485
|
acquisition: The acquisition id to filter the images.
|
|
476
486
|
"""
|
|
477
|
-
images = self._group_handler.get_from_cache("images")
|
|
478
|
-
if images is not None:
|
|
479
|
-
assert isinstance(images, dict)
|
|
480
|
-
return images
|
|
481
487
|
paths = self.images_paths(acquisition=acquisition)
|
|
482
|
-
|
|
483
|
-
def process_image(image_path):
|
|
484
|
-
"""Process a single image and return the image path and image object."""
|
|
485
|
-
img_group_handler = self._group_handler.derive_handler(image_path)
|
|
486
|
-
image = OmeZarrContainer(img_group_handler)
|
|
487
|
-
return image_path, image
|
|
488
|
-
|
|
489
488
|
images = {}
|
|
490
489
|
for image_path in paths:
|
|
491
|
-
|
|
492
|
-
images[image_path] = image
|
|
490
|
+
images[image_path] = self._get_image(image_path)
|
|
493
491
|
|
|
494
|
-
self._group_handler.add_to_cache("images", images)
|
|
495
492
|
return images
|
|
496
493
|
|
|
497
494
|
def get_image(
|
|
@@ -508,8 +505,7 @@ class OmeZarrPlate:
|
|
|
508
505
|
OmeZarrContainer: The image.
|
|
509
506
|
"""
|
|
510
507
|
image_path = self._image_path(row=row, column=column, path=image_path)
|
|
511
|
-
|
|
512
|
-
return OmeZarrContainer(group_handler)
|
|
508
|
+
return self._get_image(image_path)
|
|
513
509
|
|
|
514
510
|
def get_image_store(
|
|
515
511
|
self, row: str, column: int | str, image_path: str
|
|
@@ -538,7 +534,7 @@ class OmeZarrPlate:
|
|
|
538
534
|
for image_paths in self.well_images_paths(
|
|
539
535
|
row=row, column=column, acquisition=acquisition
|
|
540
536
|
):
|
|
541
|
-
group_handler = self._group_handler.
|
|
537
|
+
group_handler = self._group_handler.get_handler(image_paths)
|
|
542
538
|
images[image_paths] = OmeZarrContainer(group_handler)
|
|
543
539
|
return images
|
|
544
540
|
|
|
@@ -567,11 +563,11 @@ class OmeZarrPlate:
|
|
|
567
563
|
meta = meta.add_acquisition(
|
|
568
564
|
acquisition_id=acquisition_id, acquisition_name=acquisition_name
|
|
569
565
|
)
|
|
570
|
-
self.meta_handler.
|
|
566
|
+
self.meta_handler.update_meta(meta)
|
|
571
567
|
self.meta_handler._group_handler.clean_cache()
|
|
572
568
|
|
|
573
569
|
well_path = self.meta.get_well_path(row=row, column=column)
|
|
574
|
-
group_handler = self._group_handler.
|
|
570
|
+
group_handler = self._group_handler.get_handler(well_path)
|
|
575
571
|
|
|
576
572
|
if atomic:
|
|
577
573
|
well_lock = group_handler.lock
|
|
@@ -586,18 +582,19 @@ class OmeZarrPlate:
|
|
|
586
582
|
well_meta = NgioWellMeta.default_init()
|
|
587
583
|
version = self.meta.plate.version
|
|
588
584
|
version = version if version is not None else "0.4"
|
|
589
|
-
|
|
585
|
+
update_ngio_well_meta(group_handler, well_meta)
|
|
586
|
+
meta_handler = WellMetaHandler(group_handler=group_handler)
|
|
590
587
|
else:
|
|
591
|
-
meta_handler =
|
|
592
|
-
well_meta = meta_handler.
|
|
588
|
+
meta_handler = WellMetaHandler(group_handler=group_handler)
|
|
589
|
+
well_meta = meta_handler.get_meta()
|
|
593
590
|
|
|
594
|
-
group_handler = self._group_handler.
|
|
591
|
+
group_handler = self._group_handler.get_handler(well_path)
|
|
595
592
|
|
|
596
593
|
if image_path is not None:
|
|
597
594
|
well_meta = well_meta.add_image(
|
|
598
595
|
path=image_path, acquisition=acquisition_id, strict=False
|
|
599
596
|
)
|
|
600
|
-
meta_handler.
|
|
597
|
+
meta_handler.update_meta(well_meta)
|
|
601
598
|
meta_handler._group_handler.clean_cache()
|
|
602
599
|
|
|
603
600
|
if image_path is not None:
|
|
@@ -674,7 +671,7 @@ class OmeZarrPlate:
|
|
|
674
671
|
) -> "OmeZarrPlate":
|
|
675
672
|
"""Add a column to an ome-zarr plate."""
|
|
676
673
|
meta, _ = self.meta.add_column(column)
|
|
677
|
-
self.meta_handler.
|
|
674
|
+
self.meta_handler.update_meta(meta)
|
|
678
675
|
self.meta_handler._group_handler.clean_cache()
|
|
679
676
|
return self
|
|
680
677
|
|
|
@@ -684,7 +681,7 @@ class OmeZarrPlate:
|
|
|
684
681
|
) -> "OmeZarrPlate":
|
|
685
682
|
"""Add a row to an ome-zarr plate."""
|
|
686
683
|
meta, _ = self.meta.add_row(row)
|
|
687
|
-
self.meta_handler.
|
|
684
|
+
self.meta_handler.update_meta(meta)
|
|
688
685
|
self.meta_handler._group_handler.clean_cache()
|
|
689
686
|
return self
|
|
690
687
|
|
|
@@ -704,7 +701,7 @@ class OmeZarrPlate:
|
|
|
704
701
|
meta = self.meta.add_acquisition(
|
|
705
702
|
acquisition_id=acquisition_id, acquisition_name=acquisition_name
|
|
706
703
|
)
|
|
707
|
-
self.meta_handler.
|
|
704
|
+
self.meta_handler.update_meta(meta)
|
|
708
705
|
self.meta_handler._group_handler.clean_cache()
|
|
709
706
|
return self
|
|
710
707
|
|
|
@@ -723,7 +720,7 @@ class OmeZarrPlate:
|
|
|
723
720
|
with plate_lock:
|
|
724
721
|
meta = self.meta
|
|
725
722
|
meta = meta.remove_well(row, column)
|
|
726
|
-
self.meta_handler.
|
|
723
|
+
self.meta_handler.update_meta(meta)
|
|
727
724
|
self.meta_handler._group_handler.clean_cache()
|
|
728
725
|
|
|
729
726
|
def _remove_image(
|
|
@@ -744,7 +741,7 @@ class OmeZarrPlate:
|
|
|
744
741
|
with well_lock:
|
|
745
742
|
well_meta = well.meta
|
|
746
743
|
well_meta = well_meta.remove_image(path=image_path)
|
|
747
|
-
well.meta_handler.
|
|
744
|
+
well.meta_handler.update_meta(well_meta)
|
|
748
745
|
well.meta_handler._group_handler.clean_cache()
|
|
749
746
|
if len(well_meta.paths()) == 0:
|
|
750
747
|
self._remove_well(row, column, atomic=atomic)
|
|
@@ -785,7 +782,6 @@ class OmeZarrPlate:
|
|
|
785
782
|
keep_acquisitions: bool = False,
|
|
786
783
|
cache: bool = False,
|
|
787
784
|
overwrite: bool = False,
|
|
788
|
-
parallel_safe: bool = True,
|
|
789
785
|
) -> "OmeZarrPlate":
|
|
790
786
|
"""Derive a new OME-Zarr plate from an existing one.
|
|
791
787
|
|
|
@@ -796,7 +792,6 @@ class OmeZarrPlate:
|
|
|
796
792
|
keep_acquisitions (bool): Whether to keep the acquisitions in the new plate.
|
|
797
793
|
cache (bool): Whether to use a cache for the zarr group metadata.
|
|
798
794
|
overwrite (bool): Whether to overwrite the existing plate.
|
|
799
|
-
parallel_safe (bool): Whether the group handler is parallel safe.
|
|
800
795
|
"""
|
|
801
796
|
return derive_ome_zarr_plate(
|
|
802
797
|
ome_zarr_plate=self,
|
|
@@ -806,16 +801,16 @@ class OmeZarrPlate:
|
|
|
806
801
|
keep_acquisitions=keep_acquisitions,
|
|
807
802
|
cache=cache,
|
|
808
803
|
overwrite=overwrite,
|
|
809
|
-
parallel_safe=parallel_safe,
|
|
810
804
|
)
|
|
811
805
|
|
|
812
|
-
def _get_tables_container(self) -> TablesContainer | None:
|
|
806
|
+
def _get_tables_container(self, create_mode: bool = True) -> TablesContainer | None:
|
|
813
807
|
"""Return the tables container."""
|
|
814
|
-
if self._tables_container is None:
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
808
|
+
if self._tables_container is not None:
|
|
809
|
+
return self._tables_container
|
|
810
|
+
_tables_container = _try_get_table_container(
|
|
811
|
+
self._group_handler, create_mode=create_mode
|
|
812
|
+
)
|
|
813
|
+
self._tables_container = _tables_container
|
|
819
814
|
return self._tables_container
|
|
820
815
|
|
|
821
816
|
@property
|
|
@@ -830,17 +825,20 @@ class OmeZarrPlate:
|
|
|
830
825
|
|
|
831
826
|
def list_tables(self, filter_types: TypedTable | str | None = None) -> list[str]:
|
|
832
827
|
"""List all tables in the image."""
|
|
828
|
+
_tables_container = self._get_tables_container(create_mode=False)
|
|
829
|
+
if _tables_container is None:
|
|
830
|
+
return []
|
|
833
831
|
return self.tables_container.list(filter_types=filter_types)
|
|
834
832
|
|
|
835
833
|
def list_roi_tables(self) -> list[str]:
|
|
836
834
|
"""List all ROI tables in the image."""
|
|
837
|
-
masking_roi = self.tables_container.list(
|
|
838
|
-
filter_types="masking_roi_table",
|
|
839
|
-
)
|
|
840
835
|
roi = self.tables_container.list(
|
|
841
836
|
filter_types="roi_table",
|
|
842
837
|
)
|
|
843
|
-
|
|
838
|
+
masking_roi = self.tables_container.list(
|
|
839
|
+
filter_types="masking_roi_table",
|
|
840
|
+
)
|
|
841
|
+
return roi + masking_roi
|
|
844
842
|
|
|
845
843
|
def get_roi_table(self, name: str) -> RoiTable:
|
|
846
844
|
"""Get a ROI table from the image.
|
|
@@ -1143,7 +1141,6 @@ def open_ome_zarr_plate(
|
|
|
1143
1141
|
store: StoreOrGroup,
|
|
1144
1142
|
cache: bool = False,
|
|
1145
1143
|
mode: AccessModeLiteral = "r+",
|
|
1146
|
-
parallel_safe: bool = True,
|
|
1147
1144
|
) -> OmeZarrPlate:
|
|
1148
1145
|
"""Open an OME-Zarr plate.
|
|
1149
1146
|
|
|
@@ -1152,11 +1149,8 @@ def open_ome_zarr_plate(
|
|
|
1152
1149
|
cache (bool): Whether to use a cache for the zarr group metadata.
|
|
1153
1150
|
mode (AccessModeLiteral): The
|
|
1154
1151
|
access mode for the image. Defaults to "r+".
|
|
1155
|
-
parallel_safe (bool): Whether the group handler is parallel safe.
|
|
1156
1152
|
"""
|
|
1157
|
-
group_handler = ZarrGroupHandler(
|
|
1158
|
-
store=store, cache=cache, mode=mode, parallel_safe=parallel_safe
|
|
1159
|
-
)
|
|
1153
|
+
group_handler = ZarrGroupHandler(store=store, cache=cache, mode=mode)
|
|
1160
1154
|
return OmeZarrPlate(group_handler)
|
|
1161
1155
|
|
|
1162
1156
|
|
|
@@ -1168,11 +1162,8 @@ def _create_empty_plate_from_meta(
|
|
|
1168
1162
|
) -> ZarrGroupHandler:
|
|
1169
1163
|
"""Create an empty OME-Zarr plate from metadata."""
|
|
1170
1164
|
mode = "w" if overwrite else "w-"
|
|
1171
|
-
group_handler = ZarrGroupHandler(
|
|
1172
|
-
|
|
1173
|
-
)
|
|
1174
|
-
meta_handler = get_plate_meta_handler(group_handler, version=version)
|
|
1175
|
-
meta_handler.write_meta(meta)
|
|
1165
|
+
group_handler = ZarrGroupHandler(store=store, cache=True, mode=mode)
|
|
1166
|
+
update_ngio_plate_meta(group_handler, meta)
|
|
1176
1167
|
return group_handler
|
|
1177
1168
|
|
|
1178
1169
|
|
|
@@ -1183,9 +1174,18 @@ def create_empty_plate(
|
|
|
1183
1174
|
version: NgffVersions = "0.4",
|
|
1184
1175
|
cache: bool = False,
|
|
1185
1176
|
overwrite: bool = False,
|
|
1186
|
-
parallel_safe: bool = True,
|
|
1187
1177
|
) -> OmeZarrPlate:
|
|
1188
|
-
"""Initialize and create an empty OME-Zarr plate.
|
|
1178
|
+
"""Initialize and create an empty OME-Zarr plate.
|
|
1179
|
+
|
|
1180
|
+
Args:
|
|
1181
|
+
store (StoreOrGroup): The Zarr store or group that stores the plate.
|
|
1182
|
+
name (str): The name of the plate.
|
|
1183
|
+
images (list[ImageInWellPath] | None): A list of images to add to the plate.
|
|
1184
|
+
If None, no images are added. Defaults to None.
|
|
1185
|
+
version (NgffVersion): The version of the new plate.
|
|
1186
|
+
cache (bool): Whether to use a cache for the zarr group metadata.
|
|
1187
|
+
overwrite (bool): Whether to overwrite the existing plate.
|
|
1188
|
+
"""
|
|
1189
1189
|
plate_meta = NgioPlateMeta.default_init(
|
|
1190
1190
|
name=name,
|
|
1191
1191
|
version=version,
|
|
@@ -1211,7 +1211,6 @@ def create_empty_plate(
|
|
|
1211
1211
|
store=store,
|
|
1212
1212
|
cache=cache,
|
|
1213
1213
|
mode="r+",
|
|
1214
|
-
parallel_safe=parallel_safe,
|
|
1215
1214
|
)
|
|
1216
1215
|
|
|
1217
1216
|
|
|
@@ -1223,7 +1222,6 @@ def derive_ome_zarr_plate(
|
|
|
1223
1222
|
keep_acquisitions: bool = False,
|
|
1224
1223
|
cache: bool = False,
|
|
1225
1224
|
overwrite: bool = False,
|
|
1226
|
-
parallel_safe: bool = True,
|
|
1227
1225
|
) -> OmeZarrPlate:
|
|
1228
1226
|
"""Derive a new OME-Zarr plate from an existing one.
|
|
1229
1227
|
|
|
@@ -1235,7 +1233,6 @@ def derive_ome_zarr_plate(
|
|
|
1235
1233
|
keep_acquisitions (bool): Whether to keep the acquisitions in the new plate.
|
|
1236
1234
|
cache (bool): Whether to use a cache for the zarr group metadata.
|
|
1237
1235
|
overwrite (bool): Whether to overwrite the existing plate.
|
|
1238
|
-
parallel_safe (bool): Whether the group handler is parallel safe.
|
|
1239
1236
|
"""
|
|
1240
1237
|
if plate_name is None:
|
|
1241
1238
|
plate_name = ome_zarr_plate.meta.plate.name
|
|
@@ -1255,7 +1252,6 @@ def derive_ome_zarr_plate(
|
|
|
1255
1252
|
store=store,
|
|
1256
1253
|
cache=cache,
|
|
1257
1254
|
mode="r+",
|
|
1258
|
-
parallel_safe=parallel_safe,
|
|
1259
1255
|
)
|
|
1260
1256
|
|
|
1261
1257
|
|
|
@@ -1263,7 +1259,6 @@ def open_ome_zarr_well(
|
|
|
1263
1259
|
store: StoreOrGroup,
|
|
1264
1260
|
cache: bool = False,
|
|
1265
1261
|
mode: AccessModeLiteral = "r+",
|
|
1266
|
-
parallel_safe: bool = True,
|
|
1267
1262
|
) -> OmeZarrWell:
|
|
1268
1263
|
"""Open an OME-Zarr well.
|
|
1269
1264
|
|
|
@@ -1271,10 +1266,11 @@ def open_ome_zarr_well(
|
|
|
1271
1266
|
store (StoreOrGroup): The Zarr store or group that stores the plate.
|
|
1272
1267
|
cache (bool): Whether to use a cache for the zarr group metadata.
|
|
1273
1268
|
mode (AccessModeLiteral): The access mode for the image. Defaults to "r+".
|
|
1274
|
-
parallel_safe (bool): Whether the group handler is parallel safe.
|
|
1275
1269
|
"""
|
|
1276
1270
|
group_handler = ZarrGroupHandler(
|
|
1277
|
-
store=store,
|
|
1271
|
+
store=store,
|
|
1272
|
+
cache=cache,
|
|
1273
|
+
mode=mode,
|
|
1278
1274
|
)
|
|
1279
1275
|
return OmeZarrWell(group_handler)
|
|
1280
1276
|
|
|
@@ -1284,7 +1280,6 @@ def create_empty_well(
|
|
|
1284
1280
|
version: NgffVersions = "0.4",
|
|
1285
1281
|
cache: bool = False,
|
|
1286
1282
|
overwrite: bool = False,
|
|
1287
|
-
parallel_safe: bool = True,
|
|
1288
1283
|
) -> OmeZarrWell:
|
|
1289
1284
|
"""Create an empty OME-Zarr well.
|
|
1290
1285
|
|
|
@@ -1293,18 +1288,14 @@ def create_empty_well(
|
|
|
1293
1288
|
version (NgffVersion): The version of the new well.
|
|
1294
1289
|
cache (bool): Whether to use a cache for the zarr group metadata.
|
|
1295
1290
|
overwrite (bool): Whether to overwrite the existing well.
|
|
1296
|
-
parallel_safe (bool): Whether the group handler is parallel safe.
|
|
1297
1291
|
"""
|
|
1298
1292
|
group_handler = ZarrGroupHandler(
|
|
1299
|
-
store=store, cache=True, mode="w" if overwrite else "w-"
|
|
1293
|
+
store=store, cache=True, mode="w" if overwrite else "w-"
|
|
1300
1294
|
)
|
|
1301
|
-
|
|
1302
|
-
meta = NgioWellMeta.default_init()
|
|
1303
|
-
meta_handler.write_meta(meta)
|
|
1295
|
+
update_ngio_well_meta(group_handler, NgioWellMeta.default_init())
|
|
1304
1296
|
|
|
1305
1297
|
return open_ome_zarr_well(
|
|
1306
1298
|
store=store,
|
|
1307
1299
|
cache=cache,
|
|
1308
1300
|
mode="r+",
|
|
1309
|
-
parallel_safe=parallel_safe,
|
|
1310
1301
|
)
|