ngio 0.2.0b3__py3-none-any.whl → 0.2.1__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 CHANGED
@@ -9,16 +9,16 @@ except PackageNotFoundError: # pragma: no cover
9
9
  __author__ = "Lorenzo Cerrone"
10
10
  __email__ = "lorenzo.cerrone@uzh.ch"
11
11
 
12
- from ngio.common import ArrayLike, Dimensions
13
- from ngio.hcs import OmeZarrPlate, create_empty_plate, open_omezarr_plate
12
+ from ngio.common import ArrayLike, Dimensions, Roi, RoiPixels
13
+ from ngio.hcs import OmeZarrPlate, create_empty_plate, open_ome_zarr_plate
14
14
  from ngio.images import (
15
15
  Image,
16
16
  Label,
17
17
  OmeZarrContainer,
18
- create_empty_omezarr,
19
- create_omezarr_from_array,
18
+ create_empty_ome_zarr,
19
+ create_ome_zarr_from_array,
20
20
  open_image,
21
- open_omezarr_container,
21
+ open_ome_zarr_container,
22
22
  )
23
23
  from ngio.ome_zarr_meta.ngio_specs import AxesSetup, ImageInWellPath, PixelSize
24
24
 
@@ -32,10 +32,12 @@ __all__ = [
32
32
  "OmeZarrContainer",
33
33
  "OmeZarrPlate",
34
34
  "PixelSize",
35
- "create_empty_omezarr",
35
+ "Roi",
36
+ "RoiPixels",
37
+ "create_empty_ome_zarr",
36
38
  "create_empty_plate",
37
- "create_omezarr_from_array",
39
+ "create_ome_zarr_from_array",
38
40
  "open_image",
39
- "open_omezarr_container",
40
- "open_omezarr_plate",
41
+ "open_ome_zarr_container",
42
+ "open_ome_zarr_plate",
41
43
  ]
ngio/common/__init__.py CHANGED
@@ -15,7 +15,7 @@ from ngio.common._common_types import ArrayLike
15
15
  from ngio.common._dimensions import Dimensions
16
16
  from ngio.common._masking_roi import compute_masking_roi
17
17
  from ngio.common._pyramid import consolidate_pyramid, init_empty_pyramid, on_disk_zoom
18
- from ngio.common._roi import RasterCooROI, WorldCooROI, roi_to_slice_kwargs
18
+ from ngio.common._roi import Roi, RoiPixels, roi_to_slice_kwargs
19
19
  from ngio.common._slicer import (
20
20
  SliceTransform,
21
21
  compute_and_slices,
@@ -29,9 +29,9 @@ from ngio.common._zoom import dask_zoom, numpy_zoom
29
29
  __all__ = [
30
30
  "ArrayLike",
31
31
  "Dimensions",
32
- "RasterCooROI",
32
+ "Roi",
33
+ "RoiPixels",
33
34
  "SliceTransform",
34
- "WorldCooROI",
35
35
  "compute_and_slices",
36
36
  "compute_masking_roi",
37
37
  "consolidate_pyramid",
@@ -124,7 +124,7 @@ def get_pipe(
124
124
  case "dask":
125
125
  return _dask_get_pipe(array, slices, transformations)
126
126
 
127
- case "delayed_numpy":
127
+ case "delayed":
128
128
  return _delayed_numpy_get_pipe(array, slices, transformations)
129
129
 
130
130
  case _:
@@ -179,6 +179,12 @@ def _mask_pipe_common(
179
179
  **slice_kwargs,
180
180
  )
181
181
 
182
+ if not dimensions_label.has_axis("c"):
183
+ # Remove the 'c' from the slice_kwargs
184
+ # This will not work if the query uses non-default
185
+ # axes names for channel
186
+ slice_kwargs = {k: v for k, v in slice_kwargs.items() if k != "c"}
187
+
182
188
  label_patch = get_pipe(
183
189
  label_array,
184
190
  dimensions=dimensions_label,
@@ -8,7 +8,7 @@ import dask.delayed
8
8
  import numpy as np
9
9
  import scipy.ndimage as ndi
10
10
 
11
- from ngio.common._roi import RasterCooROI, WorldCooROI
11
+ from ngio.common._roi import Roi, RoiPixels
12
12
  from ngio.ome_zarr_meta import PixelSize
13
13
  from ngio.utils import NgioValueError
14
14
 
@@ -117,7 +117,7 @@ def lazy_compute_slices(segmentation: da.Array) -> dict[int, tuple[slice, ...]]:
117
117
 
118
118
  def compute_masking_roi(
119
119
  segmentation: np.ndarray | da.Array, pixel_size: PixelSize
120
- ) -> list[WorldCooROI]:
120
+ ) -> list[Roi]:
121
121
  """Compute a ROIs for each label in a segmentation.
122
122
 
123
123
  This function expects a 2D or 3D segmentation array.
@@ -143,7 +143,7 @@ def compute_masking_roi(
143
143
  max_z, max_y, max_x = slice_[0].stop, slice_[1].stop, slice_[2].stop
144
144
  else:
145
145
  raise ValueError("Invalid slice length.")
146
- roi = RasterCooROI(
146
+ roi = RoiPixels(
147
147
  name=str(label),
148
148
  x_length=max_x - min_x,
149
149
  y_length=max_y - min_y,
@@ -153,6 +153,6 @@ def compute_masking_roi(
153
153
  z=min_z,
154
154
  )
155
155
 
156
- roi = roi.to_world_coo_roi(pixel_size)
156
+ roi = roi.to_roi(pixel_size)
157
157
  rois.append(roi)
158
158
  return rois
ngio/common/_roi.py CHANGED
@@ -26,7 +26,7 @@ def _to_world(value: int, pixel_size: float) -> float:
26
26
  return value * pixel_size
27
27
 
28
28
 
29
- class WorldCooROI(BaseModel):
29
+ class Roi(BaseModel):
30
30
  """Region of interest (ROI) metadata."""
31
31
 
32
32
  name: str
@@ -40,16 +40,16 @@ class WorldCooROI(BaseModel):
40
40
 
41
41
  model_config = ConfigDict(extra="allow")
42
42
 
43
- def to_raster_coo(
43
+ def to_pixel_roi(
44
44
  self, pixel_size: PixelSize, dimensions: Dimensions
45
- ) -> "RasterCooROI":
45
+ ) -> "RoiPixels":
46
46
  """Convert to raster coordinates."""
47
47
  dim_x = dimensions.get("x")
48
48
  dim_y = dimensions.get("y")
49
49
  # Will default to 1 if z does not exist
50
50
  dim_z = dimensions.get("z", strict=False)
51
51
 
52
- return RasterCooROI(
52
+ return RoiPixels(
53
53
  name=self.name,
54
54
  x=_to_raster(self.x, pixel_size.x, dim_x),
55
55
  y=_to_raster(self.y, pixel_size.y, dim_y),
@@ -59,7 +59,7 @@ class WorldCooROI(BaseModel):
59
59
  z_length=_to_raster(self.z_length, pixel_size.z, dim_z),
60
60
  )
61
61
 
62
- def zoom(self, zoom_factor: float = 1) -> "WorldCooROI":
62
+ def zoom(self, zoom_factor: float = 1) -> "Roi":
63
63
  """Zoom the ROI by a factor.
64
64
 
65
65
  Args:
@@ -71,7 +71,7 @@ class WorldCooROI(BaseModel):
71
71
  return zoom_roi(self, zoom_factor)
72
72
 
73
73
 
74
- class RasterCooROI(BaseModel):
74
+ class RoiPixels(BaseModel):
75
75
  """Region of interest (ROI) metadata."""
76
76
 
77
77
  name: str
@@ -83,9 +83,9 @@ class RasterCooROI(BaseModel):
83
83
  z_length: int
84
84
  model_config = ConfigDict(extra="allow")
85
85
 
86
- def to_world_coo_roi(self, pixel_size: PixelSize) -> WorldCooROI:
86
+ def to_roi(self, pixel_size: PixelSize) -> Roi:
87
87
  """Convert to world coordinates."""
88
- return WorldCooROI(
88
+ return Roi(
89
89
  name=self.name,
90
90
  x=_to_world(self.x, pixel_size.x),
91
91
  y=_to_world(self.y, pixel_size.y),
@@ -105,7 +105,7 @@ class RasterCooROI(BaseModel):
105
105
  }
106
106
 
107
107
 
108
- def zoom_roi(roi: WorldCooROI, zoom_factor: float = 1) -> WorldCooROI:
108
+ def zoom_roi(roi: Roi, zoom_factor: float = 1) -> Roi:
109
109
  """Zoom the ROI by a factor.
110
110
 
111
111
  Args:
@@ -127,7 +127,7 @@ def zoom_roi(roi: WorldCooROI, zoom_factor: float = 1) -> WorldCooROI:
127
127
  new_x = max(roi.x - diff_x / 2, 0)
128
128
  new_y = max(roi.y - diff_y / 2, 0)
129
129
 
130
- new_roi = WorldCooROI(
130
+ new_roi = Roi(
131
131
  name=roi.name,
132
132
  x=new_x,
133
133
  y=new_y,
@@ -142,13 +142,13 @@ def zoom_roi(roi: WorldCooROI, zoom_factor: float = 1) -> WorldCooROI:
142
142
 
143
143
 
144
144
  def roi_to_slice_kwargs(
145
- roi: WorldCooROI,
145
+ roi: Roi,
146
146
  pixel_size: PixelSize,
147
147
  dimensions: Dimensions,
148
148
  **slice_kwargs: slice | int | Iterable[int],
149
149
  ) -> dict[str, slice | int | Iterable[int]]:
150
150
  """Convert a WorldCooROI to slice_kwargs."""
151
- raster_roi = roi.to_raster_coo(
151
+ raster_roi = roi.to_pixel_roi(
152
152
  pixel_size=pixel_size, dimensions=dimensions
153
153
  ).to_slices()
154
154
 
ngio/hcs/__init__.py CHANGED
@@ -1,5 +1,5 @@
1
1
  """OME-Zarr HCS objects models."""
2
2
 
3
- from ngio.hcs.plate import OmeZarrPlate, create_empty_plate, open_omezarr_plate
3
+ from ngio.hcs.plate import OmeZarrPlate, create_empty_plate, open_ome_zarr_plate
4
4
 
5
- __all__ = ["OmeZarrPlate", "create_empty_plate", "open_omezarr_plate"]
5
+ __all__ = ["OmeZarrPlate", "create_empty_plate", "open_ome_zarr_plate"]
ngio/hcs/plate.py CHANGED
@@ -3,6 +3,7 @@
3
3
  from ngio.images import OmeZarrContainer
4
4
  from ngio.ome_zarr_meta import (
5
5
  ImageInWellPath,
6
+ NgffVersion,
6
7
  NgioPlateMeta,
7
8
  NgioWellMeta,
8
9
  find_plate_meta_handler,
@@ -78,7 +79,7 @@ class OmeZarrPlate:
78
79
 
79
80
  def __repr__(self) -> str:
80
81
  """Return a string representation of the plate."""
81
- return f"Plate([rows x columns] ({len(self.rows)} x {len(self.columns)})"
82
+ return f"Plate([rows x columns] ({len(self.rows)} x {len(self.columns)}))"
82
83
 
83
84
  @property
84
85
  def meta_handler(self):
@@ -110,21 +111,54 @@ class OmeZarrPlate:
110
111
  """Return the acquisitions ids in the plate."""
111
112
  return self.meta.acquisitions_ids
112
113
 
113
- @property
114
- def wells_paths(self) -> list[str]:
115
- """Return the wells paths in the plate."""
116
- return self.meta.wells_paths
117
-
118
- def get_well_path(self, row: str, column: int | str) -> str:
114
+ def _well_path(self, row: str, column: int | str) -> str:
119
115
  """Return the well path in the plate."""
120
116
  return self.meta.get_well_path(row=row, column=column)
121
117
 
122
- def get_image_path(self, row: str, column: int | str, path: str) -> str:
118
+ def _image_path(self, row: str, column: int | str, path: str) -> str:
123
119
  """Return the image path in the plate."""
124
120
  well = self.get_well(row, column)
125
121
  if path not in well.paths():
126
122
  raise ValueError(f"Image {path} does not exist in well {row}{column}")
127
- return f"{self.get_well_path(row, column)}/{path}"
123
+ return f"{self._well_path(row, column)}/{path}"
124
+
125
+ def wells_paths(self) -> list[str]:
126
+ """Return the wells paths in the plate."""
127
+ return self.meta.wells_paths
128
+
129
+ def images_paths(self, acquisition: int | None = None) -> list[str]:
130
+ """Return the images paths in the plate.
131
+
132
+ If acquisition is None, return all images paths in the plate.
133
+ Else, return the images paths in the plate for the given acquisition.
134
+
135
+ Args:
136
+ acquisition (int | None): The acquisition id to filter the images.
137
+ """
138
+ images = []
139
+ for well_path, wells in self.get_wells().items():
140
+ for img_path in wells.paths(acquisition):
141
+ images.append(f"{well_path}/{img_path}")
142
+ return images
143
+
144
+ def well_images_paths(
145
+ self, row: str, column: int | str, acquisition: int | None = None
146
+ ) -> list[str]:
147
+ """Return the images paths in a well.
148
+
149
+ If acquisition is None, return all images paths in the well.
150
+ Else, return the images paths in the well for the given acquisition.
151
+
152
+ Args:
153
+ row (str): The row of the well.
154
+ column (int | str): The column of the well.
155
+ acquisition (int | None): The acquisition id to filter the images.
156
+ """
157
+ images = []
158
+ well = self.get_well(row=row, column=column)
159
+ for path in well.paths(acquisition):
160
+ images.append(self._image_path(row=row, column=column, path=path))
161
+ return images
128
162
 
129
163
  def get_well(self, row: str, column: int | str) -> OmeZarrWell:
130
164
  """Get a well from the plate.
@@ -136,36 +170,56 @@ class OmeZarrPlate:
136
170
  Returns:
137
171
  OmeZarrWell: The well.
138
172
  """
139
- well_path = self.meta.get_well_path(row=row, column=column)
173
+ well_path = self._well_path(row=row, column=column)
140
174
  group_handler = self._group_handler.derive_handler(well_path)
141
175
  return OmeZarrWell(group_handler)
142
176
 
143
177
  def get_wells(self) -> dict[str, OmeZarrWell]:
144
- """Get all wells in the plate."""
178
+ """Get all wells in the plate.
179
+
180
+ Returns:
181
+ dict[str, OmeZarrWell]: A dictionary of wells, where the key is the well
182
+ path and the value is the well object.
183
+ """
145
184
  wells = {}
146
- for well_path in self.wells_paths:
185
+ for well_path in self.wells_paths():
147
186
  group_handler = self._group_handler.derive_handler(well_path)
148
187
  well = OmeZarrWell(group_handler)
149
188
  wells[well_path] = well
150
189
  return wells
151
190
 
152
- def get_images(self, acquisition: int | None = None) -> list[OmeZarrContainer]:
191
+ def get_images(self, acquisition: int | None = None) -> dict[str, OmeZarrContainer]:
153
192
  """Get all images in the plate.
154
193
 
155
194
  Args:
156
195
  acquisition: The acquisition id to filter the images.
157
196
  """
158
- images = []
159
- for well_path, well in self.get_wells().items():
160
- for img_path in well.paths(acquisition):
161
- full_path = f"{well_path}/{img_path}"
162
- img_group_handler = self._group_handler.derive_handler(full_path)
163
- images.append(OmeZarrContainer(img_group_handler))
197
+ images = {}
198
+ for image_path in self.images_paths(acquisition):
199
+ img_group_handler = self._group_handler.derive_handler(image_path)
200
+ images[image_path] = OmeZarrContainer(img_group_handler)
164
201
  return images
165
202
 
203
+ def get_image(
204
+ self, row: str, column: int | str, image_path: str
205
+ ) -> OmeZarrContainer:
206
+ """Get an image from the plate.
207
+
208
+ Args:
209
+ row (str): The row of the well.
210
+ column (int | str): The column of the well.
211
+ image_path (str): The path of the image.
212
+
213
+ Returns:
214
+ OmeZarrContainer: The image.
215
+ """
216
+ image_path = self._image_path(row=row, column=column, path=image_path)
217
+ group_handler = self._group_handler.derive_handler(image_path)
218
+ return OmeZarrContainer(group_handler)
219
+
166
220
  def get_well_images(
167
221
  self, row: str, column: str | int, acquisition: int | None = None
168
- ) -> list[OmeZarrContainer]:
222
+ ) -> dict[str, OmeZarrContainer]:
169
223
  """Get all images in a well.
170
224
 
171
225
  Args:
@@ -173,16 +227,12 @@ class OmeZarrPlate:
173
227
  column: The column of the well.
174
228
  acquisition: The acquisition id to filter the images.
175
229
  """
176
- well_path = self.meta.get_well_path(row=row, column=column)
177
- group_handler = self._group_handler.derive_handler(well_path)
178
- well = OmeZarrWell(group_handler)
179
-
180
- images = []
181
- for path in well.paths(acquisition):
182
- image_path = f"{well_path}/{path}"
183
- group_handler = self._group_handler.derive_handler(image_path)
184
- images.append(OmeZarrContainer(group_handler))
185
-
230
+ images = {}
231
+ for image_paths in self.well_images_paths(
232
+ row=row, column=column, acquisition=acquisition
233
+ ):
234
+ group_handler = self._group_handler.derive_handler(image_paths)
235
+ images[image_paths] = OmeZarrContainer(group_handler)
186
236
  return images
187
237
 
188
238
  def _add_image(
@@ -220,7 +270,9 @@ class OmeZarrPlate:
220
270
  # Initialize the well metadata
221
271
  # if the group is empty
222
272
  well_meta = NgioWellMeta.default_init()
223
- meta_handler = get_well_meta_handler(group_handler, version="0.4")
273
+ version = self.meta.plate.version
274
+ version = version if version is not None else "0.4"
275
+ meta_handler = get_well_meta_handler(group_handler, version=version)
224
276
  else:
225
277
  meta_handler = find_well_meta_handler(group_handler)
226
278
  well_meta = meta_handler.meta
@@ -339,7 +391,7 @@ class OmeZarrPlate:
339
391
  )
340
392
 
341
393
 
342
- def open_omezarr_plate(
394
+ def open_ome_zarr_plate(
343
395
  store: StoreOrGroup,
344
396
  cache: bool = False,
345
397
  mode: AccessModeLiteral = "r+",
@@ -364,7 +416,7 @@ def create_empty_plate(
364
416
  store: StoreOrGroup,
365
417
  name: str,
366
418
  images: list[ImageInWellPath] | None = None,
367
- version: str = "0.4",
419
+ version: NgffVersion = "0.4",
368
420
  cache: bool = False,
369
421
  overwrite: bool = False,
370
422
  parallel_safe: bool = True,
@@ -391,7 +443,7 @@ def create_empty_plate(
391
443
  acquisition_id=image.acquisition_id,
392
444
  acquisition_name=image.acquisition_name,
393
445
  )
394
- return open_omezarr_plate(
446
+ return open_ome_zarr_plate(
395
447
  store=store,
396
448
  cache=cache,
397
449
  mode="r+",
ngio/images/__init__.py CHANGED
@@ -2,12 +2,12 @@
2
2
 
3
3
  from ngio.images.image import Image, ImagesContainer
4
4
  from ngio.images.label import Label, LabelsContainer
5
- from ngio.images.omezarr_container import (
5
+ from ngio.images.ome_zarr_container import (
6
6
  OmeZarrContainer,
7
- create_empty_omezarr,
8
- create_omezarr_from_array,
7
+ create_empty_ome_zarr,
8
+ create_ome_zarr_from_array,
9
9
  open_image,
10
- open_omezarr_container,
10
+ open_ome_zarr_container,
11
11
  )
12
12
 
13
13
  __all__ = [
@@ -16,8 +16,8 @@ __all__ = [
16
16
  "Label",
17
17
  "LabelsContainer",
18
18
  "OmeZarrContainer",
19
- "create_empty_omezarr",
20
- "create_omezarr_from_array",
19
+ "create_empty_ome_zarr",
20
+ "create_ome_zarr_from_array",
21
21
  "open_image",
22
- "open_omezarr_container",
22
+ "open_ome_zarr_container",
23
23
  ]
@@ -8,14 +8,15 @@ import zarr
8
8
  from ngio.common import (
9
9
  ArrayLike,
10
10
  Dimensions,
11
- RasterCooROI,
12
- WorldCooROI,
11
+ Roi,
12
+ RoiPixels,
13
13
  consolidate_pyramid,
14
14
  get_pipe,
15
15
  roi_to_slice_kwargs,
16
16
  set_pipe,
17
17
  )
18
18
  from ngio.ome_zarr_meta import (
19
+ AxesMapper,
19
20
  Dataset,
20
21
  ImageMetaHandler,
21
22
  LabelMetaHandler,
@@ -43,7 +44,7 @@ class AbstractImage(Generic[_image_handler]):
43
44
 
44
45
  Args:
45
46
  group_handler: The Zarr group handler.
46
- path: The path to the image in the omezarr file.
47
+ path: The path to the image in the ome_zarr file.
47
48
  meta_handler: The image metadata handler.
48
49
 
49
50
  """
@@ -63,7 +64,7 @@ class AbstractImage(Generic[_image_handler]):
63
64
  shape=self._zarr_array.shape, axes_mapper=self._dataset.axes_mapper
64
65
  )
65
66
 
66
- self._axer_mapper = self._dataset.axes_mapper
67
+ self._axes_mapper = self._dataset.axes_mapper
67
68
 
68
69
  def __repr__(self) -> str:
69
70
  """Return a string representation of the image."""
@@ -99,6 +100,11 @@ class AbstractImage(Generic[_image_handler]):
99
100
  """Return the dimensions of the image."""
100
101
  return self._dimensions
101
102
 
103
+ @property
104
+ def axes_mapper(self) -> AxesMapper:
105
+ """Return the axes mapper of the image."""
106
+ return self._axes_mapper
107
+
102
108
  @property
103
109
  def is_3d(self) -> bool:
104
110
  """Return True if the image is 3D."""
@@ -144,6 +150,10 @@ class AbstractImage(Generic[_image_handler]):
144
150
  """Return the path of the image."""
145
151
  return self._dataset.path
146
152
 
153
+ def has_axis(self, axis: str) -> bool:
154
+ """Return True if the image has the given axis."""
155
+ return self.dimensions.has_axis(axis)
156
+
147
157
  def get_array(
148
158
  self,
149
159
  axes_order: Collection[str] | None = None,
@@ -170,7 +180,7 @@ class AbstractImage(Generic[_image_handler]):
170
180
 
171
181
  def get_roi(
172
182
  self,
173
- roi: WorldCooROI,
183
+ roi: Roi,
174
184
  axes_order: Collection[str] | None = None,
175
185
  mode: Literal["numpy", "dask", "delayed"] = "numpy",
176
186
  **slice_kwargs: slice | int | Iterable[int],
@@ -214,7 +224,7 @@ class AbstractImage(Generic[_image_handler]):
214
224
 
215
225
  def set_roi(
216
226
  self,
217
- roi: WorldCooROI,
227
+ roi: Roi,
218
228
  patch: ArrayLike,
219
229
  axes_order: Collection[str] | None = None,
220
230
  **slice_kwargs: slice | int | Iterable[int],
@@ -256,7 +266,7 @@ def consolidate_image(
256
266
 
257
267
  def get_roi_pipe(
258
268
  image: AbstractImage,
259
- roi: WorldCooROI,
269
+ roi: Roi,
260
270
  axes_order: Collection[str] | None = None,
261
271
  mode: Literal["numpy", "dask", "delayed"] = "numpy",
262
272
  **slice_kwargs: slice | int | Iterable[int],
@@ -290,7 +300,7 @@ def get_roi_pipe(
290
300
 
291
301
  def set_roi_pipe(
292
302
  image: AbstractImage,
293
- roi: WorldCooROI,
303
+ roi: Roi,
294
304
  patch: ArrayLike,
295
305
  axes_order: Collection[str] | None = None,
296
306
  **slice_kwargs: slice | int | Iterable[int],
@@ -327,7 +337,7 @@ def build_image_roi_table(image: AbstractImage, name: str = "image") -> RoiTable
327
337
  image.dimensions.get("y"),
328
338
  image.dimensions.get("x"),
329
339
  )
330
- image_roi = RasterCooROI(
340
+ image_roi = RoiPixels(
331
341
  name=name,
332
342
  x=0,
333
343
  y=0,
@@ -336,4 +346,4 @@ def build_image_roi_table(image: AbstractImage, name: str = "image") -> RoiTable
336
346
  y_length=dim_y,
337
347
  z_length=dim_z,
338
348
  )
339
- return RoiTable(rois=[image_roi.to_world_coo_roi(pixel_size=image.pixel_size)])
349
+ return RoiTable(rois=[image_roi.to_roi(pixel_size=image.pixel_size)])
ngio/images/create.py CHANGED
@@ -12,6 +12,7 @@ from ngio.ome_zarr_meta import (
12
12
  get_label_meta_handler,
13
13
  )
14
14
  from ngio.ome_zarr_meta.ngio_specs import (
15
+ NgffVersion,
15
16
  SpaceUnits,
16
17
  TimeUnits,
17
18
  canonical_axes_order,
@@ -34,7 +35,7 @@ def _init_generic_meta(
34
35
  space_unit: SpaceUnits | str | None = None,
35
36
  time_unit: TimeUnits | str | None = None,
36
37
  name: str | None = None,
37
- version: str = "0.4",
38
+ version: NgffVersion = "0.4",
38
39
  ) -> tuple[_image_or_label_meta, list[float]]:
39
40
  """Initialize the metadata for an image or label."""
40
41
  scaling_factors = []
@@ -104,7 +105,7 @@ def _create_empty_label(
104
105
  chunks: Collection[int] | None = None,
105
106
  dtype: str = "uint16",
106
107
  overwrite: bool = False,
107
- version: str = "0.4",
108
+ version: NgffVersion = "0.4",
108
109
  ) -> ZarrGroupHandler:
109
110
  """Create an empty label with the given shape and metadata.
110
111
 
@@ -195,7 +196,7 @@ def _create_empty_image(
195
196
  chunks: Collection[int] | None = None,
196
197
  dtype: str = "uint16",
197
198
  overwrite: bool = False,
198
- version: str = "0.4",
199
+ version: NgffVersion = "0.4",
199
200
  ) -> ZarrGroupHandler:
200
201
  """Create an empty OME-Zarr image with the given shape and metadata.
201
202
 
ngio/images/image.py CHANGED
@@ -55,7 +55,7 @@ class Image(AbstractImage[ImageMetaHandler]):
55
55
 
56
56
  Args:
57
57
  group_handler: The Zarr group handler.
58
- path: The path to the image in the omezarr file.
58
+ path: The path to the image in the ome_zarr file.
59
59
  meta_handler: The image metadata handler.
60
60
 
61
61
  """
@@ -281,7 +281,7 @@ class ImagesContainer:
281
281
  """Get an image at a specific level.
282
282
 
283
283
  Args:
284
- path (str | None): The path to the image in the omezarr file.
284
+ path (str | None): The path to the image in the ome_zarr file.
285
285
  pixel_size (PixelSize | None): The pixel size of the image.
286
286
  strict (bool): Only used if the pixel size is provided. If True, the
287
287
  pixel size must match the image pixel size exactly. If False, the
ngio/images/label.py CHANGED
@@ -13,7 +13,7 @@ from ngio.ome_zarr_meta import (
13
13
  PixelSize,
14
14
  find_label_meta_handler,
15
15
  )
16
- from ngio.tables import MaskingROITable
16
+ from ngio.tables import MaskingRoiTable
17
17
  from ngio.utils import (
18
18
  NgioValidationError,
19
19
  NgioValueError,
@@ -35,7 +35,7 @@ class Label(AbstractImage[LabelMetaHandler]):
35
35
 
36
36
  Args:
37
37
  group_handler: The Zarr group handler.
38
- path: The path to the image in the omezarr file.
38
+ path: The path to the image in the ome_zarr file.
39
39
  meta_handler: The image metadata handler.
40
40
 
41
41
  """
@@ -45,12 +45,16 @@ class Label(AbstractImage[LabelMetaHandler]):
45
45
  group_handler=group_handler, path=path, meta_handler=meta_handler
46
46
  )
47
47
 
48
+ def __repr__(self) -> str:
49
+ """Return the string representation of the label."""
50
+ return f"Label(path={self.path}, {self.dimensions})"
51
+
48
52
  @property
49
53
  def meta(self) -> NgioLabelMeta:
50
54
  """Return the metadata."""
51
55
  return self._meta_handler.meta
52
56
 
53
- def build_masking_roi_table(self) -> MaskingROITable:
57
+ def build_masking_roi_table(self) -> MaskingRoiTable:
54
58
  """Compute the masking ROI table."""
55
59
  return build_masking_roi_table(self)
56
60
 
@@ -101,7 +105,7 @@ class LabelsContainer:
101
105
 
102
106
  Args:
103
107
  name (str): The name of the label.
104
- path (str | None): The path to the image in the omezarr file.
108
+ path (str | None): The path to the image in the ome_zarr file.
105
109
  pixel_size (PixelSize | None): The pixel size of the image.
106
110
  strict (bool): Only used if the pixel size is provided. If True, the
107
111
  pixel size must match the image pixel size exactly. If False, the
@@ -270,7 +274,7 @@ def _derive_label(
270
274
  return None
271
275
 
272
276
 
273
- def build_masking_roi_table(label: Label) -> MaskingROITable:
277
+ def build_masking_roi_table(label: Label) -> MaskingRoiTable:
274
278
  """Compute the masking ROI table for a label."""
275
279
  if label.dimensions.is_time_series:
276
280
  raise NgioValueError("Time series labels are not supported.")
@@ -278,4 +282,4 @@ def build_masking_roi_table(label: Label) -> MaskingROITable:
278
282
  array = label.get_array(axes_order=["z", "y", "x"], mode="dask")
279
283
 
280
284
  rois = compute_masking_roi(array, label.pixel_size)
281
- return MaskingROITable(rois, reference_label=label.meta.name)
285
+ return MaskingRoiTable(rois, reference_label=label.meta.name)