ngio 0.1.2__py3-none-any.whl → 0.1.4__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/core/ngff_image.py CHANGED
@@ -300,6 +300,8 @@ class NgffImage:
300
300
  store: StoreLike,
301
301
  name: str,
302
302
  overwrite: bool = True,
303
+ copy_labels: bool = False,
304
+ copy_tables: bool = False,
303
305
  **kwargs: dict,
304
306
  ) -> "NgffImage":
305
307
  """Derive a new image from the current image.
@@ -308,6 +310,10 @@ class NgffImage:
308
310
  store (StoreLike): The store to create the new image in.
309
311
  name (str): The name of the new image.
310
312
  overwrite (bool): Whether to overwrite the image if it exists
313
+ copy_labels (bool): Whether to copy the labels from the current image
314
+ to the new image.
315
+ copy_tables (bool): Whether to copy the tables from the current image
316
+ to the new image.
311
317
  **kwargs: Additional keyword arguments.
312
318
  Follow the same signature as `create_empty_ome_zarr_image`.
313
319
 
@@ -351,4 +357,31 @@ class NgffImage:
351
357
  create_empty_ome_zarr_image(
352
358
  **default_kwargs,
353
359
  )
354
- return NgffImage(store=store)
360
+
361
+ new_image = NgffImage(store=store)
362
+
363
+ if copy_tables:
364
+ # TODO: to be refactored when the table location is changed in the spec
365
+ source_tables_group = self.tables._table_group
366
+
367
+ if source_tables_group is None:
368
+ raise ValueError("No tables group found in the source image.")
369
+
370
+ zarr.copy(source=source_tables_group, dest=new_image.group)
371
+
372
+ # Reopen the image to get the new tables
373
+ new_image = NgffImage(store=store)
374
+
375
+ if copy_labels:
376
+ # TODO: to be refactored when the label location is changed in the spec
377
+ source_labels_group = self.labels._label_group
378
+
379
+ if source_labels_group is None:
380
+ raise ValueError("No labels group found in the source image.")
381
+
382
+ zarr.copy(source=source_labels_group, dest=new_image.group)
383
+
384
+ # Reopen the image to get the new labels
385
+ new_image = NgffImage(store=store)
386
+
387
+ return new_image
@@ -823,9 +823,7 @@ class Dataset:
823
823
  raise ValueError("Spatial axes must have a unit.")
824
824
  if return_type not in SpaceUnits.allowed_names():
825
825
  raise ValueError(f"Invalid space unit {return_type}.")
826
- if isinstance(return_type, str):
827
- return_type = SpaceUnits(return_type)
828
- return return_type
826
+ return SpaceUnits(return_type)
829
827
 
830
828
  @property
831
829
  def pixel_size(self) -> PixelSize:
@@ -850,8 +848,7 @@ class Dataset:
850
848
  if len(types) == 0:
851
849
  return None
852
850
  elif len(types) == 1:
853
- assert isinstance(types[0], TimeUnits)
854
- return types[0]
851
+ return TimeUnits(types[0])
855
852
  else:
856
853
  raise ValueError("Multiple time axes found. Only one time axis is allowed.")
857
854
 
@@ -156,14 +156,17 @@ class TableGroup:
156
156
 
157
157
  list_of_tables = self._get_list_of_tables()
158
158
  self._validate_list_of_tables(list_of_tables=list_of_tables)
159
+
160
+ all_table_types = ["roi_table", "feature_table", "masking_roi_table"]
161
+
159
162
  if table_type is None:
160
163
  return list_of_tables
161
164
 
162
165
  else:
163
- if table_type not in ["roi_table", "feature_table", "masking_roi_table"]:
166
+ if table_type not in all_table_types:
164
167
  raise ValueError(
165
168
  f"Table type {table_type} not recognized. "
166
- " Allowed values are: 'roi', 'feature', 'masking_roi'."
169
+ f" Allowed values are: {all_table_types}"
167
170
  )
168
171
  list_of_typed_tables = []
169
172
  for table_name in list_of_tables:
@@ -1,11 +1,12 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: ngio
3
- Version: 0.1.2
3
+ Version: 0.1.4
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
7
7
  Author-email: Lorenzo Cerrone <lorenzo.cerrone@uzh.ch>
8
8
  License: BSD-3-Clause
9
+ License-File: LICENSE
9
10
  Classifier: Development Status :: 3 - Alpha
10
11
  Classifier: License :: OSI Approved :: BSD License
11
12
  Classifier: Programming Language :: Python :: 3
@@ -4,7 +4,7 @@ ngio/core/dimensions.py,sha256=AyiXXwgfwe1LiJ7cNhefUVTG2GQqVzDiO0ge_KePf8Q,3722
4
4
  ngio/core/image_handler.py,sha256=2eiklMWCSZD9ajZHEwYJHB1WoQE92YTVOy7qslrtSaw,7569
5
5
  ngio/core/image_like_handler.py,sha256=_k1xs3Uct_FXKoyUDTfQwG755SmiMGlztGhsQW-OtOA,18821
6
6
  ngio/core/label_handler.py,sha256=yBWMQbhme0j4XhXcoWuNY0x3Kt_MH3aYTu6peOfWyTc,14102
7
- ngio/core/ngff_image.py,sha256=7gTPeU4cr51VTODeYEXAwsgXj8fW5NtWzNoLL5DUbSo,12491
7
+ ngio/core/ngff_image.py,sha256=3C4FE9Q-wtKwLn0Cdy7sCGIvFstgZbRWbUq-pUReOG4,13757
8
8
  ngio/core/roi.py,sha256=Vn9aKNxRvJs77ZfVFMAdjOzhy2I2ctpikLcbFP5aj74,2884
9
9
  ngio/core/utils.py,sha256=Z3_nI7nLtMZT2gHFgEFtAox6fcENiFuQA5n6UuK2uDo,10170
10
10
  ngio/io/__init__.py,sha256=g7KmkgRcVBTZbVkqstl_FldUFzz66R-b__HV9hsLvtc,400
@@ -13,7 +13,7 @@ ngio/io/_zarr_array_utils.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,
13
13
  ngio/io/_zarr_group_utils.py,sha256=-cqgxQBvSqPhy5m7iXADOCji3IiEmCgc7zOLeJW5fYw,1754
14
14
  ngio/iterators/__init__.py,sha256=-jQ5h6oNftLKtiHDru8nPOrR3x8H1rMo85hzvqkhxmw,29
15
15
  ngio/ngff_meta/__init__.py,sha256=HhtHzjjk55gaHYbjiHoHRyYmOs1QZgBdWeCBb7O19Vo,560
16
- ngio/ngff_meta/fractal_image_meta.py,sha256=VfRBEhj1PrxF5OReiKhXhO1BAnA5NUGHyY_xZvIHwNw,43472
16
+ ngio/ngff_meta/fractal_image_meta.py,sha256=yc97iEGj5VjaCWv0Md94b5I2p9qzx94DMu_HlyKmrmg,43353
17
17
  ngio/ngff_meta/meta_handler.py,sha256=YDqOl-UUzE-flqC2EXGbJc-ctqZsULsZzA0Xj6X7XkM,2588
18
18
  ngio/ngff_meta/utils.py,sha256=eZSlm1-XJAGiThSol8RW7a_61Crj91f9vXbBGssWnhk,7978
19
19
  ngio/ngff_meta/v04/__init__.py,sha256=zlIL9-R3fNT_mgrOxE51dGyhnJlZ1UX0uRNeEl8WuRM,239
@@ -27,7 +27,7 @@ ngio/pipes/data_pipe.py,sha256=SBe-3kTgbHyvFC2lVYyVZj12JazmHCx9QaTDZW1PNxU,1907
27
27
  ngio/tables/__init__.py,sha256=kedgmeeFVxBAJACoZ1yxfoyTmlmI1HCBWFhgyprbNWI,260
28
28
  ngio/tables/_ad_reader.py,sha256=OQJ3ZwS0wMedlSjz-wQuovIDBojnHRk2Qhq6FL29248,2677
29
29
  ngio/tables/_utils.py,sha256=GFOROQUubpYiZMSJ1tdqUWZGBcXAXGdf18iK2_oj8-0,10236
30
- ngio/tables/tables_group.py,sha256=idcdCAT517ZzoGG6fwRc-yLfBjsfAGXDwg9m-bSdWqM,8603
30
+ ngio/tables/tables_group.py,sha256=DFSDVQz6dYdvI00sKXEeDG7FOX1vAWXiHDDVwEfxL9I,8633
31
31
  ngio/tables/v1/__init__.py,sha256=vwJwo3lSpp6feGcwbn6lWivD1MJ_A8Py7WFsL40xUs0,308
32
32
  ngio/tables/v1/_generic_table.py,sha256=sW9fIyfZZt7QJclFzgWrMFSnCk7gKTP5Kj2atIKi6oA,6084
33
33
  ngio/tables/v1/feature_tables.py,sha256=piC6_eOGOt9IyzXWYqHlR09v0z9Ywm1o8gsdEAsEWts,5892
@@ -38,7 +38,7 @@ ngio/utils/_common_types.py,sha256=ylo6RfCyKVyXPx1Mz7WAwFfz8F85R9yd2_TPlRGRUyo,1
38
38
  ngio/utils/_errors.py,sha256=rLy9LOFkaEmsSD0-nToKUrXY1ZuPfcpcGpmeHVSnTNg,583
39
39
  ngio/utils/_logger.py,sha256=zvFG-Ta3ZIJxTyY93zYoPGp2A6TTUf7mSO0zr_uFy4A,837
40
40
  ngio/utils/_pydantic_utils.py,sha256=uN5-76cjE3bvV8GvLX62fpxoRi8GOsZu6K5aynGH1bY,1711
41
- ngio-0.1.2.dist-info/METADATA,sha256=8F1QCxbL9n5L3KJ7CkhDEhd_3WPD16vTN4IEwLRdWyE,5683
42
- ngio-0.1.2.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
43
- ngio-0.1.2.dist-info/licenses/LICENSE,sha256=UgN_a1QCeNh9rZWfz-wORQFxE3elQzLWPQaoK6N6fxQ,1502
44
- ngio-0.1.2.dist-info/RECORD,,
41
+ ngio-0.1.4.dist-info/METADATA,sha256=PjRzmV7qfMiHPuUPexCO4rLkoyKeTe6QEFBft8dPEnM,5705
42
+ ngio-0.1.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
43
+ ngio-0.1.4.dist-info/licenses/LICENSE,sha256=UgN_a1QCeNh9rZWfz-wORQFxE3elQzLWPQaoK6N6fxQ,1502
44
+ ngio-0.1.4.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.26.3
2
+ Generator: hatchling 1.27.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any