ngio 0.2.3__py3-none-any.whl → 0.2.5__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/hcs/plate.py CHANGED
@@ -686,6 +686,9 @@ class OmeZarrPlate:
686
686
  """List all ROI tables in the image."""
687
687
  return self.tables_container.list_roi_tables()
688
688
 
689
+ @overload
690
+ def get_table(self, name: str) -> Table: ...
691
+
689
692
  @overload
690
693
  def get_table(self, name: str, check_type: None) -> Table: ...
691
694
 
@@ -708,8 +711,19 @@ class OmeZarrPlate:
708
711
  ) -> GenericRoiTable: ...
709
712
 
710
713
  def get_table(self, name: str, check_type: TypedTable | None = None) -> Table:
711
- """Get a table from the image."""
712
- table = self.tables_container.get(name)
714
+ """Get a table from the image.
715
+
716
+ Args:
717
+ name (str): The name of the table.
718
+ check_type (TypedTable | None): The type of the table. If None, the
719
+ type is not checked. If a type is provided, the table must be of that
720
+ type.
721
+ """
722
+ if check_type is None:
723
+ table = self.tables_container.get(name, strict=False)
724
+ return table
725
+
726
+ table = self.tables_container.get(name, strict=True)
713
727
  match check_type:
714
728
  case "roi_table":
715
729
  if not isinstance(table, RoiTable):
@@ -740,8 +754,6 @@ class OmeZarrPlate:
740
754
  f"Found type: {table.type()}"
741
755
  )
742
756
  return table
743
- case None:
744
- return table
745
757
  case _:
746
758
  raise NgioValueError(f"Unknown check_type: {check_type}")
747
759
 
@@ -353,6 +353,9 @@ class OmeZarrContainer:
353
353
  """List all ROI tables in the image."""
354
354
  return self.tables_container.list_roi_tables()
355
355
 
356
+ @overload
357
+ def get_table(self, name: str) -> Table: ...
358
+
356
359
  @overload
357
360
  def get_table(self, name: str, check_type: None) -> Table: ...
358
361
 
@@ -375,8 +378,19 @@ class OmeZarrContainer:
375
378
  ) -> GenericRoiTable: ...
376
379
 
377
380
  def get_table(self, name: str, check_type: TypedTable | None = None) -> Table:
378
- """Get a table from the image."""
379
- table = self.tables_container.get(name)
381
+ """Get a table from the image.
382
+
383
+ Args:
384
+ name (str): The name of the table.
385
+ check_type (TypedTable | None): The type of the table. If None, the
386
+ type is not checked. If a type is provided, the table must be of that
387
+ type.
388
+ """
389
+ if check_type is None:
390
+ table = self.tables_container.get(name, strict=False)
391
+ return table
392
+
393
+ table = self.tables_container.get(name, strict=True)
380
394
  match check_type:
381
395
  case "roi_table":
382
396
  if not isinstance(table, RoiTable):
@@ -407,8 +421,6 @@ class OmeZarrContainer:
407
421
  f"Found type: {table.type()}"
408
422
  )
409
423
  return table
410
- case None:
411
- return table
412
424
  case _:
413
425
  raise NgioValueError(f"Unknown check_type: {check_type}")
414
426
 
@@ -361,6 +361,7 @@ class NgioPlateMeta(HCSAttrs):
361
361
  acquisitions=self.plate.acquisitions,
362
362
  wells=wells,
363
363
  field_count=self.plate.field_count,
364
+ name=self.plate.name,
364
365
  version=self.plate.version,
365
366
  )
366
367
  return NgioPlateMeta(plate=new_plate), row_idx
@@ -398,6 +399,7 @@ class NgioPlateMeta(HCSAttrs):
398
399
  acquisitions=self.plate.acquisitions,
399
400
  wells=wells,
400
401
  field_count=self.plate.field_count,
402
+ name=self.plate.name,
401
403
  version=self.plate.version,
402
404
  )
403
405
  return NgioPlateMeta(plate=new_plate), column_idx
@@ -435,6 +437,7 @@ class NgioPlateMeta(HCSAttrs):
435
437
  acquisitions=plate.plate.acquisitions,
436
438
  wells=wells,
437
439
  field_count=plate.plate.field_count,
440
+ name=plate.plate.name,
438
441
  version=plate.plate.version,
439
442
  )
440
443
  return NgioPlateMeta(plate=new_plate)
@@ -473,6 +476,7 @@ class NgioPlateMeta(HCSAttrs):
473
476
  acquisitions=acquisitions,
474
477
  wells=self.plate.wells,
475
478
  field_count=self.plate.field_count,
479
+ name=self.plate.name,
476
480
  version=self.plate.version,
477
481
  )
478
482
  return NgioPlateMeta(plate=new_plate)
@@ -508,6 +512,7 @@ class NgioPlateMeta(HCSAttrs):
508
512
  acquisitions=self.plate.acquisitions,
509
513
  wells=wells,
510
514
  field_count=self.plate.field_count,
515
+ name=self.plate.name,
511
516
  version=self.plate.version,
512
517
  )
513
518
  return NgioPlateMeta(plate=new_plate)
@@ -53,6 +53,10 @@ def _validate_index_key_df(pandas_df: DataFrame, index_key: str | None) -> DataF
53
53
  pandas_df.index.name = index_key
54
54
  return pandas_df
55
55
 
56
+ if pandas_df.index.name is None:
57
+ pandas_df.index.name = index_key
58
+ return pandas_df
59
+
56
60
  raise NgioTableValidationError(f"Index key '{index_key}' is not found in DataFrame")
57
61
 
58
62
 
@@ -90,6 +90,7 @@ class ImplementedTables:
90
90
  version: str,
91
91
  handler: ZarrGroupHandler,
92
92
  backend_name: str | None = None,
93
+ strict: bool = True,
93
94
  ) -> Table:
94
95
  """Try to get a handler for the given store based on the metadata version."""
95
96
  _errors = {}
@@ -102,7 +103,12 @@ class ImplementedTables:
102
103
  )
103
104
  return table
104
105
  except Exception as e:
105
- _errors[name] = e
106
+ if strict:
107
+ raise NgioValidationError(
108
+ f"Could not load table {name} from handler. Error: {e}"
109
+ ) from e
110
+ else:
111
+ _errors[name] = e
106
112
  # If no table was found, we can try to load the table from a generic table
107
113
  try:
108
114
  table = GenericTable._from_handler(
@@ -207,7 +213,9 @@ class TablesContainer:
207
213
  filtered_tables.append(table_name)
208
214
  return filtered_tables
209
215
 
210
- def get(self, name: str, backend_name: str | None = None) -> Table:
216
+ def get(
217
+ self, name: str, backend_name: str | None = None, strict: bool = True
218
+ ) -> Table:
211
219
  """Get a label from the group."""
212
220
  if name not in self.list():
213
221
  raise KeyError(f"Table '{name}' not found in the group.")
@@ -220,6 +228,7 @@ class TablesContainer:
220
228
  version=table_version,
221
229
  handler=table_handler,
222
230
  backend_name=backend_name,
231
+ strict=strict,
223
232
  )
224
233
 
225
234
  def add(
@@ -227,13 +227,18 @@ class _GenericRoiTableV1(Generic[_roi_meta]):
227
227
  """List all ROIs in the table."""
228
228
  return list(self._rois.values())
229
229
 
230
- def add(self, roi: Roi | Iterable[Roi]) -> None:
231
- """Append ROIs to the current table."""
230
+ def add(self, roi: Roi | Iterable[Roi], overwrite: bool = False) -> None:
231
+ """Append ROIs to the current table.
232
+
233
+ Args:
234
+ roi: A single ROI or a list of ROIs to add to the table.
235
+ overwrite: If True, overwrite existing ROIs with the same name.
236
+ """
232
237
  if isinstance(roi, Roi):
233
238
  roi = [roi]
234
239
 
235
240
  for _roi in roi:
236
- if _roi.name in self._rois:
241
+ if not overwrite and _roi.name in self._rois:
237
242
  raise NgioValueError(f"ROI {_roi.name} already exists in the table.")
238
243
  self._rois[_roi.name] = _roi
239
244
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ngio
3
- Version: 0.2.3
3
+ Version: 0.2.5
4
4
  Summary: Next Generation file format IO
5
5
  Project-URL: homepage, https://github.com/lorenzocerrone/ngio
6
6
  Project-URL: repository, https://github.com/lorenzocerrone/ngio
@@ -10,21 +10,21 @@ ngio/common/_roi.py,sha256=dq1iVT8-G_zWuxcYWJeHfviBSbPgsyKUcDL3Vg6jx6I,5122
10
10
  ngio/common/_slicer.py,sha256=AKpwXRncOmF9nhjKYma0C_41WqAgSv860beKGx-aw-0,3075
11
11
  ngio/common/_zoom.py,sha256=KsURa5VuixmpbAAY5-6obmuQV8vfiHKZqBxZDXvchpM,5473
12
12
  ngio/hcs/__init__.py,sha256=5oAYT_454WGhms97kxo8gS4_rKHtFf_x-9uu8M_VeVM,356
13
- ngio/hcs/plate.py,sha256=MK-HTuSyxt2dp1CuA9tvSwRc9VWEjDz4Pju-2dxXQf4,30102
13
+ ngio/hcs/plate.py,sha256=zmhHXRsoc4s_-bPccYCH9rqoYg419j-T-NF-OojXRZM,30509
14
14
  ngio/images/__init__.py,sha256=DYbXAdBgPxyjBRdJrWvU0UnBRI0gUMmx9KaJ-Bucvz4,533
15
15
  ngio/images/abstract_image.py,sha256=8PNQPZjiDz-pcTFXSJAVw7nUr4yL_iRwqDEUTKkAnp0,10266
16
16
  ngio/images/create.py,sha256=XYn30m_2OSZeHHASYHc3eK9u_gZIYy9wo6mGdRGaq5c,9473
17
17
  ngio/images/image.py,sha256=mKLIR2DGQUWtQbf3my2fh0bEPkbbsabUoge_XJPhfWE,17824
18
18
  ngio/images/label.py,sha256=qgbBHFPGYpUR2fHf1OiXZh4sn0FgCeeWwH1F4SrOM1c,10460
19
19
  ngio/images/masked_image.py,sha256=IBo8x2jHyXBXn7ORo8fSiwBPjV_1JOTb_vatjKNxbJ0,8531
20
- ngio/images/ome_zarr_container.py,sha256=5tgUd1iq2nQOmWsIZY-kwVR1d5UV4rKlVEXTslDBCno,28520
20
+ ngio/images/ome_zarr_container.py,sha256=-9bbzNtsVAjU1X_h78Lr5LOV0JXtOiWVWqmt3DFpXus,28927
21
21
  ngio/ome_zarr_meta/__init__.py,sha256=oZ8PEsWM7U0KwzpsnvVfX9k4UfuTz5sZ8B6B9eY5hyY,1193
22
22
  ngio/ome_zarr_meta/_meta_handlers.py,sha256=BLvYt5PONYrWkEb2XgEiAXR_OX9rfeX_C0eEqen0jQA,25549
23
23
  ngio/ome_zarr_meta/ngio_specs/__init__.py,sha256=05NQukZG0nNvjzf8AKWGu7PhjhQcImGSAOK3D3Bg-Js,1786
24
24
  ngio/ome_zarr_meta/ngio_specs/_axes.py,sha256=Kqe9T7LWa_9o3UWS5uzALyyNluIhXxWhDGxWY4-GIo8,16707
25
25
  ngio/ome_zarr_meta/ngio_specs/_channels.py,sha256=ufZuYuTO5PJA1vcBrNAcuZCMgIEwF57buPloTHIzB1Q,14082
26
26
  ngio/ome_zarr_meta/ngio_specs/_dataset.py,sha256=hY8ogPPxvCgVg6k02t3zUr24lasYrvnxBd1iPEigdG4,5892
27
- ngio/ome_zarr_meta/ngio_specs/_ngio_hcs.py,sha256=VhXfgy87z3xpzIqC4Pz5iwcoh0C47mvRiAhN0vLVSJA,17294
27
+ ngio/ome_zarr_meta/ngio_specs/_ngio_hcs.py,sha256=uh345KQmEQtslIyMmLK9sB-NbjPYxi0Y9FuYIFhd3Rc,17465
28
28
  ngio/ome_zarr_meta/ngio_specs/_ngio_image.py,sha256=8E38Mgw-l0Ff1nkmCJIzo64G_paAVhM8xktUS_V5egY,17960
29
29
  ngio/ome_zarr_meta/ngio_specs/_pixel_size.py,sha256=5TT8250XdCKUnk3OwZeyXIMNFKOg_jx4NnoCo9RLsXI,4079
30
30
  ngio/ome_zarr_meta/v04/__init__.py,sha256=dJRzzxyYc81kf-0Hip_bqvbdManaM8XTdQX2meWyCSs,583
@@ -32,7 +32,7 @@ ngio/ome_zarr_meta/v04/_custom_models.py,sha256=5GxiDERvLuvq4QvApcA6EiKLS6hLFX1R
32
32
  ngio/ome_zarr_meta/v04/_v04_spec_utils.py,sha256=05tEr2eEP_XVIfBMOAWLT7lzJV4KS5eYrpK8l94tn3w,15876
33
33
  ngio/tables/__init__.py,sha256=gxvNvAgLePgrngOm06H5qU50Axc6boeIs5iCfrmqTi0,609
34
34
  ngio/tables/_validators.py,sha256=7Eqln9j1tWmNakSCnryy2q39SbTuk6V31O2iMByTWWw,3363
35
- ngio/tables/tables_container.py,sha256=Jt9FNjWU9EPbb4L9pKhLIuzDcr_gCkTEoRN5Wt-vOjw,9888
35
+ ngio/tables/tables_container.py,sha256=DFlz_6ts5p0lHkm6NMBtKZget30OicCYHrLbiG4xU1s,10188
36
36
  ngio/tables/backends/__init__.py,sha256=Y9MIFefwUaSmhhv5FDZFn7jBdYXDML2FovO-uK-vxgI,936
37
37
  ngio/tables/backends/_abstract_backend.py,sha256=--4qeVHs4YRo5i5XsREmDm6BxMsQ5tIqc6XZ810GJno,8776
38
38
  ngio/tables/backends/_anndata_utils.py,sha256=DBWIcR0btnH-DIvDvzlcnMXoYhhtXc9DstryiOP0Qsg,3122
@@ -40,18 +40,18 @@ ngio/tables/backends/_anndata_v1.py,sha256=5p_8pWUkYM4rEhm7g-b2yCXt2mmyd6lFisc1u
40
40
  ngio/tables/backends/_csv_v1.py,sha256=o5AGlBH3UQdXx6MP2DtMm7zmXkOwnBBzu5TKk-QgQdI,5847
41
41
  ngio/tables/backends/_json_v1.py,sha256=7ALjB2thKTxPBeYOleqn2LNuAy6erp0Nzd-GZ9Xcd4Y,3079
42
42
  ngio/tables/backends/_table_backends.py,sha256=NXdH4pxo9XWZ_YxC5RVaw4PTOg-do30c3vlIy8KG4vQ,5831
43
- ngio/tables/backends/_utils.py,sha256=Q1Twe-knhg5b5LHKKSiwppT9lhCPE9-NWb6o1boD7ao,14557
43
+ ngio/tables/backends/_utils.py,sha256=D0zI8_b6HEBZ2ER-80JvEEh_2-aCC1kpyKJGDPBPHco,14661
44
44
  ngio/tables/v1/__init__.py,sha256=XWi6f_KbjbX45Ku-7uymJRSTVWyFAPAAEp_TXDeZV4s,314
45
45
  ngio/tables/v1/_feature_table.py,sha256=2pZEENyZAmn_Awezu8VLGq90d-J7aXd6Ry8gNNR0wAQ,6104
46
46
  ngio/tables/v1/_generic_table.py,sha256=O2fu8k_TjhWEZtJxlU3Uj7ZTZnc75vLlvjw5lweSnd8,5710
47
- ngio/tables/v1/_roi_table.py,sha256=9kVLKzXz2gGrTmPC_sR3Zc6cX5VVROHYEjOJ-0Ol08g,11248
47
+ ngio/tables/v1/_roi_table.py,sha256=zGoISSC5q0UHyc0hcxfm2xpw2W6wUocoYctdi5nMmwg,11460
48
48
  ngio/utils/__init__.py,sha256=r3nuLWgp6-cQlS4ODjYSBrfgdTLkCOVke9jKbn1NpkA,1129
49
49
  ngio/utils/_datasets.py,sha256=EdYJHIifpRou4f43dIuiKsdxe4K6FaeS4f1_e_EYrcI,1727
50
50
  ngio/utils/_errors.py,sha256=pKQ12LUjQLYE1nUawemA5h7HsgznjaSvV1n2PQU33N0,759
51
51
  ngio/utils/_fractal_fsspec_store.py,sha256=7qoGLiLi8JQFh9Ej_z5WNwQQuWrujb0f6p9nj8ocsS8,548
52
52
  ngio/utils/_logger.py,sha256=HIuqD_2ShfFGDswBddcouStbKfL0Vz_ah8cAIFGhbS8,888
53
53
  ngio/utils/_zarr_utils.py,sha256=qOI-HL2HsfFLCj_yxsTR-aq4oHpSqS9KR13aEIvhGDY,13593
54
- ngio-0.2.3.dist-info/METADATA,sha256=8q0VoG887uE9DmawKNHljCbGcXPsqjr4_Tp8nrHAK5A,5215
55
- ngio-0.2.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
56
- ngio-0.2.3.dist-info/licenses/LICENSE,sha256=UgN_a1QCeNh9rZWfz-wORQFxE3elQzLWPQaoK6N6fxQ,1502
57
- ngio-0.2.3.dist-info/RECORD,,
54
+ ngio-0.2.5.dist-info/METADATA,sha256=CfWGOhGP41xxTqsvNvwDeA4nT2hjeMS6yMJ4xHalXqo,5215
55
+ ngio-0.2.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
56
+ ngio-0.2.5.dist-info/licenses/LICENSE,sha256=UgN_a1QCeNh9rZWfz-wORQFxE3elQzLWPQaoK6N6fxQ,1502
57
+ ngio-0.2.5.dist-info/RECORD,,
File without changes