ngio 0.2.1__py3-none-any.whl → 0.2.2__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 +20 -2
- ngio/common/_roi.py +2 -2
- ngio/hcs/__init__.py +16 -2
- ngio/hcs/plate.py +381 -22
- ngio/images/abstract_image.py +10 -0
- ngio/images/create.py +25 -36
- ngio/images/image.py +38 -6
- ngio/images/label.py +23 -2
- ngio/images/ome_zarr_container.py +66 -26
- ngio/ome_zarr_meta/__init__.py +5 -3
- ngio/ome_zarr_meta/ngio_specs/__init__.py +10 -2
- ngio/ome_zarr_meta/ngio_specs/_axes.py +90 -65
- ngio/ome_zarr_meta/ngio_specs/_dataset.py +46 -8
- ngio/ome_zarr_meta/ngio_specs/_ngio_hcs.py +242 -70
- ngio/ome_zarr_meta/ngio_specs/_ngio_image.py +49 -11
- ngio/ome_zarr_meta/ngio_specs/_pixel_size.py +28 -11
- ngio/ome_zarr_meta/v04/_custom_models.py +18 -0
- ngio/ome_zarr_meta/v04/_v04_spec_utils.py +2 -2
- {ngio-0.2.1.dist-info → ngio-0.2.2.dist-info}/METADATA +1 -1
- {ngio-0.2.1.dist-info → ngio-0.2.2.dist-info}/RECORD +22 -21
- {ngio-0.2.1.dist-info → ngio-0.2.2.dist-info}/WHEEL +0 -0
- {ngio-0.2.1.dist-info → ngio-0.2.2.dist-info}/licenses/LICENSE +0 -0
ngio/images/create.py
CHANGED
|
@@ -12,7 +12,10 @@ 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
|
-
|
|
15
|
+
DefaultNgffVersion,
|
|
16
|
+
DefaultSpaceUnit,
|
|
17
|
+
DefaultTimeUnit,
|
|
18
|
+
NgffVersions,
|
|
16
19
|
SpaceUnits,
|
|
17
20
|
TimeUnits,
|
|
18
21
|
canonical_axes_order,
|
|
@@ -32,10 +35,10 @@ def _init_generic_meta(
|
|
|
32
35
|
levels: int | list[str] = 5,
|
|
33
36
|
yx_scaling_factor: float | tuple[float, float] = 2.0,
|
|
34
37
|
z_scaling_factor: float = 1.0,
|
|
35
|
-
space_unit: SpaceUnits | str | None =
|
|
36
|
-
time_unit: TimeUnits | str | None =
|
|
38
|
+
space_unit: SpaceUnits | str | None = DefaultSpaceUnit,
|
|
39
|
+
time_unit: TimeUnits | str | None = DefaultTimeUnit,
|
|
37
40
|
name: str | None = None,
|
|
38
|
-
version:
|
|
41
|
+
version: NgffVersions = DefaultNgffVersion,
|
|
39
42
|
) -> tuple[_image_or_label_meta, list[float]]:
|
|
40
43
|
"""Initialize the metadata for an image or label."""
|
|
41
44
|
scaling_factors = []
|
|
@@ -55,20 +58,6 @@ def _init_generic_meta(
|
|
|
55
58
|
else:
|
|
56
59
|
scaling_factors.append(1.0)
|
|
57
60
|
|
|
58
|
-
if space_unit is None:
|
|
59
|
-
space_unit = SpaceUnits.micrometer
|
|
60
|
-
elif isinstance(space_unit, str):
|
|
61
|
-
space_unit = SpaceUnits(space_unit)
|
|
62
|
-
elif not isinstance(space_unit, SpaceUnits):
|
|
63
|
-
raise NgioValueError(f"space_unit can not be {type(space_unit)}.")
|
|
64
|
-
|
|
65
|
-
if time_unit is None:
|
|
66
|
-
time_unit = TimeUnits.seconds
|
|
67
|
-
elif isinstance(time_unit, str):
|
|
68
|
-
time_unit = TimeUnits(time_unit)
|
|
69
|
-
elif not isinstance(time_unit, TimeUnits):
|
|
70
|
-
raise NgioValueError(f"time_units can not be {type(time_unit)}.")
|
|
71
|
-
|
|
72
61
|
pixel_sizes = PixelSize(
|
|
73
62
|
x=pixelsize,
|
|
74
63
|
y=pixelsize,
|
|
@@ -89,7 +78,7 @@ def _init_generic_meta(
|
|
|
89
78
|
return meta, scaling_factors
|
|
90
79
|
|
|
91
80
|
|
|
92
|
-
def
|
|
81
|
+
def create_empty_label_container(
|
|
93
82
|
store: StoreOrGroup,
|
|
94
83
|
shape: Collection[int],
|
|
95
84
|
pixelsize: float,
|
|
@@ -98,14 +87,14 @@ def _create_empty_label(
|
|
|
98
87
|
levels: int | list[str] = 5,
|
|
99
88
|
yx_scaling_factor: float | tuple[float, float] = 2.0,
|
|
100
89
|
z_scaling_factor: float = 1.0,
|
|
101
|
-
space_unit: SpaceUnits | str | None =
|
|
102
|
-
time_unit: TimeUnits | str | None =
|
|
90
|
+
space_unit: SpaceUnits | str | None = DefaultSpaceUnit,
|
|
91
|
+
time_unit: TimeUnits | str | None = DefaultTimeUnit,
|
|
103
92
|
axes_names: Collection[str] | None = None,
|
|
104
93
|
name: str | None = None,
|
|
105
94
|
chunks: Collection[int] | None = None,
|
|
106
95
|
dtype: str = "uint16",
|
|
107
96
|
overwrite: bool = False,
|
|
108
|
-
version:
|
|
97
|
+
version: NgffVersions = DefaultNgffVersion,
|
|
109
98
|
) -> ZarrGroupHandler:
|
|
110
99
|
"""Create an empty label with the given shape and metadata.
|
|
111
100
|
|
|
@@ -122,10 +111,10 @@ def _create_empty_label(
|
|
|
122
111
|
dimensions. Defaults to 2.0.
|
|
123
112
|
z_scaling_factor (float, optional): The down-scaling factor in z dimension.
|
|
124
113
|
Defaults to 1.0.
|
|
125
|
-
space_unit (SpaceUnits
|
|
126
|
-
|
|
127
|
-
time_unit (TimeUnits
|
|
128
|
-
|
|
114
|
+
space_unit (SpaceUnits, optional): The unit of space. Defaults to
|
|
115
|
+
DefaultSpaceUnit.
|
|
116
|
+
time_unit (TimeUnits, optional): The unit of time. Defaults to
|
|
117
|
+
DefaultTimeUnit.
|
|
129
118
|
axes_names (Collection[str] | None, optional): The names of the axes.
|
|
130
119
|
If None the canonical names are used. Defaults to None.
|
|
131
120
|
name (str | None, optional): The name of the image. Defaults to None.
|
|
@@ -135,7 +124,7 @@ def _create_empty_label(
|
|
|
135
124
|
overwrite (bool, optional): Whether to overwrite an existing image.
|
|
136
125
|
Defaults to True.
|
|
137
126
|
version (str, optional): The version of the OME-Zarr specification.
|
|
138
|
-
Defaults to
|
|
127
|
+
Defaults to DefaultVersion.
|
|
139
128
|
|
|
140
129
|
"""
|
|
141
130
|
if axes_names is None:
|
|
@@ -180,7 +169,7 @@ def _create_empty_label(
|
|
|
180
169
|
return group_handler
|
|
181
170
|
|
|
182
171
|
|
|
183
|
-
def
|
|
172
|
+
def create_empty_image_container(
|
|
184
173
|
store: StoreOrGroup,
|
|
185
174
|
shape: Collection[int],
|
|
186
175
|
pixelsize: float,
|
|
@@ -189,14 +178,14 @@ def _create_empty_image(
|
|
|
189
178
|
levels: int | list[str] = 5,
|
|
190
179
|
yx_scaling_factor: float | tuple[float, float] = 2,
|
|
191
180
|
z_scaling_factor: float = 1.0,
|
|
192
|
-
space_unit: SpaceUnits | str | None =
|
|
193
|
-
time_unit: TimeUnits | str | None =
|
|
181
|
+
space_unit: SpaceUnits | str | None = DefaultSpaceUnit,
|
|
182
|
+
time_unit: TimeUnits | str | None = DefaultTimeUnit,
|
|
194
183
|
axes_names: Collection[str] | None = None,
|
|
195
184
|
name: str | None = None,
|
|
196
185
|
chunks: Collection[int] | None = None,
|
|
197
186
|
dtype: str = "uint16",
|
|
198
187
|
overwrite: bool = False,
|
|
199
|
-
version:
|
|
188
|
+
version: NgffVersions = DefaultNgffVersion,
|
|
200
189
|
) -> ZarrGroupHandler:
|
|
201
190
|
"""Create an empty OME-Zarr image with the given shape and metadata.
|
|
202
191
|
|
|
@@ -213,10 +202,10 @@ def _create_empty_image(
|
|
|
213
202
|
dimensions. Defaults to 2.0.
|
|
214
203
|
z_scaling_factor (float, optional): The down-scaling factor in z dimension.
|
|
215
204
|
Defaults to 1.0.
|
|
216
|
-
space_unit (SpaceUnits
|
|
217
|
-
|
|
218
|
-
time_unit (TimeUnits
|
|
219
|
-
|
|
205
|
+
space_unit (SpaceUnits, optional): The unit of space. Defaults to
|
|
206
|
+
DefaultSpaceUnit.
|
|
207
|
+
time_unit (TimeUnits, optional): The unit of time. Defaults to
|
|
208
|
+
DefaultTimeUnit.
|
|
220
209
|
axes_names (Collection[str] | None, optional): The names of the axes.
|
|
221
210
|
If None the canonical names are used. Defaults to None.
|
|
222
211
|
name (str | None, optional): The name of the image. Defaults to None.
|
|
@@ -226,7 +215,7 @@ def _create_empty_image(
|
|
|
226
215
|
overwrite (bool, optional): Whether to overwrite an existing image.
|
|
227
216
|
Defaults to True.
|
|
228
217
|
version (str, optional): The version of the OME-Zarr specification.
|
|
229
|
-
Defaults to
|
|
218
|
+
Defaults to DefaultVersion.
|
|
230
219
|
|
|
231
220
|
"""
|
|
232
221
|
if axes_names is None:
|
ngio/images/image.py
CHANGED
|
@@ -7,14 +7,22 @@ from dask import array as da
|
|
|
7
7
|
|
|
8
8
|
from ngio.common import Dimensions
|
|
9
9
|
from ngio.images.abstract_image import AbstractImage, consolidate_image
|
|
10
|
-
from ngio.images.create import
|
|
10
|
+
from ngio.images.create import create_empty_image_container
|
|
11
11
|
from ngio.ome_zarr_meta import (
|
|
12
12
|
ImageMetaHandler,
|
|
13
13
|
NgioImageMeta,
|
|
14
14
|
PixelSize,
|
|
15
15
|
find_image_meta_handler,
|
|
16
16
|
)
|
|
17
|
-
from ngio.ome_zarr_meta.ngio_specs import
|
|
17
|
+
from ngio.ome_zarr_meta.ngio_specs import (
|
|
18
|
+
Channel,
|
|
19
|
+
ChannelsMeta,
|
|
20
|
+
ChannelVisualisation,
|
|
21
|
+
DefaultSpaceUnit,
|
|
22
|
+
DefaultTimeUnit,
|
|
23
|
+
SpaceUnits,
|
|
24
|
+
TimeUnits,
|
|
25
|
+
)
|
|
18
26
|
from ngio.utils import (
|
|
19
27
|
NgioValidationError,
|
|
20
28
|
StoreOrGroup,
|
|
@@ -142,7 +150,7 @@ class ImagesContainer:
|
|
|
142
150
|
image = self.get()
|
|
143
151
|
return image.wavelength_ids
|
|
144
152
|
|
|
145
|
-
def
|
|
153
|
+
def set_channel_meta(
|
|
146
154
|
self,
|
|
147
155
|
labels: Collection[str] | int | None = None,
|
|
148
156
|
wavelength_id: Collection[str] | None = None,
|
|
@@ -196,7 +204,7 @@ class ImagesContainer:
|
|
|
196
204
|
meta.set_channels_meta(channel_meta)
|
|
197
205
|
self._meta_handler.write_meta(meta)
|
|
198
206
|
|
|
199
|
-
def
|
|
207
|
+
def set_channel_percentiles(
|
|
200
208
|
self,
|
|
201
209
|
start_percentile: float = 0.1,
|
|
202
210
|
end_percentile: float = 99.9,
|
|
@@ -230,6 +238,21 @@ class ImagesContainer:
|
|
|
230
238
|
meta.set_channels_meta(new_meta)
|
|
231
239
|
self._meta_handler.write_meta(meta)
|
|
232
240
|
|
|
241
|
+
def set_axes_unit(
|
|
242
|
+
self,
|
|
243
|
+
space_unit: SpaceUnits = DefaultSpaceUnit,
|
|
244
|
+
time_unit: TimeUnits = DefaultTimeUnit,
|
|
245
|
+
) -> None:
|
|
246
|
+
"""Set the axes unit of the image.
|
|
247
|
+
|
|
248
|
+
Args:
|
|
249
|
+
space_unit (SpaceUnits): The space unit of the image.
|
|
250
|
+
time_unit (TimeUnits): The time unit of the image.
|
|
251
|
+
"""
|
|
252
|
+
meta = self.meta
|
|
253
|
+
meta = meta.to_units(space_unit=space_unit, time_unit=time_unit)
|
|
254
|
+
self._meta_handler.write_meta(meta)
|
|
255
|
+
|
|
233
256
|
def derive(
|
|
234
257
|
self,
|
|
235
258
|
store: StoreOrGroup,
|
|
@@ -238,6 +261,7 @@ class ImagesContainer:
|
|
|
238
261
|
labels: Collection[str] | None = None,
|
|
239
262
|
pixel_size: PixelSize | None = None,
|
|
240
263
|
axes_names: Collection[str] | None = None,
|
|
264
|
+
name: str | None = None,
|
|
241
265
|
chunks: Collection[int] | None = None,
|
|
242
266
|
dtype: str | None = None,
|
|
243
267
|
overwrite: bool = False,
|
|
@@ -252,6 +276,7 @@ class ImagesContainer:
|
|
|
252
276
|
labels (Collection[str] | None): The labels of the new image.
|
|
253
277
|
pixel_size (PixelSize | None): The pixel size of the new image.
|
|
254
278
|
axes_names (Collection[str] | None): The axes names of the new image.
|
|
279
|
+
name (str | None): The name of the new image.
|
|
255
280
|
chunks (Collection[int] | None): The chunk shape of the new image.
|
|
256
281
|
dtype (str | None): The data type of the new image.
|
|
257
282
|
overwrite (bool): Whether to overwrite an existing image.
|
|
@@ -267,6 +292,7 @@ class ImagesContainer:
|
|
|
267
292
|
labels=labels,
|
|
268
293
|
pixel_size=pixel_size,
|
|
269
294
|
axes_names=axes_names,
|
|
295
|
+
name=name,
|
|
270
296
|
chunks=chunks,
|
|
271
297
|
dtype=dtype,
|
|
272
298
|
overwrite=overwrite,
|
|
@@ -346,6 +372,7 @@ def derive_image_container(
|
|
|
346
372
|
labels: Collection[str] | None = None,
|
|
347
373
|
pixel_size: PixelSize | None = None,
|
|
348
374
|
axes_names: Collection[str] | None = None,
|
|
375
|
+
name: str | None = None,
|
|
349
376
|
chunks: Collection[int] | None = None,
|
|
350
377
|
dtype: str | None = None,
|
|
351
378
|
overwrite: bool = False,
|
|
@@ -360,6 +387,7 @@ def derive_image_container(
|
|
|
360
387
|
labels (Collection[str] | None): The labels of the new image.
|
|
361
388
|
pixel_size (PixelSize | None): The pixel size of the new image.
|
|
362
389
|
axes_names (Collection[str] | None): The axes names of the new image.
|
|
390
|
+
name (str | None): The name of the new image.
|
|
363
391
|
chunks (Collection[int] | None): The chunk shape of the new image.
|
|
364
392
|
dtype (str | None): The data type of the new image.
|
|
365
393
|
overwrite (bool): Whether to overwrite an existing image.
|
|
@@ -399,9 +427,12 @@ def derive_image_container(
|
|
|
399
427
|
f"Got {chunks} for shape {shape}."
|
|
400
428
|
)
|
|
401
429
|
|
|
430
|
+
if name is None:
|
|
431
|
+
name = ref_meta.name
|
|
432
|
+
|
|
402
433
|
if dtype is None:
|
|
403
434
|
dtype = ref_image.dtype
|
|
404
|
-
handler =
|
|
435
|
+
handler = create_empty_image_container(
|
|
405
436
|
store=store,
|
|
406
437
|
shape=shape,
|
|
407
438
|
pixelsize=pixel_size.x,
|
|
@@ -413,6 +444,7 @@ def derive_image_container(
|
|
|
413
444
|
time_unit=pixel_size.time_unit,
|
|
414
445
|
space_unit=pixel_size.space_unit,
|
|
415
446
|
axes_names=axes_names,
|
|
447
|
+
name=name,
|
|
416
448
|
chunks=chunks,
|
|
417
449
|
dtype=dtype,
|
|
418
450
|
overwrite=overwrite,
|
|
@@ -443,7 +475,7 @@ def derive_image_container(
|
|
|
443
475
|
)
|
|
444
476
|
_labels = labels
|
|
445
477
|
|
|
446
|
-
image_container.
|
|
478
|
+
image_container.set_channel_meta(
|
|
447
479
|
labels=_labels,
|
|
448
480
|
wavelength_id=wavelength_id,
|
|
449
481
|
percentiles=None,
|
ngio/images/label.py
CHANGED
|
@@ -5,7 +5,7 @@ from typing import Literal
|
|
|
5
5
|
|
|
6
6
|
from ngio.common import compute_masking_roi
|
|
7
7
|
from ngio.images.abstract_image import AbstractImage, consolidate_image
|
|
8
|
-
from ngio.images.create import
|
|
8
|
+
from ngio.images.create import create_empty_label_container
|
|
9
9
|
from ngio.images.image import Image
|
|
10
10
|
from ngio.ome_zarr_meta import (
|
|
11
11
|
LabelMetaHandler,
|
|
@@ -13,6 +13,12 @@ from ngio.ome_zarr_meta import (
|
|
|
13
13
|
PixelSize,
|
|
14
14
|
find_label_meta_handler,
|
|
15
15
|
)
|
|
16
|
+
from ngio.ome_zarr_meta.ngio_specs import (
|
|
17
|
+
DefaultSpaceUnit,
|
|
18
|
+
DefaultTimeUnit,
|
|
19
|
+
SpaceUnits,
|
|
20
|
+
TimeUnits,
|
|
21
|
+
)
|
|
16
22
|
from ngio.tables import MaskingRoiTable
|
|
17
23
|
from ngio.utils import (
|
|
18
24
|
NgioValidationError,
|
|
@@ -54,6 +60,21 @@ class Label(AbstractImage[LabelMetaHandler]):
|
|
|
54
60
|
"""Return the metadata."""
|
|
55
61
|
return self._meta_handler.meta
|
|
56
62
|
|
|
63
|
+
def set_axes_unit(
|
|
64
|
+
self,
|
|
65
|
+
space_unit: SpaceUnits = DefaultSpaceUnit,
|
|
66
|
+
time_unit: TimeUnits = DefaultTimeUnit,
|
|
67
|
+
) -> None:
|
|
68
|
+
"""Set the axes unit of the image.
|
|
69
|
+
|
|
70
|
+
Args:
|
|
71
|
+
space_unit (SpaceUnits): The space unit of the image.
|
|
72
|
+
time_unit (TimeUnits): The time unit of the image.
|
|
73
|
+
"""
|
|
74
|
+
meta = self.meta
|
|
75
|
+
meta = meta.to_units(space_unit=space_unit, time_unit=time_unit)
|
|
76
|
+
self._meta_handler.write_meta(meta)
|
|
77
|
+
|
|
57
78
|
def build_masking_roi_table(self) -> MaskingRoiTable:
|
|
58
79
|
"""Compute the masking ROI table."""
|
|
59
80
|
return build_masking_roi_table(self)
|
|
@@ -253,7 +274,7 @@ def _derive_label(
|
|
|
253
274
|
axes_names = list(axes_names)
|
|
254
275
|
axes_names = axes_names[:c_axis] + axes_names[c_axis + 1 :]
|
|
255
276
|
|
|
256
|
-
_ =
|
|
277
|
+
_ = create_empty_label_container(
|
|
257
278
|
store=store,
|
|
258
279
|
shape=shape,
|
|
259
280
|
pixelsize=ref_image.pixel_size.x,
|
|
@@ -5,7 +5,7 @@ from typing import Literal, overload
|
|
|
5
5
|
|
|
6
6
|
import numpy as np
|
|
7
7
|
|
|
8
|
-
from ngio.images.create import
|
|
8
|
+
from ngio.images.create import create_empty_image_container
|
|
9
9
|
from ngio.images.image import Image, ImagesContainer
|
|
10
10
|
from ngio.images.label import Label, LabelsContainer
|
|
11
11
|
from ngio.images.masked_image import MaskedImage, MaskedLabel
|
|
@@ -13,7 +13,14 @@ from ngio.ome_zarr_meta import (
|
|
|
13
13
|
NgioImageMeta,
|
|
14
14
|
PixelSize,
|
|
15
15
|
)
|
|
16
|
-
from ngio.ome_zarr_meta.ngio_specs import
|
|
16
|
+
from ngio.ome_zarr_meta.ngio_specs import (
|
|
17
|
+
DefaultNgffVersion,
|
|
18
|
+
DefaultSpaceUnit,
|
|
19
|
+
DefaultTimeUnit,
|
|
20
|
+
NgffVersions,
|
|
21
|
+
SpaceUnits,
|
|
22
|
+
TimeUnits,
|
|
23
|
+
)
|
|
17
24
|
from ngio.tables import (
|
|
18
25
|
FeatureTable,
|
|
19
26
|
GenericRoiTable,
|
|
@@ -152,7 +159,17 @@ class OmeZarrContainer:
|
|
|
152
159
|
"""Return True if the image is multichannel."""
|
|
153
160
|
return self.get_image().is_multi_channels
|
|
154
161
|
|
|
155
|
-
|
|
162
|
+
@property
|
|
163
|
+
def space_unit(self) -> str | None:
|
|
164
|
+
"""Return the space unit of the image."""
|
|
165
|
+
return self.image_meta.space_unit
|
|
166
|
+
|
|
167
|
+
@property
|
|
168
|
+
def time_unit(self) -> str | None:
|
|
169
|
+
"""Return the time unit of the image."""
|
|
170
|
+
return self.image_meta.time_unit
|
|
171
|
+
|
|
172
|
+
def set_channel_meta(
|
|
156
173
|
self,
|
|
157
174
|
labels: Collection[str] | int | None = None,
|
|
158
175
|
wavelength_id: Collection[str] | None = None,
|
|
@@ -162,7 +179,7 @@ class OmeZarrContainer:
|
|
|
162
179
|
**omero_kwargs: dict,
|
|
163
180
|
) -> None:
|
|
164
181
|
"""Create a ChannelsMeta object with the default unit."""
|
|
165
|
-
self._images_container.
|
|
182
|
+
self._images_container.set_channel_meta(
|
|
166
183
|
labels=labels,
|
|
167
184
|
wavelength_id=wavelength_id,
|
|
168
185
|
percentiles=percentiles,
|
|
@@ -171,16 +188,36 @@ class OmeZarrContainer:
|
|
|
171
188
|
**omero_kwargs,
|
|
172
189
|
)
|
|
173
190
|
|
|
174
|
-
def
|
|
191
|
+
def set_channel_percentiles(
|
|
175
192
|
self,
|
|
176
193
|
start_percentile: float = 0.1,
|
|
177
194
|
end_percentile: float = 99.9,
|
|
178
195
|
) -> None:
|
|
179
196
|
"""Update the percentiles of the image."""
|
|
180
|
-
self._images_container.
|
|
197
|
+
self._images_container.set_channel_percentiles(
|
|
181
198
|
start_percentile=start_percentile, end_percentile=end_percentile
|
|
182
199
|
)
|
|
183
200
|
|
|
201
|
+
def set_axes_units(
|
|
202
|
+
self,
|
|
203
|
+
space_unit: SpaceUnits = DefaultSpaceUnit,
|
|
204
|
+
time_unit: TimeUnits = DefaultTimeUnit,
|
|
205
|
+
set_labels: bool = True,
|
|
206
|
+
) -> None:
|
|
207
|
+
"""Set the units of the image.
|
|
208
|
+
|
|
209
|
+
Args:
|
|
210
|
+
space_unit (SpaceUnits): The unit of space.
|
|
211
|
+
time_unit (TimeUnits): The unit of time.
|
|
212
|
+
set_labels (bool): Whether to set the units for the labels as well.
|
|
213
|
+
"""
|
|
214
|
+
self._images_container.set_axes_unit(space_unit=space_unit, time_unit=time_unit)
|
|
215
|
+
if not set_labels:
|
|
216
|
+
return
|
|
217
|
+
for label_name in self.list_labels():
|
|
218
|
+
label = self.get_label(label_name)
|
|
219
|
+
label.set_axes_unit(space_unit=space_unit, time_unit=time_unit)
|
|
220
|
+
|
|
184
221
|
def get_image(
|
|
185
222
|
self,
|
|
186
223
|
path: str | None = None,
|
|
@@ -247,6 +284,7 @@ class OmeZarrContainer:
|
|
|
247
284
|
labels: Collection[str] | None = None,
|
|
248
285
|
pixel_size: PixelSize | None = None,
|
|
249
286
|
axes_names: Collection[str] | None = None,
|
|
287
|
+
name: str | None = None,
|
|
250
288
|
chunks: Collection[int] | None = None,
|
|
251
289
|
dtype: str | None = None,
|
|
252
290
|
copy_labels: bool = False,
|
|
@@ -265,6 +303,7 @@ class OmeZarrContainer:
|
|
|
265
303
|
axes_names (Collection[str] | None): The axes names of the new image.
|
|
266
304
|
chunks (Collection[int] | None): The chunk shape of the new image.
|
|
267
305
|
dtype (str | None): The data type of the new image.
|
|
306
|
+
name (str | None): The name of the new image.
|
|
268
307
|
copy_labels (bool): Whether to copy the labels from the reference image.
|
|
269
308
|
copy_tables (bool): Whether to copy the tables from the reference image.
|
|
270
309
|
overwrite (bool): Whether to overwrite an existing image.
|
|
@@ -280,6 +319,7 @@ class OmeZarrContainer:
|
|
|
280
319
|
labels=labels,
|
|
281
320
|
pixel_size=pixel_size,
|
|
282
321
|
axes_names=axes_names,
|
|
322
|
+
name=name,
|
|
283
323
|
chunks=chunks,
|
|
284
324
|
dtype=dtype,
|
|
285
325
|
overwrite=overwrite,
|
|
@@ -557,8 +597,8 @@ def create_empty_ome_zarr(
|
|
|
557
597
|
levels: int | list[str] = 5,
|
|
558
598
|
xy_scaling_factor: float = 2,
|
|
559
599
|
z_scaling_factor: float = 1.0,
|
|
560
|
-
space_unit: SpaceUnits
|
|
561
|
-
time_unit: TimeUnits
|
|
600
|
+
space_unit: SpaceUnits = DefaultSpaceUnit,
|
|
601
|
+
time_unit: TimeUnits = DefaultTimeUnit,
|
|
562
602
|
axes_names: Collection[str] | None = None,
|
|
563
603
|
name: str | None = None,
|
|
564
604
|
chunks: Collection[int] | None = None,
|
|
@@ -569,7 +609,7 @@ def create_empty_ome_zarr(
|
|
|
569
609
|
channel_colors: Collection[str] | None = None,
|
|
570
610
|
channel_active: Collection[bool] | None = None,
|
|
571
611
|
overwrite: bool = False,
|
|
572
|
-
version:
|
|
612
|
+
version: NgffVersions = DefaultNgffVersion,
|
|
573
613
|
) -> OmeZarrContainer:
|
|
574
614
|
"""Create an empty OME-Zarr image with the given shape and metadata.
|
|
575
615
|
|
|
@@ -586,10 +626,10 @@ def create_empty_ome_zarr(
|
|
|
586
626
|
dimensions. Defaults to 2.0.
|
|
587
627
|
z_scaling_factor (float, optional): The down-scaling factor in z dimension.
|
|
588
628
|
Defaults to 1.0.
|
|
589
|
-
space_unit (SpaceUnits
|
|
590
|
-
|
|
591
|
-
time_unit (TimeUnits
|
|
592
|
-
|
|
629
|
+
space_unit (SpaceUnits, optional): The unit of space. Defaults to
|
|
630
|
+
DefaultSpaceUnit.
|
|
631
|
+
time_unit (TimeUnits, optional): The unit of time. Defaults to
|
|
632
|
+
DefaultTimeUnit.
|
|
593
633
|
axes_names (Collection[str] | None, optional): The names of the axes.
|
|
594
634
|
If None the canonical names are used. Defaults to None.
|
|
595
635
|
name (str | None, optional): The name of the image. Defaults to None.
|
|
@@ -609,9 +649,9 @@ def create_empty_ome_zarr(
|
|
|
609
649
|
overwrite (bool, optional): Whether to overwrite an existing image.
|
|
610
650
|
Defaults to True.
|
|
611
651
|
version (NgffVersion, optional): The version of the OME-Zarr specification.
|
|
612
|
-
Defaults to
|
|
652
|
+
Defaults to DefaultNgffVersion.
|
|
613
653
|
"""
|
|
614
|
-
handler =
|
|
654
|
+
handler = create_empty_image_container(
|
|
615
655
|
store=store,
|
|
616
656
|
shape=shape,
|
|
617
657
|
pixelsize=xy_pixelsize,
|
|
@@ -631,7 +671,7 @@ def create_empty_ome_zarr(
|
|
|
631
671
|
)
|
|
632
672
|
|
|
633
673
|
ome_zarr = OmeZarrContainer(group_handler=handler)
|
|
634
|
-
ome_zarr.
|
|
674
|
+
ome_zarr.set_channel_meta(
|
|
635
675
|
labels=channel_labels,
|
|
636
676
|
wavelength_id=channel_wavelengths,
|
|
637
677
|
percentiles=percentiles,
|
|
@@ -650,8 +690,8 @@ def create_ome_zarr_from_array(
|
|
|
650
690
|
levels: int | list[str] = 5,
|
|
651
691
|
xy_scaling_factor: float = 2.0,
|
|
652
692
|
z_scaling_factor: float = 1.0,
|
|
653
|
-
space_unit: SpaceUnits
|
|
654
|
-
time_unit: TimeUnits
|
|
693
|
+
space_unit: SpaceUnits = DefaultSpaceUnit,
|
|
694
|
+
time_unit: TimeUnits = DefaultTimeUnit,
|
|
655
695
|
axes_names: Collection[str] | None = None,
|
|
656
696
|
channel_labels: list[str] | None = None,
|
|
657
697
|
channel_wavelengths: list[str] | None = None,
|
|
@@ -661,7 +701,7 @@ def create_ome_zarr_from_array(
|
|
|
661
701
|
name: str | None = None,
|
|
662
702
|
chunks: Collection[int] | None = None,
|
|
663
703
|
overwrite: bool = False,
|
|
664
|
-
version:
|
|
704
|
+
version: NgffVersions = DefaultNgffVersion,
|
|
665
705
|
) -> OmeZarrContainer:
|
|
666
706
|
"""Create an OME-Zarr image from a numpy array.
|
|
667
707
|
|
|
@@ -678,10 +718,10 @@ def create_ome_zarr_from_array(
|
|
|
678
718
|
dimensions. Defaults to 2.0.
|
|
679
719
|
z_scaling_factor (float, optional): The down-scaling factor in z dimension.
|
|
680
720
|
Defaults to 1.0.
|
|
681
|
-
space_unit (SpaceUnits
|
|
682
|
-
|
|
683
|
-
time_unit (TimeUnits
|
|
684
|
-
|
|
721
|
+
space_unit (SpaceUnits, optional): The unit of space. Defaults to
|
|
722
|
+
DefaultSpaceUnit.
|
|
723
|
+
time_unit (TimeUnits, optional): The unit of time. Defaults to
|
|
724
|
+
DefaultTimeUnit.
|
|
685
725
|
axes_names (Collection[str] | None, optional): The names of the axes.
|
|
686
726
|
If None the canonical names are used. Defaults to None.
|
|
687
727
|
name (str | None, optional): The name of the image. Defaults to None.
|
|
@@ -700,9 +740,9 @@ def create_ome_zarr_from_array(
|
|
|
700
740
|
overwrite (bool, optional): Whether to overwrite an existing image.
|
|
701
741
|
Defaults to True.
|
|
702
742
|
version (str, optional): The version of the OME-Zarr specification.
|
|
703
|
-
Defaults to
|
|
743
|
+
Defaults to DefaultNgffVersion.
|
|
704
744
|
"""
|
|
705
|
-
handler =
|
|
745
|
+
handler = create_empty_image_container(
|
|
706
746
|
store=store,
|
|
707
747
|
shape=array.shape,
|
|
708
748
|
pixelsize=xy_pixelsize,
|
|
@@ -725,7 +765,7 @@ def create_ome_zarr_from_array(
|
|
|
725
765
|
image = ome_zarr.get_image()
|
|
726
766
|
image.set_array(array)
|
|
727
767
|
image.consolidate()
|
|
728
|
-
ome_zarr.
|
|
768
|
+
ome_zarr.set_channel_meta(
|
|
729
769
|
labels=channel_labels,
|
|
730
770
|
wavelength_id=channel_wavelengths,
|
|
731
771
|
percentiles=percentiles,
|
ngio/ome_zarr_meta/__init__.py
CHANGED
|
@@ -16,12 +16,13 @@ from ngio.ome_zarr_meta.ngio_specs import (
|
|
|
16
16
|
AxesMapper,
|
|
17
17
|
Dataset,
|
|
18
18
|
ImageInWellPath,
|
|
19
|
-
|
|
19
|
+
NgffVersions,
|
|
20
20
|
NgioImageMeta,
|
|
21
21
|
NgioLabelMeta,
|
|
22
22
|
NgioPlateMeta,
|
|
23
23
|
NgioWellMeta,
|
|
24
24
|
PixelSize,
|
|
25
|
+
path_in_well_validation,
|
|
25
26
|
)
|
|
26
27
|
|
|
27
28
|
__all__ = [
|
|
@@ -32,8 +33,8 @@ __all__ = [
|
|
|
32
33
|
"ImageMetaHandler",
|
|
33
34
|
"LabelMetaHandler",
|
|
34
35
|
"LabelMetaHandler",
|
|
35
|
-
"
|
|
36
|
-
"
|
|
36
|
+
"NgffVersions",
|
|
37
|
+
"NgffVersions",
|
|
37
38
|
"NgioImageMeta",
|
|
38
39
|
"NgioLabelMeta",
|
|
39
40
|
"NgioPlateMeta",
|
|
@@ -47,4 +48,5 @@ __all__ = [
|
|
|
47
48
|
"get_label_meta_handler",
|
|
48
49
|
"get_plate_meta_handler",
|
|
49
50
|
"get_well_meta_handler",
|
|
51
|
+
"path_in_well_validation",
|
|
50
52
|
]
|
|
@@ -15,6 +15,8 @@ from ngio.ome_zarr_meta.ngio_specs._axes import (
|
|
|
15
15
|
AxesTranspose,
|
|
16
16
|
Axis,
|
|
17
17
|
AxisType,
|
|
18
|
+
DefaultSpaceUnit,
|
|
19
|
+
DefaultTimeUnit,
|
|
18
20
|
SpaceUnits,
|
|
19
21
|
TimeUnits,
|
|
20
22
|
canonical_axes_order,
|
|
@@ -32,10 +34,12 @@ from ngio.ome_zarr_meta.ngio_specs._ngio_hcs import (
|
|
|
32
34
|
ImageInWellPath,
|
|
33
35
|
NgioPlateMeta,
|
|
34
36
|
NgioWellMeta,
|
|
37
|
+
path_in_well_validation,
|
|
35
38
|
)
|
|
36
39
|
from ngio.ome_zarr_meta.ngio_specs._ngio_image import (
|
|
40
|
+
DefaultNgffVersion,
|
|
37
41
|
ImageLabelSource,
|
|
38
|
-
|
|
42
|
+
NgffVersions,
|
|
39
43
|
NgioImageLabelMeta,
|
|
40
44
|
NgioImageMeta,
|
|
41
45
|
NgioLabelMeta,
|
|
@@ -55,9 +59,12 @@ __all__ = [
|
|
|
55
59
|
"ChannelVisualisation",
|
|
56
60
|
"ChannelsMeta",
|
|
57
61
|
"Dataset",
|
|
62
|
+
"DefaultNgffVersion",
|
|
63
|
+
"DefaultSpaceUnit",
|
|
64
|
+
"DefaultTimeUnit",
|
|
58
65
|
"ImageInWellPath",
|
|
59
66
|
"ImageLabelSource",
|
|
60
|
-
"
|
|
67
|
+
"NgffVersions",
|
|
61
68
|
"NgioColors",
|
|
62
69
|
"NgioImageLabelMeta",
|
|
63
70
|
"NgioImageMeta",
|
|
@@ -70,4 +77,5 @@ __all__ = [
|
|
|
70
77
|
"canonical_axes_order",
|
|
71
78
|
"canonical_label_axes_order",
|
|
72
79
|
"default_channel_name",
|
|
80
|
+
"path_in_well_validation",
|
|
73
81
|
]
|