ngio 0.2.0a2__py3-none-any.whl → 0.5.0b4__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 +40 -12
- ngio/common/__init__.py +16 -32
- ngio/common/_dimensions.py +270 -48
- ngio/common/_masking_roi.py +153 -0
- ngio/common/_pyramid.py +267 -73
- ngio/common/_roi.py +290 -66
- ngio/common/_synt_images_utils.py +101 -0
- ngio/common/_zoom.py +54 -22
- ngio/experimental/__init__.py +5 -0
- ngio/experimental/iterators/__init__.py +15 -0
- ngio/experimental/iterators/_abstract_iterator.py +390 -0
- ngio/experimental/iterators/_feature.py +189 -0
- ngio/experimental/iterators/_image_processing.py +130 -0
- ngio/experimental/iterators/_mappers.py +48 -0
- ngio/experimental/iterators/_rois_utils.py +126 -0
- ngio/experimental/iterators/_segmentation.py +235 -0
- ngio/hcs/__init__.py +17 -58
- ngio/hcs/_plate.py +1354 -0
- ngio/images/__init__.py +30 -9
- ngio/images/_abstract_image.py +968 -0
- ngio/images/_create_synt_container.py +132 -0
- ngio/images/_create_utils.py +423 -0
- ngio/images/_image.py +926 -0
- ngio/images/_label.py +417 -0
- ngio/images/_masked_image.py +531 -0
- ngio/images/_ome_zarr_container.py +1235 -0
- ngio/images/_table_ops.py +471 -0
- ngio/io_pipes/__init__.py +75 -0
- ngio/io_pipes/_io_pipes.py +361 -0
- ngio/io_pipes/_io_pipes_masked.py +488 -0
- ngio/io_pipes/_io_pipes_roi.py +146 -0
- ngio/io_pipes/_io_pipes_types.py +56 -0
- ngio/io_pipes/_match_shape.py +377 -0
- ngio/io_pipes/_ops_axes.py +344 -0
- ngio/io_pipes/_ops_slices.py +411 -0
- ngio/io_pipes/_ops_slices_utils.py +199 -0
- ngio/io_pipes/_ops_transforms.py +104 -0
- ngio/io_pipes/_zoom_transform.py +180 -0
- ngio/ome_zarr_meta/__init__.py +39 -15
- ngio/ome_zarr_meta/_meta_handlers.py +490 -96
- ngio/ome_zarr_meta/ngio_specs/__init__.py +24 -10
- ngio/ome_zarr_meta/ngio_specs/_axes.py +268 -234
- ngio/ome_zarr_meta/ngio_specs/_channels.py +125 -41
- ngio/ome_zarr_meta/ngio_specs/_dataset.py +42 -87
- ngio/ome_zarr_meta/ngio_specs/_ngio_hcs.py +536 -2
- ngio/ome_zarr_meta/ngio_specs/_ngio_image.py +202 -198
- ngio/ome_zarr_meta/ngio_specs/_pixel_size.py +72 -34
- ngio/ome_zarr_meta/v04/__init__.py +21 -5
- ngio/ome_zarr_meta/v04/_custom_models.py +18 -0
- ngio/ome_zarr_meta/v04/{_v04_spec_utils.py → _v04_spec.py} +151 -90
- ngio/ome_zarr_meta/v05/__init__.py +27 -0
- ngio/ome_zarr_meta/v05/_custom_models.py +18 -0
- ngio/ome_zarr_meta/v05/_v05_spec.py +511 -0
- ngio/resources/20200812-CardiomyocyteDifferentiation14-Cycle1_B03/mask.png +0 -0
- ngio/resources/20200812-CardiomyocyteDifferentiation14-Cycle1_B03/nuclei.png +0 -0
- ngio/resources/20200812-CardiomyocyteDifferentiation14-Cycle1_B03/raw.jpg +0 -0
- ngio/resources/__init__.py +55 -0
- ngio/resources/resource_model.py +36 -0
- ngio/tables/__init__.py +20 -4
- ngio/tables/_abstract_table.py +270 -0
- ngio/tables/_tables_container.py +449 -0
- ngio/tables/backends/__init__.py +50 -1
- ngio/tables/backends/_abstract_backend.py +200 -31
- ngio/tables/backends/_anndata.py +139 -0
- ngio/tables/backends/_anndata_utils.py +10 -114
- ngio/tables/backends/_csv.py +19 -0
- ngio/tables/backends/_json.py +92 -0
- ngio/tables/backends/_parquet.py +19 -0
- ngio/tables/backends/_py_arrow_backends.py +222 -0
- ngio/tables/backends/_table_backends.py +162 -38
- ngio/tables/backends/_utils.py +608 -0
- ngio/tables/v1/__init__.py +19 -4
- ngio/tables/v1/_condition_table.py +71 -0
- ngio/tables/v1/_feature_table.py +79 -115
- ngio/tables/v1/_generic_table.py +21 -90
- ngio/tables/v1/_roi_table.py +486 -137
- ngio/transforms/__init__.py +5 -0
- ngio/transforms/_zoom.py +19 -0
- ngio/utils/__init__.py +16 -14
- ngio/utils/_cache.py +48 -0
- ngio/utils/_datasets.py +121 -13
- ngio/utils/_fractal_fsspec_store.py +42 -0
- ngio/utils/_zarr_utils.py +374 -218
- ngio-0.5.0b4.dist-info/METADATA +147 -0
- ngio-0.5.0b4.dist-info/RECORD +88 -0
- {ngio-0.2.0a2.dist-info → ngio-0.5.0b4.dist-info}/WHEEL +1 -1
- ngio/common/_array_pipe.py +0 -160
- ngio/common/_axes_transforms.py +0 -63
- ngio/common/_common_types.py +0 -5
- ngio/common/_slicer.py +0 -97
- ngio/images/abstract_image.py +0 -240
- ngio/images/create.py +0 -251
- ngio/images/image.py +0 -389
- ngio/images/label.py +0 -236
- ngio/images/omezarr_container.py +0 -535
- ngio/ome_zarr_meta/_generic_handlers.py +0 -320
- ngio/ome_zarr_meta/v04/_meta_handlers.py +0 -54
- ngio/tables/_validators.py +0 -192
- ngio/tables/backends/_anndata_v1.py +0 -75
- ngio/tables/backends/_json_v1.py +0 -56
- ngio/tables/tables_container.py +0 -300
- ngio/tables/v1/_masking_roi_table.py +0 -175
- ngio/utils/_logger.py +0 -29
- ngio-0.2.0a2.dist-info/METADATA +0 -95
- ngio-0.2.0a2.dist-info/RECORD +0 -53
- {ngio-0.2.0a2.dist-info → ngio-0.5.0b4.dist-info}/licenses/LICENSE +0 -0
ngio/images/abstract_image.py
DELETED
|
@@ -1,240 +0,0 @@
|
|
|
1
|
-
"""Generic class to handle Image-like data in a OME-NGFF file."""
|
|
2
|
-
|
|
3
|
-
from collections.abc import Collection, Iterable
|
|
4
|
-
from typing import Generic, Literal, TypeVar
|
|
5
|
-
|
|
6
|
-
import zarr
|
|
7
|
-
|
|
8
|
-
from ngio.common import (
|
|
9
|
-
ArrayLike,
|
|
10
|
-
Dimensions,
|
|
11
|
-
WorldCooROI,
|
|
12
|
-
consolidate_pyramid,
|
|
13
|
-
get_pipe,
|
|
14
|
-
set_pipe,
|
|
15
|
-
)
|
|
16
|
-
from ngio.ome_zarr_meta import (
|
|
17
|
-
Dataset,
|
|
18
|
-
ImageMetaHandler,
|
|
19
|
-
LabelMetaHandler,
|
|
20
|
-
PixelSize,
|
|
21
|
-
)
|
|
22
|
-
from ngio.utils import (
|
|
23
|
-
NgioFileExistsError,
|
|
24
|
-
ZarrGroupHandler,
|
|
25
|
-
)
|
|
26
|
-
|
|
27
|
-
_image_handler = TypeVar("_image_handler", ImageMetaHandler, LabelMetaHandler)
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
class AbstractImage(Generic[_image_handler]):
|
|
31
|
-
"""A class to handle a single image (or level) in an OME-Zarr image.
|
|
32
|
-
|
|
33
|
-
This class is meant to be subclassed by specific image types.
|
|
34
|
-
"""
|
|
35
|
-
|
|
36
|
-
def __init__(
|
|
37
|
-
self,
|
|
38
|
-
group_handler: ZarrGroupHandler,
|
|
39
|
-
path: str,
|
|
40
|
-
meta_handler: _image_handler,
|
|
41
|
-
) -> None:
|
|
42
|
-
"""Initialize the Image at a single level.
|
|
43
|
-
|
|
44
|
-
Args:
|
|
45
|
-
group_handler: The Zarr group handler.
|
|
46
|
-
path: The path to the image in the omezarr file.
|
|
47
|
-
meta_handler: The image metadata handler.
|
|
48
|
-
|
|
49
|
-
"""
|
|
50
|
-
self._path = path
|
|
51
|
-
self._group_handler = group_handler
|
|
52
|
-
self._meta_handler = meta_handler
|
|
53
|
-
|
|
54
|
-
self._dataset = self._meta_handler.meta.get_dataset(path=path)
|
|
55
|
-
self._pixel_size = self._dataset.pixel_size
|
|
56
|
-
|
|
57
|
-
try:
|
|
58
|
-
self._zarr_array = self._group_handler.get_array(self._dataset.path)
|
|
59
|
-
except NgioFileExistsError as e:
|
|
60
|
-
raise NgioFileExistsError(f"Could not find the dataset at {path}.") from e
|
|
61
|
-
|
|
62
|
-
self._dimensions = Dimensions(
|
|
63
|
-
shape=self._zarr_array.shape, axes_mapper=self._dataset.axes_mapper
|
|
64
|
-
)
|
|
65
|
-
|
|
66
|
-
self._axer_mapper = self._dataset.axes_mapper
|
|
67
|
-
|
|
68
|
-
def __repr__(self) -> str:
|
|
69
|
-
"""Return a string representation of the image."""
|
|
70
|
-
return f"Image(path={self.path}, {self.dimensions})"
|
|
71
|
-
|
|
72
|
-
@property
|
|
73
|
-
def meta_handler(self) -> _image_handler:
|
|
74
|
-
"""Return the metadata."""
|
|
75
|
-
return self._meta_handler
|
|
76
|
-
|
|
77
|
-
@property
|
|
78
|
-
def zarr_array(self) -> zarr.Array:
|
|
79
|
-
"""Return the Zarr array."""
|
|
80
|
-
return self._zarr_array
|
|
81
|
-
|
|
82
|
-
@property
|
|
83
|
-
def shape(self) -> tuple[int, ...]:
|
|
84
|
-
"""Return the shape of the image."""
|
|
85
|
-
return self.zarr_array.shape
|
|
86
|
-
|
|
87
|
-
@property
|
|
88
|
-
def dtype(self) -> str:
|
|
89
|
-
"""Return the dtype of the image."""
|
|
90
|
-
return str(self.zarr_array.dtype)
|
|
91
|
-
|
|
92
|
-
@property
|
|
93
|
-
def chunks(self) -> tuple[int, ...]:
|
|
94
|
-
"""Return the chunks of the image."""
|
|
95
|
-
return self.zarr_array.chunks
|
|
96
|
-
|
|
97
|
-
@property
|
|
98
|
-
def dimensions(self) -> Dimensions:
|
|
99
|
-
"""Return the dimensions of the image."""
|
|
100
|
-
return self._dimensions
|
|
101
|
-
|
|
102
|
-
@property
|
|
103
|
-
def pixel_size(self) -> PixelSize:
|
|
104
|
-
"""Return the pixel size of the image."""
|
|
105
|
-
return self._pixel_size
|
|
106
|
-
|
|
107
|
-
@property
|
|
108
|
-
def dataset(self) -> Dataset:
|
|
109
|
-
"""Return the dataset of the image."""
|
|
110
|
-
return self._dataset
|
|
111
|
-
|
|
112
|
-
@property
|
|
113
|
-
def path(self) -> str:
|
|
114
|
-
"""Return the path of the image."""
|
|
115
|
-
return self._dataset.path
|
|
116
|
-
|
|
117
|
-
def get_array(
|
|
118
|
-
self,
|
|
119
|
-
axes_order: Collection[str] | None = None,
|
|
120
|
-
mode: Literal["numpy", "dask", "delayed"] = "numpy",
|
|
121
|
-
**slice_kwargs: slice | int | Iterable[int],
|
|
122
|
-
) -> ArrayLike:
|
|
123
|
-
"""Get a slice of the image.
|
|
124
|
-
|
|
125
|
-
Args:
|
|
126
|
-
axes_order: The order of the axes to return the array.
|
|
127
|
-
mode: The mode to return the array.
|
|
128
|
-
**slice_kwargs: The slices to get the array.
|
|
129
|
-
|
|
130
|
-
Returns:
|
|
131
|
-
The array of the region of interest.
|
|
132
|
-
"""
|
|
133
|
-
return get_pipe(
|
|
134
|
-
array=self.zarr_array,
|
|
135
|
-
dimensions=self.dimensions,
|
|
136
|
-
axes_order=axes_order,
|
|
137
|
-
mode=mode,
|
|
138
|
-
**slice_kwargs,
|
|
139
|
-
)
|
|
140
|
-
|
|
141
|
-
def get_roi(
|
|
142
|
-
self,
|
|
143
|
-
roi: WorldCooROI,
|
|
144
|
-
axes_order: Collection[str] | None = None,
|
|
145
|
-
mode: Literal["numpy", "dask", "delayed"] = "numpy",
|
|
146
|
-
**slice_kwargs: slice | int | Iterable[int],
|
|
147
|
-
) -> ArrayLike:
|
|
148
|
-
"""Get a slice of the image.
|
|
149
|
-
|
|
150
|
-
Args:
|
|
151
|
-
roi: The region of interest to get the array.
|
|
152
|
-
axes_order: The order of the axes to return the array.
|
|
153
|
-
mode: The mode to return the array.
|
|
154
|
-
**slice_kwargs: The slices to get the array.
|
|
155
|
-
|
|
156
|
-
Returns:
|
|
157
|
-
The array of the region of interest.
|
|
158
|
-
"""
|
|
159
|
-
raster_roi = roi.to_raster_coo(
|
|
160
|
-
pixel_size=self.pixel_size, dimensions=self.dimensions
|
|
161
|
-
).to_slices()
|
|
162
|
-
|
|
163
|
-
for key in slice_kwargs.keys():
|
|
164
|
-
if key in raster_roi:
|
|
165
|
-
raise ValueError(
|
|
166
|
-
f"Key {key} is already in the slice_kwargs. "
|
|
167
|
-
"Ambiguous which one to use: "
|
|
168
|
-
f"{key}={slice_kwargs[key]} or roi_{key}={raster_roi[key]}"
|
|
169
|
-
)
|
|
170
|
-
return self.get_array(
|
|
171
|
-
axes_order=axes_order, mode=mode, **raster_roi, **slice_kwargs
|
|
172
|
-
)
|
|
173
|
-
|
|
174
|
-
def set_array(
|
|
175
|
-
self,
|
|
176
|
-
patch: ArrayLike,
|
|
177
|
-
axes_order: Collection[str] | None = None,
|
|
178
|
-
**slice_kwargs: slice | int | Iterable[int],
|
|
179
|
-
) -> None:
|
|
180
|
-
"""Set a slice of the image.
|
|
181
|
-
|
|
182
|
-
Args:
|
|
183
|
-
patch: The patch to set.
|
|
184
|
-
axes_order: The order of the axes to set the patch.
|
|
185
|
-
**slice_kwargs: The slices to set the patch.
|
|
186
|
-
|
|
187
|
-
"""
|
|
188
|
-
set_pipe(
|
|
189
|
-
array=self.zarr_array,
|
|
190
|
-
patch=patch,
|
|
191
|
-
dimensions=self.dimensions,
|
|
192
|
-
axes_order=axes_order,
|
|
193
|
-
**slice_kwargs,
|
|
194
|
-
)
|
|
195
|
-
|
|
196
|
-
def set_roi(
|
|
197
|
-
self,
|
|
198
|
-
roi: WorldCooROI,
|
|
199
|
-
patch: ArrayLike,
|
|
200
|
-
axes_order: Collection[str] | None = None,
|
|
201
|
-
**slice_kwargs: slice | int | Iterable[int],
|
|
202
|
-
) -> None:
|
|
203
|
-
"""Set a slice of the image.
|
|
204
|
-
|
|
205
|
-
Args:
|
|
206
|
-
roi: The region of interest to set the patch.
|
|
207
|
-
patch: The patch to set.
|
|
208
|
-
axes_order: The order of the axes to set the patch.
|
|
209
|
-
**slice_kwargs: The slices to set the patch.
|
|
210
|
-
|
|
211
|
-
"""
|
|
212
|
-
raster_roi = roi.to_raster_coo(
|
|
213
|
-
pixel_size=self.pixel_size, dimensions=self.dimensions
|
|
214
|
-
).to_slices()
|
|
215
|
-
|
|
216
|
-
for key in slice_kwargs.keys():
|
|
217
|
-
if key in raster_roi:
|
|
218
|
-
raise ValueError(
|
|
219
|
-
f"Key {key} is already in the slice_kwargs. "
|
|
220
|
-
"Ambiguous which one to use: "
|
|
221
|
-
f"{key}={slice_kwargs[key]} or roi_{key}={raster_roi[key]}"
|
|
222
|
-
)
|
|
223
|
-
self.set_array(patch=patch, axes_order=axes_order, **raster_roi, **slice_kwargs)
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
def consolidate_image(
|
|
227
|
-
image: AbstractImage,
|
|
228
|
-
order: Literal[0, 1, 2] = 1,
|
|
229
|
-
mode: Literal["dask", "numpy", "coarsen"] = "dask",
|
|
230
|
-
) -> None:
|
|
231
|
-
"""Consolidate the image on disk."""
|
|
232
|
-
target_paths = image._meta_handler.meta.paths
|
|
233
|
-
targets = [
|
|
234
|
-
image._group_handler.get_array(path)
|
|
235
|
-
for path in target_paths
|
|
236
|
-
if path != image.path
|
|
237
|
-
]
|
|
238
|
-
consolidate_pyramid(
|
|
239
|
-
source=image.zarr_array, targets=targets, order=order, mode=mode
|
|
240
|
-
)
|
ngio/images/create.py
DELETED
|
@@ -1,251 +0,0 @@
|
|
|
1
|
-
"""Utility functions for working with OME-Zarr images."""
|
|
2
|
-
|
|
3
|
-
from collections.abc import Collection
|
|
4
|
-
from typing import TypeVar
|
|
5
|
-
|
|
6
|
-
from ngio.common._pyramid import init_empty_pyramid
|
|
7
|
-
from ngio.ome_zarr_meta import (
|
|
8
|
-
ImplementedImageMetaHandlers,
|
|
9
|
-
ImplementedLabelMetaHandlers,
|
|
10
|
-
NgioImageMeta,
|
|
11
|
-
NgioLabelMeta,
|
|
12
|
-
PixelSize,
|
|
13
|
-
)
|
|
14
|
-
from ngio.ome_zarr_meta.ngio_specs import (
|
|
15
|
-
SpaceUnits,
|
|
16
|
-
TimeUnits,
|
|
17
|
-
canonical_axes_order,
|
|
18
|
-
canonical_label_axes_order,
|
|
19
|
-
)
|
|
20
|
-
from ngio.utils import StoreOrGroup, ZarrGroupHandler
|
|
21
|
-
|
|
22
|
-
_image_or_label_meta = TypeVar("_image_or_label_meta", NgioImageMeta, NgioLabelMeta)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
def _init_generic_meta(
|
|
26
|
-
meta_type: type[_image_or_label_meta],
|
|
27
|
-
xy_pixelsize: float,
|
|
28
|
-
axes_names: Collection[str],
|
|
29
|
-
z_spacing: float = 1.0,
|
|
30
|
-
time_spacing: float = 1.0,
|
|
31
|
-
levels: int | list[str] = 5,
|
|
32
|
-
xy_scaling_factor: float = 2.0,
|
|
33
|
-
z_scaling_factor: float = 1.0,
|
|
34
|
-
space_unit: SpaceUnits | str | None = None,
|
|
35
|
-
time_unit: TimeUnits | str | None = None,
|
|
36
|
-
name: str | None = None,
|
|
37
|
-
version: str = "0.4",
|
|
38
|
-
) -> tuple[_image_or_label_meta, list[float]]:
|
|
39
|
-
"""Initialize the metadata for an image or label."""
|
|
40
|
-
scaling_factors = []
|
|
41
|
-
for ax in axes_names:
|
|
42
|
-
if ax == "z":
|
|
43
|
-
scaling_factors.append(z_scaling_factor)
|
|
44
|
-
elif ax in ["x", "y"]:
|
|
45
|
-
scaling_factors.append(xy_scaling_factor)
|
|
46
|
-
else:
|
|
47
|
-
scaling_factors.append(1.0)
|
|
48
|
-
|
|
49
|
-
if space_unit is None:
|
|
50
|
-
space_unit = SpaceUnits.micrometer
|
|
51
|
-
elif isinstance(space_unit, str):
|
|
52
|
-
space_unit = SpaceUnits(space_unit)
|
|
53
|
-
elif not isinstance(space_unit, SpaceUnits):
|
|
54
|
-
raise ValueError(f"space_unit can not be {type(space_unit)}.")
|
|
55
|
-
|
|
56
|
-
if time_unit is None:
|
|
57
|
-
time_unit = TimeUnits.seconds
|
|
58
|
-
elif isinstance(time_unit, str):
|
|
59
|
-
time_unit = TimeUnits(time_unit)
|
|
60
|
-
elif not isinstance(time_unit, TimeUnits):
|
|
61
|
-
raise ValueError(f"time_units can not be {type(time_unit)}.")
|
|
62
|
-
|
|
63
|
-
pixel_sizes = PixelSize(
|
|
64
|
-
x=xy_pixelsize,
|
|
65
|
-
y=xy_pixelsize,
|
|
66
|
-
z=z_spacing,
|
|
67
|
-
t=time_spacing,
|
|
68
|
-
space_unit=space_unit,
|
|
69
|
-
time_unit=time_unit,
|
|
70
|
-
)
|
|
71
|
-
|
|
72
|
-
meta = meta_type.default_init(
|
|
73
|
-
name=name,
|
|
74
|
-
levels=levels,
|
|
75
|
-
axes_names=axes_names,
|
|
76
|
-
pixel_size=pixel_sizes,
|
|
77
|
-
scaling_factors=scaling_factors,
|
|
78
|
-
version=version,
|
|
79
|
-
)
|
|
80
|
-
return meta, scaling_factors
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
def _create_empty_label(
|
|
84
|
-
store: StoreOrGroup,
|
|
85
|
-
shape: Collection[int],
|
|
86
|
-
xy_pixelsize: float,
|
|
87
|
-
z_spacing: float = 1.0,
|
|
88
|
-
time_spacing: float = 1.0,
|
|
89
|
-
levels: int | list[str] = 5,
|
|
90
|
-
xy_scaling_factor: float = 2.0,
|
|
91
|
-
z_scaling_factor: float = 1.0,
|
|
92
|
-
space_unit: SpaceUnits | str | None = None,
|
|
93
|
-
time_unit: TimeUnits | str | None = None,
|
|
94
|
-
axes_names: Collection[str] | None = None,
|
|
95
|
-
name: str | None = None,
|
|
96
|
-
chunks: Collection[int] | None = None,
|
|
97
|
-
dtype: str = "uint16",
|
|
98
|
-
overwrite: bool = False,
|
|
99
|
-
version: str = "0.4",
|
|
100
|
-
) -> ZarrGroupHandler:
|
|
101
|
-
"""Create an empty label with the given shape and metadata.
|
|
102
|
-
|
|
103
|
-
Args:
|
|
104
|
-
store (StoreOrGroup): The Zarr store or group to create the image in.
|
|
105
|
-
shape (Collection[int]): The shape of the image.
|
|
106
|
-
xy_pixelsize (float): The pixel size in x and y dimensions.
|
|
107
|
-
z_spacing (float, optional): The spacing between z slices. Defaults to 1.0.
|
|
108
|
-
time_spacing (float, optional): The spacing between time points.
|
|
109
|
-
Defaults to 1.0.
|
|
110
|
-
levels (int | list[str], optional): The number of levels in the pyramid or a
|
|
111
|
-
list of level names. Defaults to 5.
|
|
112
|
-
xy_scaling_factor (float, optional): The down-scaling factor in x and y
|
|
113
|
-
dimensions. Defaults to 2.0.
|
|
114
|
-
z_scaling_factor (float, optional): The down-scaling factor in z dimension.
|
|
115
|
-
Defaults to 1.0.
|
|
116
|
-
space_unit (SpaceUnits | str | None, optional): The unit of space. Defaults to
|
|
117
|
-
None.
|
|
118
|
-
time_unit (TimeUnits | str | None, optional): The unit of time. Defaults to
|
|
119
|
-
None.
|
|
120
|
-
axes_names (Collection[str] | None, optional): The names of the axes.
|
|
121
|
-
If None the canonical names are used. Defaults to None.
|
|
122
|
-
name (str | None, optional): The name of the image. Defaults to None.
|
|
123
|
-
chunks (Collection[int] | None, optional): The chunk shape. If None the shape
|
|
124
|
-
is used. Defaults to None.
|
|
125
|
-
dtype (str, optional): The data type of the image. Defaults to "uint16".
|
|
126
|
-
overwrite (bool, optional): Whether to overwrite an existing image.
|
|
127
|
-
Defaults to True.
|
|
128
|
-
version (str, optional): The version of the OME-Zarr specification.
|
|
129
|
-
Defaults to "0.4".
|
|
130
|
-
|
|
131
|
-
"""
|
|
132
|
-
if axes_names is None:
|
|
133
|
-
axes_names = canonical_label_axes_order()[-len(shape) :]
|
|
134
|
-
|
|
135
|
-
meta, scaling_factors = _init_generic_meta(
|
|
136
|
-
meta_type=NgioLabelMeta,
|
|
137
|
-
xy_pixelsize=xy_pixelsize,
|
|
138
|
-
z_spacing=z_spacing,
|
|
139
|
-
time_spacing=time_spacing,
|
|
140
|
-
levels=levels,
|
|
141
|
-
xy_scaling_factor=xy_scaling_factor,
|
|
142
|
-
z_scaling_factor=z_scaling_factor,
|
|
143
|
-
space_unit=space_unit,
|
|
144
|
-
time_unit=time_unit,
|
|
145
|
-
axes_names=axes_names,
|
|
146
|
-
name=name,
|
|
147
|
-
version=version,
|
|
148
|
-
)
|
|
149
|
-
|
|
150
|
-
mode = "w" if overwrite else "w-"
|
|
151
|
-
group_handler = ZarrGroupHandler(store=store, mode=mode, cache=False)
|
|
152
|
-
image_handler = ImplementedLabelMetaHandlers().get_handler(
|
|
153
|
-
version=version, group_handler=group_handler
|
|
154
|
-
)
|
|
155
|
-
image_handler.write_meta(meta)
|
|
156
|
-
|
|
157
|
-
init_empty_pyramid(
|
|
158
|
-
store=store,
|
|
159
|
-
paths=meta.paths,
|
|
160
|
-
scaling_factors=scaling_factors,
|
|
161
|
-
ref_shape=shape,
|
|
162
|
-
chunks=chunks,
|
|
163
|
-
dtype=dtype,
|
|
164
|
-
mode="a",
|
|
165
|
-
)
|
|
166
|
-
return group_handler
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
def _create_empty_image(
|
|
170
|
-
store: StoreOrGroup,
|
|
171
|
-
shape: Collection[int],
|
|
172
|
-
xy_pixelsize: float,
|
|
173
|
-
z_spacing: float = 1.0,
|
|
174
|
-
time_spacing: float = 1.0,
|
|
175
|
-
levels: int | list[str] = 5,
|
|
176
|
-
xy_scaling_factor: float = 2,
|
|
177
|
-
z_scaling_factor: float = 1.0,
|
|
178
|
-
space_unit: SpaceUnits | str | None = None,
|
|
179
|
-
time_unit: TimeUnits | str | None = None,
|
|
180
|
-
axes_names: Collection[str] | None = None,
|
|
181
|
-
name: str | None = None,
|
|
182
|
-
chunks: Collection[int] | None = None,
|
|
183
|
-
dtype: str = "uint16",
|
|
184
|
-
overwrite: bool = False,
|
|
185
|
-
version: str = "0.4",
|
|
186
|
-
) -> ZarrGroupHandler:
|
|
187
|
-
"""Create an empty OME-Zarr image with the given shape and metadata.
|
|
188
|
-
|
|
189
|
-
Args:
|
|
190
|
-
store (StoreOrGroup): The Zarr store or group to create the image in.
|
|
191
|
-
shape (Collection[int]): The shape of the image.
|
|
192
|
-
xy_pixelsize (float): The pixel size in x and y dimensions.
|
|
193
|
-
z_spacing (float, optional): The spacing between z slices. Defaults to 1.0.
|
|
194
|
-
time_spacing (float, optional): The spacing between time points.
|
|
195
|
-
Defaults to 1.0.
|
|
196
|
-
levels (int | list[str], optional): The number of levels in the pyramid or a
|
|
197
|
-
list of level names. Defaults to 5.
|
|
198
|
-
xy_scaling_factor (float, optional): The down-scaling factor in x and y
|
|
199
|
-
dimensions. Defaults to 2.0.
|
|
200
|
-
z_scaling_factor (float, optional): The down-scaling factor in z dimension.
|
|
201
|
-
Defaults to 1.0.
|
|
202
|
-
space_unit (SpaceUnits | str | None, optional): The unit of space. Defaults to
|
|
203
|
-
None.
|
|
204
|
-
time_unit (TimeUnits | str | None, optional): The unit of time. Defaults to
|
|
205
|
-
None.
|
|
206
|
-
axes_names (Collection[str] | None, optional): The names of the axes.
|
|
207
|
-
If None the canonical names are used. Defaults to None.
|
|
208
|
-
name (str | None, optional): The name of the image. Defaults to None.
|
|
209
|
-
chunks (Collection[int] | None, optional): The chunk shape. If None the shape
|
|
210
|
-
is used. Defaults to None.
|
|
211
|
-
dtype (str, optional): The data type of the image. Defaults to "uint16".
|
|
212
|
-
overwrite (bool, optional): Whether to overwrite an existing image.
|
|
213
|
-
Defaults to True.
|
|
214
|
-
version (str, optional): The version of the OME-Zarr specification.
|
|
215
|
-
Defaults to "0.4".
|
|
216
|
-
|
|
217
|
-
"""
|
|
218
|
-
if axes_names is None:
|
|
219
|
-
axes_names = canonical_axes_order()[-len(shape) :]
|
|
220
|
-
|
|
221
|
-
meta, scaling_factors = _init_generic_meta(
|
|
222
|
-
meta_type=NgioImageMeta,
|
|
223
|
-
xy_pixelsize=xy_pixelsize,
|
|
224
|
-
z_spacing=z_spacing,
|
|
225
|
-
time_spacing=time_spacing,
|
|
226
|
-
levels=levels,
|
|
227
|
-
xy_scaling_factor=xy_scaling_factor,
|
|
228
|
-
z_scaling_factor=z_scaling_factor,
|
|
229
|
-
space_unit=space_unit,
|
|
230
|
-
time_unit=time_unit,
|
|
231
|
-
axes_names=axes_names,
|
|
232
|
-
name=name,
|
|
233
|
-
version=version,
|
|
234
|
-
)
|
|
235
|
-
mode = "w" if overwrite else "w-"
|
|
236
|
-
group_handler = ZarrGroupHandler(store=store, mode=mode, cache=False)
|
|
237
|
-
image_handler = ImplementedImageMetaHandlers().get_handler(
|
|
238
|
-
version=version, group_handler=group_handler
|
|
239
|
-
)
|
|
240
|
-
image_handler.write_meta(meta)
|
|
241
|
-
|
|
242
|
-
init_empty_pyramid(
|
|
243
|
-
store=store,
|
|
244
|
-
paths=meta.paths,
|
|
245
|
-
scaling_factors=scaling_factors,
|
|
246
|
-
ref_shape=shape,
|
|
247
|
-
chunks=chunks,
|
|
248
|
-
dtype=dtype,
|
|
249
|
-
mode="a",
|
|
250
|
-
)
|
|
251
|
-
return group_handler
|