ngio 0.5.0b6__py3-none-any.whl → 0.5.0b7__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/common/_pyramid.py +129 -30
- ngio/images/_abstract_image.py +117 -48
- ngio/images/_create_synt_container.py +4 -0
- ngio/images/_create_utils.py +9 -13
- ngio/images/_image.py +8 -0
- ngio/images/_label.py +8 -0
- ngio/images/_ome_zarr_container.py +16 -0
- ngio/ome_zarr_meta/v04/_v04_spec.py +3 -1
- ngio/ome_zarr_meta/v05/_v05_spec.py +3 -1
- {ngio-0.5.0b6.dist-info → ngio-0.5.0b7.dist-info}/METADATA +1 -1
- {ngio-0.5.0b6.dist-info → ngio-0.5.0b7.dist-info}/RECORD +13 -13
- {ngio-0.5.0b6.dist-info → ngio-0.5.0b7.dist-info}/WHEEL +0 -0
- {ngio-0.5.0b6.dist-info → ngio-0.5.0b7.dist-info}/licenses/LICENSE +0 -0
ngio/common/_pyramid.py
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import itertools
|
|
2
|
+
import math
|
|
1
3
|
from collections.abc import Callable, Mapping, Sequence
|
|
2
4
|
from typing import Any, Literal
|
|
3
5
|
|
|
@@ -195,7 +197,7 @@ ChunksLike = tuple[int, ...] | Literal["auto"]
|
|
|
195
197
|
ShardsLike = tuple[int, ...] | Literal["auto"]
|
|
196
198
|
|
|
197
199
|
|
|
198
|
-
def
|
|
200
|
+
def compute_shapes_from_scaling_factors(
|
|
199
201
|
base_shape: tuple[int, ...],
|
|
200
202
|
scaling_factors: tuple[float, ...],
|
|
201
203
|
num_levels: int,
|
|
@@ -215,7 +217,7 @@ def shapes_from_scaling_factors(
|
|
|
215
217
|
for _ in range(num_levels):
|
|
216
218
|
shapes.append(current_shape)
|
|
217
219
|
current_shape = tuple(
|
|
218
|
-
max(1,
|
|
220
|
+
max(1, math.floor(s / f))
|
|
219
221
|
for s, f in zip(current_shape, scaling_factors, strict=True)
|
|
220
222
|
)
|
|
221
223
|
return shapes
|
|
@@ -233,6 +235,7 @@ class PyramidLevel(BaseModel):
|
|
|
233
235
|
path: str
|
|
234
236
|
shape: tuple[int, ...]
|
|
235
237
|
scale: tuple[float, ...]
|
|
238
|
+
translation: tuple[float, ...]
|
|
236
239
|
chunks: ChunksLike = "auto"
|
|
237
240
|
shards: ShardsLike | None = None
|
|
238
241
|
|
|
@@ -247,6 +250,12 @@ class PyramidLevel(BaseModel):
|
|
|
247
250
|
if any(isinstance(s, float) and s < 0 for s in self.scale):
|
|
248
251
|
raise NgioValueError("Scale values must be positive.")
|
|
249
252
|
|
|
253
|
+
if len(self.translation) != len(self.shape):
|
|
254
|
+
raise NgioValueError(
|
|
255
|
+
"Translation must have the same length as shape "
|
|
256
|
+
f"({len(self.shape)}), got {len(self.translation)}"
|
|
257
|
+
)
|
|
258
|
+
|
|
250
259
|
if isinstance(self.chunks, tuple):
|
|
251
260
|
if len(self.chunks) != len(self.shape):
|
|
252
261
|
raise NgioValueError(
|
|
@@ -271,6 +280,63 @@ class PyramidLevel(BaseModel):
|
|
|
271
280
|
return self
|
|
272
281
|
|
|
273
282
|
|
|
283
|
+
def compute_scales_from_shapes(
|
|
284
|
+
shapes: Sequence[tuple[int, ...]],
|
|
285
|
+
base_scale: tuple[float, ...],
|
|
286
|
+
) -> list[tuple[float, ...]]:
|
|
287
|
+
scales = [base_scale]
|
|
288
|
+
scale_ = base_scale
|
|
289
|
+
for current_shape, next_shape in itertools.pairwise(shapes):
|
|
290
|
+
# This only works for downsampling pyramids
|
|
291
|
+
# The _check_order function (called before) ensures that the
|
|
292
|
+
# shapes are decreasing
|
|
293
|
+
_scaling_factor = tuple(
|
|
294
|
+
s1 / s2
|
|
295
|
+
for s1, s2 in zip(
|
|
296
|
+
current_shape,
|
|
297
|
+
next_shape,
|
|
298
|
+
strict=True,
|
|
299
|
+
)
|
|
300
|
+
)
|
|
301
|
+
scale_ = tuple(s * f for s, f in zip(scale_, _scaling_factor, strict=True))
|
|
302
|
+
scales.append(scale_)
|
|
303
|
+
return scales
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
def _compute_translations_from_shapes(
|
|
307
|
+
scales: Sequence[tuple[float, ...]],
|
|
308
|
+
base_translation: Sequence[float] | None,
|
|
309
|
+
) -> list[tuple[float, ...]]:
|
|
310
|
+
translations = []
|
|
311
|
+
if base_translation is None:
|
|
312
|
+
n_dim = len(scales[0])
|
|
313
|
+
base_translation = tuple(0.0 for _ in range(n_dim))
|
|
314
|
+
else:
|
|
315
|
+
base_translation = tuple(base_translation)
|
|
316
|
+
|
|
317
|
+
translation_ = base_translation
|
|
318
|
+
for _ in scales:
|
|
319
|
+
# TBD: How to update translation
|
|
320
|
+
# For now, we keep it constant but we should probably change it
|
|
321
|
+
# to reflect the shift introduced by downsampling
|
|
322
|
+
# translation_ = translation_ + _scaling_factor
|
|
323
|
+
translations.append(translation_)
|
|
324
|
+
return translations
|
|
325
|
+
|
|
326
|
+
|
|
327
|
+
def _compute_scales_from_factors(
|
|
328
|
+
base_scale: tuple[float, ...], scaling_factors: tuple[float, ...], num_levels: int
|
|
329
|
+
) -> list[tuple[float, ...]]:
|
|
330
|
+
precision_scales = []
|
|
331
|
+
current_scale = base_scale
|
|
332
|
+
for _ in range(num_levels):
|
|
333
|
+
precision_scales.append(current_scale)
|
|
334
|
+
current_scale = tuple(
|
|
335
|
+
s * f for s, f in zip(current_scale, scaling_factors, strict=True)
|
|
336
|
+
)
|
|
337
|
+
return precision_scales
|
|
338
|
+
|
|
339
|
+
|
|
274
340
|
class ImagePyramidBuilder(BaseModel):
|
|
275
341
|
levels: list[PyramidLevel]
|
|
276
342
|
axes: tuple[str, ...]
|
|
@@ -290,6 +356,7 @@ class ImagePyramidBuilder(BaseModel):
|
|
|
290
356
|
base_shape: tuple[int, ...],
|
|
291
357
|
base_scale: tuple[float, ...],
|
|
292
358
|
axes: tuple[str, ...],
|
|
359
|
+
base_translation: Sequence[float] | None = None,
|
|
293
360
|
chunks: ChunksLike = "auto",
|
|
294
361
|
shards: ShardsLike | None = None,
|
|
295
362
|
data_type: str = "uint16",
|
|
@@ -297,16 +364,39 @@ class ImagePyramidBuilder(BaseModel):
|
|
|
297
364
|
compressors: Any = "auto",
|
|
298
365
|
zarr_format: Literal[2, 3] = 2,
|
|
299
366
|
other_array_kwargs: Mapping[str, Any] | None = None,
|
|
367
|
+
precision_scale: bool = True,
|
|
300
368
|
) -> "ImagePyramidBuilder":
|
|
301
|
-
shapes
|
|
369
|
+
# Since shapes needs to be rounded to integers, we compute them here
|
|
370
|
+
# and then pass them to from_shapes
|
|
371
|
+
# This ensures that the shapes and scaling factors are consistent
|
|
372
|
+
# and avoids accumulation of rounding errors
|
|
373
|
+
shapes = compute_shapes_from_scaling_factors(
|
|
302
374
|
base_shape=base_shape,
|
|
303
375
|
scaling_factors=scaling_factors,
|
|
304
376
|
num_levels=len(levels_paths),
|
|
305
377
|
)
|
|
378
|
+
|
|
379
|
+
if precision_scale:
|
|
380
|
+
# Compute precise scales from shapes
|
|
381
|
+
# Since shapes are rounded to integers, the scaling factors
|
|
382
|
+
# may not be exactly the same as the input scaling factors
|
|
383
|
+
# Thus, we compute the scales from the shapes to ensure consistency
|
|
384
|
+
base_scale_ = compute_scales_from_shapes(
|
|
385
|
+
shapes=shapes,
|
|
386
|
+
base_scale=base_scale,
|
|
387
|
+
)
|
|
388
|
+
else:
|
|
389
|
+
base_scale_ = _compute_scales_from_factors(
|
|
390
|
+
base_scale=base_scale,
|
|
391
|
+
scaling_factors=scaling_factors,
|
|
392
|
+
num_levels=len(levels_paths),
|
|
393
|
+
)
|
|
394
|
+
|
|
306
395
|
return cls.from_shapes(
|
|
307
396
|
shapes=shapes,
|
|
308
|
-
base_scale=
|
|
397
|
+
base_scale=base_scale_,
|
|
309
398
|
axes=axes,
|
|
399
|
+
base_translation=base_translation,
|
|
310
400
|
levels_paths=levels_paths,
|
|
311
401
|
chunks=chunks,
|
|
312
402
|
shards=shards,
|
|
@@ -321,8 +411,9 @@ class ImagePyramidBuilder(BaseModel):
|
|
|
321
411
|
def from_shapes(
|
|
322
412
|
cls,
|
|
323
413
|
shapes: Sequence[tuple[int, ...]],
|
|
324
|
-
base_scale: tuple[float, ...],
|
|
414
|
+
base_scale: tuple[float, ...] | list[tuple[float, ...]],
|
|
325
415
|
axes: tuple[str, ...],
|
|
416
|
+
base_translation: Sequence[float] | None = None,
|
|
326
417
|
levels_paths: Sequence[str] | None = None,
|
|
327
418
|
chunks: ChunksLike = "auto",
|
|
328
419
|
shards: ShardsLike | None = None,
|
|
@@ -335,34 +426,42 @@ class ImagePyramidBuilder(BaseModel):
|
|
|
335
426
|
levels = []
|
|
336
427
|
if levels_paths is None:
|
|
337
428
|
levels_paths = tuple(str(i) for i in range(len(shapes)))
|
|
429
|
+
|
|
338
430
|
_check_order(shapes)
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
431
|
+
if isinstance(base_scale, tuple) and all(
|
|
432
|
+
isinstance(s, float) for s in base_scale
|
|
433
|
+
):
|
|
434
|
+
scales = compute_scales_from_shapes(shapes, base_scale)
|
|
435
|
+
elif isinstance(base_scale, list):
|
|
436
|
+
scales = base_scale
|
|
437
|
+
if len(scales) != len(shapes):
|
|
438
|
+
raise NgioValueError(
|
|
439
|
+
"Scales must have the same length as shapes "
|
|
440
|
+
f"({len(shapes)}), got {len(scales)}"
|
|
348
441
|
)
|
|
442
|
+
else:
|
|
443
|
+
raise NgioValueError(
|
|
444
|
+
"base_scale must be either a tuple of floats or a list of tuples "
|
|
445
|
+
" of floats."
|
|
349
446
|
)
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
447
|
+
|
|
448
|
+
translations = _compute_translations_from_shapes(scales, base_translation)
|
|
449
|
+
for level_path, shape, scale, translation in zip(
|
|
450
|
+
levels_paths,
|
|
451
|
+
shapes,
|
|
452
|
+
scales,
|
|
453
|
+
translations,
|
|
454
|
+
strict=True,
|
|
455
|
+
):
|
|
456
|
+
level = PyramidLevel(
|
|
457
|
+
path=level_path,
|
|
458
|
+
shape=shape,
|
|
459
|
+
scale=scale,
|
|
460
|
+
translation=translation,
|
|
461
|
+
chunks=chunks,
|
|
462
|
+
shards=shards,
|
|
463
|
+
)
|
|
464
|
+
levels.append(level)
|
|
366
465
|
other_array_kwargs = other_array_kwargs or {}
|
|
367
466
|
return cls(
|
|
368
467
|
levels=levels,
|
ngio/images/_abstract_image.py
CHANGED
|
@@ -16,9 +16,15 @@ from ngio.common import (
|
|
|
16
16
|
Roi,
|
|
17
17
|
consolidate_pyramid,
|
|
18
18
|
)
|
|
19
|
-
from ngio.common._pyramid import
|
|
19
|
+
from ngio.common._pyramid import (
|
|
20
|
+
ChunksLike,
|
|
21
|
+
ShardsLike,
|
|
22
|
+
compute_scales_from_shapes,
|
|
23
|
+
compute_shapes_from_scaling_factors,
|
|
24
|
+
)
|
|
20
25
|
from ngio.images._create_utils import (
|
|
21
26
|
_image_or_label_meta,
|
|
27
|
+
compute_base_scale,
|
|
22
28
|
init_image_like_from_shapes,
|
|
23
29
|
)
|
|
24
30
|
from ngio.io_pipes import (
|
|
@@ -602,32 +608,39 @@ def consolidate_image(
|
|
|
602
608
|
|
|
603
609
|
def _shapes_from_ref_image(
|
|
604
610
|
ref_image: AbstractImage,
|
|
605
|
-
) -> list[tuple[int, ...]]:
|
|
611
|
+
) -> tuple[list[tuple[int, ...]], list[tuple[float, ...]]]:
|
|
606
612
|
"""Rebuild base shape based on a new shape."""
|
|
607
|
-
|
|
613
|
+
meta = ref_image.meta
|
|
614
|
+
paths = meta.paths
|
|
608
615
|
index_path = paths.index(ref_image.path)
|
|
609
616
|
sub_paths = paths[index_path:]
|
|
610
617
|
group_handler = ref_image._group_handler
|
|
611
|
-
shapes = []
|
|
618
|
+
shapes, scales = [], []
|
|
612
619
|
for path in sub_paths:
|
|
613
620
|
zarr_array = group_handler.get_array(path)
|
|
614
621
|
shapes.append(zarr_array.shape)
|
|
622
|
+
scales.append(meta.get_dataset(path=path).scale)
|
|
615
623
|
if len(shapes) == len(paths):
|
|
616
|
-
return shapes
|
|
624
|
+
return shapes, scales
|
|
617
625
|
missing_levels = len(paths) - len(shapes)
|
|
618
|
-
extended_shapes =
|
|
626
|
+
extended_shapes = compute_shapes_from_scaling_factors(
|
|
619
627
|
base_shape=shapes[-1],
|
|
620
628
|
scaling_factors=ref_image.meta.scaling_factor(),
|
|
621
629
|
num_levels=missing_levels + 1,
|
|
622
630
|
)
|
|
623
631
|
shapes.extend(extended_shapes[1:])
|
|
624
|
-
|
|
632
|
+
extended_scales = compute_scales_from_shapes(
|
|
633
|
+
shapes=extended_shapes,
|
|
634
|
+
base_scale=scales[-1],
|
|
635
|
+
)
|
|
636
|
+
scales.extend(extended_scales[1:])
|
|
637
|
+
return shapes, scales
|
|
625
638
|
|
|
626
639
|
|
|
627
640
|
def _shapes_from_new_shape(
|
|
628
641
|
ref_image: AbstractImage,
|
|
629
642
|
shape: Sequence[int],
|
|
630
|
-
) -> list[tuple[int, ...]]:
|
|
643
|
+
) -> tuple[list[tuple[int, ...]], list[tuple[float, ...]]]:
|
|
631
644
|
"""Rebuild pyramid shapes based on a new base shape."""
|
|
632
645
|
if len(shape) != len(ref_image.shape):
|
|
633
646
|
raise NgioValueError(
|
|
@@ -637,27 +650,33 @@ def _shapes_from_new_shape(
|
|
|
637
650
|
base_shape = tuple(shape)
|
|
638
651
|
scaling_factors = ref_image.meta.scaling_factor()
|
|
639
652
|
num_levels = len(ref_image.meta.paths)
|
|
640
|
-
|
|
653
|
+
shapes = compute_shapes_from_scaling_factors(
|
|
641
654
|
base_shape=base_shape,
|
|
642
655
|
scaling_factors=scaling_factors,
|
|
643
656
|
num_levels=num_levels,
|
|
644
657
|
)
|
|
658
|
+
scales = compute_scales_from_shapes(
|
|
659
|
+
shapes=shapes,
|
|
660
|
+
base_scale=ref_image.dataset.scale,
|
|
661
|
+
)
|
|
662
|
+
return shapes, scales
|
|
645
663
|
|
|
646
664
|
|
|
647
665
|
def _compute_pyramid_shapes(
|
|
648
666
|
ref_image: AbstractImage,
|
|
649
667
|
shape: Sequence[int] | None,
|
|
650
|
-
) -> list[tuple[int, ...]]:
|
|
668
|
+
) -> tuple[list[tuple[int, ...]], list[tuple[float, ...]]]:
|
|
651
669
|
"""Rebuild pyramid shapes based on a new base shape."""
|
|
652
670
|
if shape is None:
|
|
653
671
|
return _shapes_from_ref_image(ref_image=ref_image)
|
|
654
672
|
return _shapes_from_new_shape(ref_image=ref_image, shape=shape)
|
|
655
673
|
|
|
656
674
|
|
|
657
|
-
def
|
|
675
|
+
def _check_len_compatibility(
|
|
658
676
|
ref_shape: tuple[int, ...],
|
|
659
677
|
chunks: ChunksLike,
|
|
660
678
|
shards: ShardsLike | None,
|
|
679
|
+
translation: Sequence[float] | None = None,
|
|
661
680
|
) -> None:
|
|
662
681
|
"""Check if the chunks and shards are compatible with the reference shape.
|
|
663
682
|
|
|
@@ -665,6 +684,7 @@ def _check_chunks_and_shards_compatibility(
|
|
|
665
684
|
ref_shape: The reference shape.
|
|
666
685
|
chunks: The chunks to check.
|
|
667
686
|
shards: The shards to check.
|
|
687
|
+
translation: The translation to check.
|
|
668
688
|
"""
|
|
669
689
|
if chunks != "auto":
|
|
670
690
|
if len(chunks) != len(ref_shape):
|
|
@@ -676,6 +696,12 @@ def _check_chunks_and_shards_compatibility(
|
|
|
676
696
|
raise NgioValueError(
|
|
677
697
|
"The length of the shards must be the same as the number of dimensions."
|
|
678
698
|
)
|
|
699
|
+
if translation is not None:
|
|
700
|
+
if len(translation) != len(ref_shape):
|
|
701
|
+
raise NgioValueError(
|
|
702
|
+
"The length of the translation must be the same as the number of "
|
|
703
|
+
"dimensions."
|
|
704
|
+
)
|
|
679
705
|
|
|
680
706
|
|
|
681
707
|
def _apply_channel_policy(
|
|
@@ -685,7 +711,16 @@ def _apply_channel_policy(
|
|
|
685
711
|
axes: tuple[str, ...],
|
|
686
712
|
chunks: ChunksLike,
|
|
687
713
|
shards: ShardsLike | None,
|
|
688
|
-
|
|
714
|
+
translation: Sequence[float],
|
|
715
|
+
scales: list[tuple[float, ...]] | tuple[float, ...],
|
|
716
|
+
) -> tuple[
|
|
717
|
+
list[tuple[int, ...]],
|
|
718
|
+
tuple[str, ...],
|
|
719
|
+
ChunksLike,
|
|
720
|
+
ShardsLike | None,
|
|
721
|
+
tuple[float, ...],
|
|
722
|
+
list[tuple[float, ...]] | tuple[float, ...],
|
|
723
|
+
]:
|
|
689
724
|
"""Apply the channel policy to the shapes and axes.
|
|
690
725
|
|
|
691
726
|
Args:
|
|
@@ -695,12 +730,15 @@ def _apply_channel_policy(
|
|
|
695
730
|
axes: The axes of the image.
|
|
696
731
|
chunks: The chunks of the image.
|
|
697
732
|
shards: The shards of the image.
|
|
733
|
+
translation: The translation of the image.
|
|
734
|
+
scales: The scales of the image.
|
|
698
735
|
|
|
699
736
|
Returns:
|
|
700
737
|
The new shapes and axes after applying the channel policy.
|
|
701
738
|
"""
|
|
739
|
+
translation = tuple(translation)
|
|
702
740
|
if channels_policy == "same":
|
|
703
|
-
return shapes, axes, chunks, shards
|
|
741
|
+
return shapes, axes, chunks, shards, translation, scales
|
|
704
742
|
|
|
705
743
|
if channels_policy == "singleton":
|
|
706
744
|
# Treat 'singleton' as setting channel size to 1
|
|
@@ -709,7 +747,7 @@ def _apply_channel_policy(
|
|
|
709
747
|
channel_index = ref_image.axes_handler.get_index("c")
|
|
710
748
|
if channel_index is None:
|
|
711
749
|
if channels_policy == "squeeze":
|
|
712
|
-
return shapes, axes, chunks, shards
|
|
750
|
+
return shapes, axes, chunks, shards, translation, scales
|
|
713
751
|
raise NgioValueError(
|
|
714
752
|
f"Cannot apply channel policy {channels_policy=} to an image "
|
|
715
753
|
"without channels axis."
|
|
@@ -719,6 +757,15 @@ def _apply_channel_policy(
|
|
|
719
757
|
for shape in shapes:
|
|
720
758
|
new_shape = shape[:channel_index] + shape[channel_index + 1 :]
|
|
721
759
|
new_shapes.append(new_shape)
|
|
760
|
+
|
|
761
|
+
if isinstance(scales, tuple):
|
|
762
|
+
new_scales = scales[:channel_index] + scales[channel_index + 1 :]
|
|
763
|
+
else:
|
|
764
|
+
new_scales = []
|
|
765
|
+
for scale in scales:
|
|
766
|
+
new_scale = scale[:channel_index] + scale[channel_index + 1 :]
|
|
767
|
+
new_scales.append(new_scale)
|
|
768
|
+
|
|
722
769
|
new_axes = axes[:channel_index] + axes[channel_index + 1 :]
|
|
723
770
|
if chunks == "auto":
|
|
724
771
|
new_chunks: ChunksLike = "auto"
|
|
@@ -728,7 +775,9 @@ def _apply_channel_policy(
|
|
|
728
775
|
new_shards: ShardsLike | None = shards
|
|
729
776
|
else:
|
|
730
777
|
new_shards = shards[:channel_index] + shards[channel_index + 1 :]
|
|
731
|
-
|
|
778
|
+
|
|
779
|
+
translation = translation[:channel_index] + translation[channel_index + 1 :]
|
|
780
|
+
return new_shapes, new_axes, new_chunks, new_shards, translation, new_scales
|
|
732
781
|
elif isinstance(channels_policy, int):
|
|
733
782
|
new_shapes = []
|
|
734
783
|
for shape in shapes:
|
|
@@ -738,7 +787,7 @@ def _apply_channel_policy(
|
|
|
738
787
|
*shape[channel_index + 1 :],
|
|
739
788
|
)
|
|
740
789
|
new_shapes.append(new_shape)
|
|
741
|
-
return new_shapes, axes, chunks, shards
|
|
790
|
+
return new_shapes, axes, chunks, shards, translation, scales
|
|
742
791
|
else:
|
|
743
792
|
raise NgioValueError(
|
|
744
793
|
f"Invalid channels policy: {channels_policy}. "
|
|
@@ -783,6 +832,35 @@ def _check_channels_meta_compatibility(
|
|
|
783
832
|
return channels_meta_
|
|
784
833
|
|
|
785
834
|
|
|
835
|
+
def adapt_scales(
|
|
836
|
+
scales: list[tuple[float, ...]],
|
|
837
|
+
pixelsize: float | tuple[float, float] | None,
|
|
838
|
+
z_spacing: float | None,
|
|
839
|
+
time_spacing: float | None,
|
|
840
|
+
ref_image: AbstractImage,
|
|
841
|
+
) -> list[tuple[float, ...]] | tuple[float, ...]:
|
|
842
|
+
if pixelsize is None and z_spacing is None and time_spacing is None:
|
|
843
|
+
return scales
|
|
844
|
+
pixel_size = ref_image.pixel_size
|
|
845
|
+
if pixelsize is None:
|
|
846
|
+
pixelsize = (pixel_size.y, pixel_size.x)
|
|
847
|
+
if z_spacing is None:
|
|
848
|
+
z_spacing = pixel_size.z
|
|
849
|
+
else:
|
|
850
|
+
z_spacing = z_spacing
|
|
851
|
+
if time_spacing is None:
|
|
852
|
+
time_spacing = pixel_size.t
|
|
853
|
+
else:
|
|
854
|
+
time_spacing = time_spacing
|
|
855
|
+
base_scale = compute_base_scale(
|
|
856
|
+
pixelsize=pixelsize,
|
|
857
|
+
z_spacing=z_spacing,
|
|
858
|
+
time_spacing=time_spacing,
|
|
859
|
+
axes_handler=ref_image.axes_handler,
|
|
860
|
+
)
|
|
861
|
+
return base_scale
|
|
862
|
+
|
|
863
|
+
|
|
786
864
|
def abstract_derive(
|
|
787
865
|
*,
|
|
788
866
|
ref_image: AbstractImage,
|
|
@@ -795,6 +873,7 @@ def abstract_derive(
|
|
|
795
873
|
z_spacing: float | None = None,
|
|
796
874
|
time_spacing: float | None = None,
|
|
797
875
|
name: str | None = None,
|
|
876
|
+
translation: Sequence[float] | None = None,
|
|
798
877
|
channels_policy: Literal["squeeze", "same", "singleton"] | int = "same",
|
|
799
878
|
channels_meta: Sequence[str | Channel] | None = None,
|
|
800
879
|
ngff_version: NgffVersions | None = None,
|
|
@@ -823,6 +902,8 @@ def abstract_derive(
|
|
|
823
902
|
z_spacing (float | None): The z spacing of the new image.
|
|
824
903
|
time_spacing (float | None): The time spacing of the new image.
|
|
825
904
|
name (str | None): The name of the new image.
|
|
905
|
+
translation (Sequence[float] | None): The translation for each axis
|
|
906
|
+
at the highest resolution level. Defaults to None.
|
|
826
907
|
channels_policy (Literal["squeeze", "same", "singleton"] | int):
|
|
827
908
|
Possible policies:
|
|
828
909
|
- If "squeeze", the channels axis will be removed (no matter its size).
|
|
@@ -867,40 +948,23 @@ def abstract_derive(
|
|
|
867
948
|
DeprecationWarning,
|
|
868
949
|
stacklevel=2,
|
|
869
950
|
)
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
time_spacing_ = pixel_size.t
|
|
873
|
-
else:
|
|
874
|
-
if pixelsize is None:
|
|
875
|
-
pixelsize_ = (ref_image.pixel_size.y, ref_image.pixel_size.x)
|
|
876
|
-
else:
|
|
877
|
-
pixelsize_ = pixelsize
|
|
878
|
-
|
|
879
|
-
if z_spacing is None:
|
|
880
|
-
z_spacing_ = ref_image.pixel_size.z
|
|
881
|
-
else:
|
|
882
|
-
z_spacing_ = z_spacing
|
|
883
|
-
|
|
884
|
-
if time_spacing is None:
|
|
885
|
-
time_spacing_ = ref_image.pixel_size.t
|
|
886
|
-
else:
|
|
887
|
-
time_spacing_ = time_spacing
|
|
951
|
+
pixelsize = (pixel_size.y, pixel_size.x)
|
|
952
|
+
# End of deprecated arguments handling
|
|
888
953
|
ref_meta = ref_image.meta
|
|
889
954
|
|
|
890
|
-
shapes = _compute_pyramid_shapes(
|
|
955
|
+
shapes, scales = _compute_pyramid_shapes(
|
|
891
956
|
shape=shape,
|
|
892
957
|
ref_image=ref_image,
|
|
893
958
|
)
|
|
894
959
|
ref_shape = next(iter(shapes))
|
|
895
960
|
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
time_spacing = ref_image.pixel_size.t
|
|
961
|
+
scales = adapt_scales(
|
|
962
|
+
scales=scales,
|
|
963
|
+
pixelsize=pixelsize,
|
|
964
|
+
z_spacing=z_spacing,
|
|
965
|
+
time_spacing=time_spacing,
|
|
966
|
+
ref_image=ref_image,
|
|
967
|
+
)
|
|
904
968
|
|
|
905
969
|
if name is None:
|
|
906
970
|
name = ref_meta.name
|
|
@@ -914,27 +978,33 @@ def abstract_derive(
|
|
|
914
978
|
if compressors is None:
|
|
915
979
|
compressors = ref_image.zarr_array.compressors # type: ignore
|
|
916
980
|
|
|
981
|
+
if translation is None:
|
|
982
|
+
translation = ref_image.dataset.translation
|
|
983
|
+
|
|
917
984
|
if chunks is None:
|
|
918
985
|
chunks = ref_image.zarr_array.chunks
|
|
919
986
|
if shards is None:
|
|
920
987
|
shards = ref_image.zarr_array.shards
|
|
921
988
|
|
|
922
|
-
|
|
989
|
+
_check_len_compatibility(
|
|
923
990
|
ref_shape=ref_shape,
|
|
924
991
|
chunks=chunks,
|
|
925
992
|
shards=shards,
|
|
993
|
+
translation=translation,
|
|
926
994
|
)
|
|
927
995
|
|
|
928
996
|
if ngff_version is None:
|
|
929
997
|
ngff_version = ref_meta.version
|
|
930
998
|
|
|
931
|
-
shapes, axes, chunks, shards = _apply_channel_policy(
|
|
999
|
+
shapes, axes, chunks, shards, translation, scales = _apply_channel_policy(
|
|
932
1000
|
ref_image=ref_image,
|
|
933
1001
|
channels_policy=channels_policy,
|
|
934
1002
|
shapes=shapes,
|
|
935
1003
|
axes=ref_image.axes,
|
|
936
1004
|
chunks=chunks,
|
|
937
1005
|
shards=shards,
|
|
1006
|
+
translation=translation,
|
|
1007
|
+
scales=scales,
|
|
938
1008
|
)
|
|
939
1009
|
channels_meta_ = _check_channels_meta_compatibility(
|
|
940
1010
|
meta_type=meta_type,
|
|
@@ -946,10 +1016,9 @@ def abstract_derive(
|
|
|
946
1016
|
store=store,
|
|
947
1017
|
meta_type=meta_type,
|
|
948
1018
|
shapes=shapes,
|
|
949
|
-
|
|
950
|
-
z_spacing=z_spacing_,
|
|
951
|
-
time_spacing=time_spacing_,
|
|
1019
|
+
base_scale=scales,
|
|
952
1020
|
levels=ref_meta.paths,
|
|
1021
|
+
translation=translation,
|
|
953
1022
|
time_unit=ref_image.time_unit,
|
|
954
1023
|
space_unit=ref_image.space_unit,
|
|
955
1024
|
axes_names=axes,
|
|
@@ -30,6 +30,7 @@ def create_synthetic_ome_zarr(
|
|
|
30
30
|
shape: Sequence[int],
|
|
31
31
|
reference_sample: AVAILABLE_SAMPLES | SampleInfo = "Cardiomyocyte",
|
|
32
32
|
levels: int | list[str] = 5,
|
|
33
|
+
translation: Sequence[float] | None = None,
|
|
33
34
|
table_backend: TableBackend = DefaultTableBackend,
|
|
34
35
|
scaling_factors: Sequence[float] | Literal["auto"] = "auto",
|
|
35
36
|
axes_names: Sequence[str] | None = None,
|
|
@@ -51,6 +52,8 @@ def create_synthetic_ome_zarr(
|
|
|
51
52
|
Defaults to "Cardiomyocyte".
|
|
52
53
|
levels (int | list[str]): The number of levels in the pyramid or a list of
|
|
53
54
|
level names. Defaults to 5.
|
|
55
|
+
translation (Sequence[float] | None): The translation for each axis
|
|
56
|
+
at the highest resolution level. Defaults to None.
|
|
54
57
|
table_backend (TableBackend): Table backend to be used to store tables.
|
|
55
58
|
Defaults to DefaultTableBackend.
|
|
56
59
|
scaling_factors (Sequence[float] | Literal["auto"]): The down-scaling factors
|
|
@@ -86,6 +89,7 @@ def create_synthetic_ome_zarr(
|
|
|
86
89
|
z_spacing=sample_info.z_spacing,
|
|
87
90
|
time_spacing=sample_info.time_spacing,
|
|
88
91
|
levels=levels,
|
|
92
|
+
translation=translation,
|
|
89
93
|
space_unit=sample_info.space_unit,
|
|
90
94
|
time_unit=sample_info.time_unit,
|
|
91
95
|
axes_names=axes_names,
|
ngio/images/_create_utils.py
CHANGED
|
@@ -149,7 +149,7 @@ def _compute_scaling_factors(
|
|
|
149
149
|
return tuple(scaling_factors)
|
|
150
150
|
|
|
151
151
|
|
|
152
|
-
def
|
|
152
|
+
def compute_base_scale(
|
|
153
153
|
*,
|
|
154
154
|
pixelsize: float | tuple[float, float],
|
|
155
155
|
z_spacing: float,
|
|
@@ -243,6 +243,7 @@ def init_image_like(
|
|
|
243
243
|
time_spacing: float = 1.0,
|
|
244
244
|
scaling_factors: Sequence[float] | Literal["auto"] = "auto",
|
|
245
245
|
levels: int | list[str] = 5,
|
|
246
|
+
translation: Sequence[float] | None = None,
|
|
246
247
|
space_unit: SpaceUnits | str | None = DefaultSpaceUnit,
|
|
247
248
|
time_unit: TimeUnits | str | None = DefaultTimeUnit,
|
|
248
249
|
axes_names: Sequence[str] | None = None,
|
|
@@ -283,7 +284,7 @@ def init_image_like(
|
|
|
283
284
|
allow_non_canonical_axes=allow_non_canonical_axes,
|
|
284
285
|
strict_canonical_order=strict_canonical_order,
|
|
285
286
|
)
|
|
286
|
-
base_scale =
|
|
287
|
+
base_scale = compute_base_scale(
|
|
287
288
|
pixelsize=pixelsize,
|
|
288
289
|
z_spacing=z_spacing,
|
|
289
290
|
time_spacing=time_spacing,
|
|
@@ -306,6 +307,7 @@ def init_image_like(
|
|
|
306
307
|
scaling_factors=scaling_factors,
|
|
307
308
|
base_shape=shape,
|
|
308
309
|
base_scale=base_scale,
|
|
310
|
+
base_translation=translation,
|
|
309
311
|
axes=axes_handler.axes_names,
|
|
310
312
|
chunks=chunks,
|
|
311
313
|
data_type=dtype,
|
|
@@ -319,7 +321,7 @@ def init_image_like(
|
|
|
319
321
|
levels=[p.path for p in pyramid_builder.levels],
|
|
320
322
|
axes_handler=axes_handler,
|
|
321
323
|
scales=[p.scale for p in pyramid_builder.levels],
|
|
322
|
-
translations=[
|
|
324
|
+
translations=[p.translation for p in pyramid_builder.levels],
|
|
323
325
|
name=name,
|
|
324
326
|
version=ngff_version,
|
|
325
327
|
)
|
|
@@ -340,10 +342,9 @@ def init_image_like_from_shapes(
|
|
|
340
342
|
# Ngff image parameters
|
|
341
343
|
meta_type: type[_image_or_label_meta],
|
|
342
344
|
shapes: Sequence[tuple[int, ...]],
|
|
343
|
-
|
|
344
|
-
z_spacing: float = 1.0,
|
|
345
|
-
time_spacing: float = 1.0,
|
|
345
|
+
base_scale: tuple[float, ...] | list[tuple[float, ...]],
|
|
346
346
|
levels: list[str] | None = None,
|
|
347
|
+
translation: Sequence[float] | None = None,
|
|
347
348
|
space_unit: SpaceUnits | str | None = DefaultSpaceUnit,
|
|
348
349
|
time_unit: TimeUnits | str | None = DefaultTimeUnit,
|
|
349
350
|
axes_names: Sequence[str] | None = None,
|
|
@@ -381,12 +382,6 @@ def init_image_like_from_shapes(
|
|
|
381
382
|
allow_non_canonical_axes=allow_non_canonical_axes,
|
|
382
383
|
strict_canonical_order=strict_canonical_order,
|
|
383
384
|
)
|
|
384
|
-
base_scale = _compute_base_scale(
|
|
385
|
-
pixelsize=pixelsize,
|
|
386
|
-
z_spacing=z_spacing,
|
|
387
|
-
time_spacing=time_spacing,
|
|
388
|
-
axes_handler=axes_handler,
|
|
389
|
-
)
|
|
390
385
|
if levels is None:
|
|
391
386
|
levels_paths = tuple(str(i) for i in range(len(shapes)))
|
|
392
387
|
else:
|
|
@@ -395,6 +390,7 @@ def init_image_like_from_shapes(
|
|
|
395
390
|
pyramid_builder = ImagePyramidBuilder.from_shapes(
|
|
396
391
|
shapes=shapes,
|
|
397
392
|
base_scale=base_scale,
|
|
393
|
+
base_translation=translation,
|
|
398
394
|
levels_paths=levels_paths,
|
|
399
395
|
axes=axes_handler.axes_names,
|
|
400
396
|
chunks=chunks,
|
|
@@ -409,7 +405,7 @@ def init_image_like_from_shapes(
|
|
|
409
405
|
levels=[p.path for p in pyramid_builder.levels],
|
|
410
406
|
axes_handler=axes_handler,
|
|
411
407
|
scales=[p.scale for p in pyramid_builder.levels],
|
|
412
|
-
translations=[
|
|
408
|
+
translations=[p.translation for p in pyramid_builder.levels],
|
|
413
409
|
name=name,
|
|
414
410
|
version=ngff_version,
|
|
415
411
|
)
|
ngio/images/_image.py
CHANGED
|
@@ -612,6 +612,7 @@ class ImagesContainer:
|
|
|
612
612
|
z_spacing: float | None = None,
|
|
613
613
|
time_spacing: float | None = None,
|
|
614
614
|
name: str | None = None,
|
|
615
|
+
translation: Sequence[float] | None = None,
|
|
615
616
|
channels_meta: Sequence[str | Channel] | None = None,
|
|
616
617
|
channels_policy: Literal["same", "squeeze", "singleton"] | int = "same",
|
|
617
618
|
ngff_version: NgffVersions | None = None,
|
|
@@ -643,6 +644,8 @@ class ImagesContainer:
|
|
|
643
644
|
z_spacing (float | None): The z spacing of the new image.
|
|
644
645
|
time_spacing (float | None): The time spacing of the new image.
|
|
645
646
|
name (str | None): The name of the new image.
|
|
647
|
+
translation (Sequence[float] | None): The translation for each axis
|
|
648
|
+
at the highest resolution level. Defaults to None.
|
|
646
649
|
channels_meta (Sequence[str | Channel] | None): The channels metadata
|
|
647
650
|
of the new image.
|
|
648
651
|
channels_policy (Literal["same", "squeeze", "singleton"] | int):
|
|
@@ -681,6 +684,7 @@ class ImagesContainer:
|
|
|
681
684
|
z_spacing=z_spacing,
|
|
682
685
|
time_spacing=time_spacing,
|
|
683
686
|
name=name,
|
|
687
|
+
translation=translation,
|
|
684
688
|
channels_meta=channels_meta,
|
|
685
689
|
channels_policy=channels_policy,
|
|
686
690
|
ngff_version=ngff_version,
|
|
@@ -774,6 +778,7 @@ def derive_image_container(
|
|
|
774
778
|
z_spacing: float | None = None,
|
|
775
779
|
time_spacing: float | None = None,
|
|
776
780
|
name: str | None = None,
|
|
781
|
+
translation: Sequence[float] | None = None,
|
|
777
782
|
channels_policy: Literal["same", "squeeze", "singleton"] | int = "same",
|
|
778
783
|
channels_meta: Sequence[str | Channel] | None = None,
|
|
779
784
|
ngff_version: NgffVersions | None = None,
|
|
@@ -803,6 +808,8 @@ def derive_image_container(
|
|
|
803
808
|
z_spacing (float | None): The z spacing of the new image.
|
|
804
809
|
time_spacing (float | None): The time spacing of the new image.
|
|
805
810
|
name (str | None): The name of the new image.
|
|
811
|
+
translation (Sequence[float] | None): The translation for each axis
|
|
812
|
+
at the highest resolution level. Defaults to None.
|
|
806
813
|
channels_policy (Literal["squeeze", "same", "singleton"] | int): Possible
|
|
807
814
|
policies:
|
|
808
815
|
- If "squeeze", the channels axis will be removed (no matter its size).
|
|
@@ -842,6 +849,7 @@ def derive_image_container(
|
|
|
842
849
|
z_spacing=z_spacing,
|
|
843
850
|
time_spacing=time_spacing,
|
|
844
851
|
name=name,
|
|
852
|
+
translation=translation,
|
|
845
853
|
channels_meta=channels_meta,
|
|
846
854
|
channels_policy=channels_policy,
|
|
847
855
|
ngff_version=ngff_version,
|
ngio/images/_label.py
CHANGED
|
@@ -218,6 +218,7 @@ class LabelsContainer:
|
|
|
218
218
|
pixelsize: float | tuple[float, float] | None = None,
|
|
219
219
|
z_spacing: float | None = None,
|
|
220
220
|
time_spacing: float | None = None,
|
|
221
|
+
translation: Sequence[float] | None = None,
|
|
221
222
|
channels_policy: Literal["same", "squeeze", "singleton"] | int = "squeeze",
|
|
222
223
|
ngff_version: NgffVersions | None = None,
|
|
223
224
|
# Zarr Array parameters
|
|
@@ -244,6 +245,8 @@ class LabelsContainer:
|
|
|
244
245
|
label.
|
|
245
246
|
z_spacing (float | None): The z spacing of the new label.
|
|
246
247
|
time_spacing (float | None): The time spacing of the new label.
|
|
248
|
+
translation (Sequence[float] | None): The translation for each axis
|
|
249
|
+
at the highest resolution level. Defaults to None.
|
|
247
250
|
channels_policy (Literal["squeeze", "same", "singleton"] | int):
|
|
248
251
|
Possible policies:
|
|
249
252
|
- If "squeeze", the channels axis will be removed (no matter its size).
|
|
@@ -288,6 +291,7 @@ class LabelsContainer:
|
|
|
288
291
|
z_spacing=z_spacing,
|
|
289
292
|
time_spacing=time_spacing,
|
|
290
293
|
name=name,
|
|
294
|
+
translation=translation,
|
|
291
295
|
channels_policy=channels_policy,
|
|
292
296
|
ngff_version=ngff_version,
|
|
293
297
|
chunks=chunks,
|
|
@@ -321,6 +325,7 @@ def derive_label(
|
|
|
321
325
|
z_spacing: float | None = None,
|
|
322
326
|
time_spacing: float | None = None,
|
|
323
327
|
name: str | None = None,
|
|
328
|
+
translation: Sequence[float] | None = None,
|
|
324
329
|
channels_policy: Literal["same", "squeeze", "singleton"] | int = "squeeze",
|
|
325
330
|
ngff_version: NgffVersions | None = None,
|
|
326
331
|
# Zarr Array parameters
|
|
@@ -347,6 +352,8 @@ def derive_label(
|
|
|
347
352
|
z_spacing (float | None): The z spacing of the new label.
|
|
348
353
|
time_spacing (float | None): The time spacing of the new label.
|
|
349
354
|
name (str | None): The name of the new label.
|
|
355
|
+
translation (Sequence[float] | None): The translation for each axis
|
|
356
|
+
at the highest resolution level. Defaults to None.
|
|
350
357
|
channels_policy (Literal["squeeze", "same", "singleton"] | int): Possible
|
|
351
358
|
policies:
|
|
352
359
|
- If "squeeze", the channels axis will be removed (no matter its size).
|
|
@@ -385,6 +392,7 @@ def derive_label(
|
|
|
385
392
|
z_spacing=z_spacing,
|
|
386
393
|
time_spacing=time_spacing,
|
|
387
394
|
name=name,
|
|
395
|
+
translation=translation,
|
|
388
396
|
channels_meta=None,
|
|
389
397
|
channels_policy=channels_policy,
|
|
390
398
|
ngff_version=ngff_version,
|
|
@@ -430,6 +430,7 @@ class OmeZarrContainer:
|
|
|
430
430
|
z_spacing: float | None = None,
|
|
431
431
|
time_spacing: float | None = None,
|
|
432
432
|
name: str | None = None,
|
|
433
|
+
translation: Sequence[float] | None = None,
|
|
433
434
|
channels_policy: Literal["squeeze", "same", "singleton"] | int = "same",
|
|
434
435
|
channels_meta: Sequence[str | Channel] | None = None,
|
|
435
436
|
ngff_version: NgffVersions | None = None,
|
|
@@ -462,6 +463,8 @@ class OmeZarrContainer:
|
|
|
462
463
|
z_spacing (float | None): The z spacing of the new image.
|
|
463
464
|
time_spacing (float | None): The time spacing of the new image.
|
|
464
465
|
name (str | None): The name of the new image.
|
|
466
|
+
translation (Sequence[float] | None): The translation for each axis
|
|
467
|
+
at the highest resolution level. Defaults to None.
|
|
465
468
|
channels_policy (Literal["squeeze", "same", "singleton"] | int): Possible
|
|
466
469
|
policies:
|
|
467
470
|
- If "squeeze", the channels axis will be removed (no matter its size).
|
|
@@ -503,6 +506,7 @@ class OmeZarrContainer:
|
|
|
503
506
|
z_spacing=z_spacing,
|
|
504
507
|
time_spacing=time_spacing,
|
|
505
508
|
name=name,
|
|
509
|
+
translation=translation,
|
|
506
510
|
channels_meta=channels_meta,
|
|
507
511
|
channels_policy=channels_policy,
|
|
508
512
|
ngff_version=ngff_version,
|
|
@@ -788,6 +792,7 @@ class OmeZarrContainer:
|
|
|
788
792
|
pixelsize: float | tuple[float, float] | None = None,
|
|
789
793
|
z_spacing: float | None = None,
|
|
790
794
|
time_spacing: float | None = None,
|
|
795
|
+
translation: Sequence[float] | None = None,
|
|
791
796
|
channels_policy: Literal["same", "squeeze", "singleton"] | int = "squeeze",
|
|
792
797
|
ngff_version: NgffVersions | None = None,
|
|
793
798
|
# Zarr Array parameters
|
|
@@ -815,6 +820,8 @@ class OmeZarrContainer:
|
|
|
815
820
|
label.
|
|
816
821
|
z_spacing (float | None): The z spacing of the new label.
|
|
817
822
|
time_spacing (float | None): The time spacing of the new label.
|
|
823
|
+
translation (Sequence[float] | None): The translation for each axis
|
|
824
|
+
at the highest resolution level. Defaults to None.
|
|
818
825
|
channels_policy (Literal["same", "squeeze", "singleton"] | int): Possible
|
|
819
826
|
policies:
|
|
820
827
|
- If "squeeze", the channels axis will be removed (no matter its size).
|
|
@@ -852,6 +859,7 @@ class OmeZarrContainer:
|
|
|
852
859
|
pixelsize=pixelsize,
|
|
853
860
|
z_spacing=z_spacing,
|
|
854
861
|
time_spacing=time_spacing,
|
|
862
|
+
translation=translation,
|
|
855
863
|
channels_policy=channels_policy,
|
|
856
864
|
ngff_version=ngff_version,
|
|
857
865
|
chunks=chunks,
|
|
@@ -961,6 +969,7 @@ def create_empty_ome_zarr(
|
|
|
961
969
|
time_spacing: float = 1.0,
|
|
962
970
|
scaling_factors: Sequence[float] | Literal["auto"] = "auto",
|
|
963
971
|
levels: int | list[str] = 5,
|
|
972
|
+
translation: Sequence[float] | None = None,
|
|
964
973
|
space_unit: SpaceUnits = DefaultSpaceUnit,
|
|
965
974
|
time_unit: TimeUnits = DefaultTimeUnit,
|
|
966
975
|
axes_names: Sequence[str] | None = None,
|
|
@@ -996,6 +1005,8 @@ def create_empty_ome_zarr(
|
|
|
996
1005
|
for the pyramid levels. Defaults to "auto".
|
|
997
1006
|
levels (int | list[str]): The number of levels in the pyramid or a list of
|
|
998
1007
|
level names. Defaults to 5.
|
|
1008
|
+
translation (Sequence[float] | None): The translation for each axis.
|
|
1009
|
+
at the highest resolution level. Defaults to None.
|
|
999
1010
|
space_unit (SpaceUnits): The unit of space. Defaults to DefaultSpaceUnit.
|
|
1000
1011
|
time_unit (TimeUnits): The unit of time. Defaults to DefaultTimeUnit.
|
|
1001
1012
|
axes_names (Sequence[str] | None): The names of the axes. If None the
|
|
@@ -1088,6 +1099,7 @@ def create_empty_ome_zarr(
|
|
|
1088
1099
|
time_spacing=time_spacing,
|
|
1089
1100
|
scaling_factors=scaling_factors,
|
|
1090
1101
|
levels=levels,
|
|
1102
|
+
translation=translation,
|
|
1091
1103
|
space_unit=space_unit,
|
|
1092
1104
|
time_unit=time_unit,
|
|
1093
1105
|
axes_names=axes_names,
|
|
@@ -1133,6 +1145,7 @@ def create_ome_zarr_from_array(
|
|
|
1133
1145
|
time_spacing: float = 1.0,
|
|
1134
1146
|
scaling_factors: Sequence[float] | Literal["auto"] = "auto",
|
|
1135
1147
|
levels: int | list[str] = 5,
|
|
1148
|
+
translation: Sequence[float] | None = None,
|
|
1136
1149
|
space_unit: SpaceUnits = DefaultSpaceUnit,
|
|
1137
1150
|
time_unit: TimeUnits = DefaultTimeUnit,
|
|
1138
1151
|
axes_names: Sequence[str] | None = None,
|
|
@@ -1168,6 +1181,8 @@ def create_ome_zarr_from_array(
|
|
|
1168
1181
|
for the pyramid levels. Defaults to "auto".
|
|
1169
1182
|
levels (int | list[str]): The number of levels in the pyramid or a list of
|
|
1170
1183
|
level names. Defaults to 5.
|
|
1184
|
+
translation (Sequence[float] | None): The translation for each axis.
|
|
1185
|
+
at the highest resolution level. Defaults to None.
|
|
1171
1186
|
space_unit (SpaceUnits): The unit of space. Defaults to DefaultSpaceUnit.
|
|
1172
1187
|
time_unit (TimeUnits): The unit of time. Defaults to DefaultTimeUnit.
|
|
1173
1188
|
axes_names (Sequence[str] | None): The names of the axes. If None the
|
|
@@ -1203,6 +1218,7 @@ def create_ome_zarr_from_array(
|
|
|
1203
1218
|
time_spacing=time_spacing,
|
|
1204
1219
|
scaling_factors=scaling_factors,
|
|
1205
1220
|
levels=levels,
|
|
1221
|
+
translation=translation,
|
|
1206
1222
|
space_unit=space_unit,
|
|
1207
1223
|
time_unit=time_unit,
|
|
1208
1224
|
axes_names=axes_names,
|
|
@@ -9,6 +9,9 @@ For Images and Labels implements the following functionalities:
|
|
|
9
9
|
- A function to convert a ngio image metadata to a v04 image metadata.
|
|
10
10
|
"""
|
|
11
11
|
|
|
12
|
+
from ome_zarr_models.common.coordinate_transformations import (
|
|
13
|
+
ValidTransform as ValidTransformV04,
|
|
14
|
+
)
|
|
12
15
|
from ome_zarr_models.v04.axes import Axis as AxisV04
|
|
13
16
|
from ome_zarr_models.v04.coordinate_transformations import VectorScale as VectorScaleV04
|
|
14
17
|
from ome_zarr_models.v04.coordinate_transformations import (
|
|
@@ -20,7 +23,6 @@ from ome_zarr_models.v04.image_label import ImageLabelAttrs as ImageLabelAttrsV0
|
|
|
20
23
|
from ome_zarr_models.v04.labels import LabelsAttrs as LabelsAttrsV04
|
|
21
24
|
from ome_zarr_models.v04.multiscales import Dataset as DatasetV04
|
|
22
25
|
from ome_zarr_models.v04.multiscales import Multiscale as MultiscaleV04
|
|
23
|
-
from ome_zarr_models.v04.multiscales import ValidTransform as ValidTransformV04
|
|
24
26
|
from ome_zarr_models.v04.omero import Channel as ChannelV04
|
|
25
27
|
from ome_zarr_models.v04.omero import Omero as OmeroV04
|
|
26
28
|
from ome_zarr_models.v04.omero import Window as WindowV04
|
|
@@ -9,6 +9,9 @@ For Images and Labels implements the following functionalities:
|
|
|
9
9
|
- A function to convert a ngio image metadata to a v05 image metadata.
|
|
10
10
|
"""
|
|
11
11
|
|
|
12
|
+
from ome_zarr_models.common.coordinate_transformations import (
|
|
13
|
+
ValidTransform as ValidTransformV05,
|
|
14
|
+
)
|
|
12
15
|
from ome_zarr_models.common.omero import Channel as ChannelV05
|
|
13
16
|
from ome_zarr_models.common.omero import Omero as OmeroV05
|
|
14
17
|
from ome_zarr_models.common.omero import Window as WindowV05
|
|
@@ -24,7 +27,6 @@ from ome_zarr_models.v05.labels import Labels as Labels
|
|
|
24
27
|
from ome_zarr_models.v05.labels import LabelsAttrs as LabelsAttrsV05
|
|
25
28
|
from ome_zarr_models.v05.multiscales import Dataset as DatasetV05
|
|
26
29
|
from ome_zarr_models.v05.multiscales import Multiscale as MultiscaleV05
|
|
27
|
-
from ome_zarr_models.v05.multiscales import ValidTransform as ValidTransformV05
|
|
28
30
|
from pydantic import BaseModel
|
|
29
31
|
|
|
30
32
|
from ngio.ome_zarr_meta.ngio_specs import (
|
|
@@ -2,7 +2,7 @@ ngio/__init__.py,sha256=kyInohhWrBs4qkbMYFIQeAiy1CDpvbSOtXB4buFocbw,1535
|
|
|
2
2
|
ngio/common/__init__.py,sha256=F3zAHQIhwig1xUA-SpmFVRtMeOrEj926-nHWhj-wS6c,684
|
|
3
3
|
ngio/common/_dimensions.py,sha256=w8PYgyWxA8hgJETjFbw5CXf7WrasCL5FbzgfL1in86M,11361
|
|
4
4
|
ngio/common/_masking_roi.py,sha256=rWOvhT08KfxX5djvUsX6LsUVofyU0Fq5LcUmpOYElDg,4757
|
|
5
|
-
ngio/common/_pyramid.py,sha256=
|
|
5
|
+
ngio/common/_pyramid.py,sha256=7kbvCY4J0hLl_iV5oT267j_h3UTkbqIdltqHcrwicvw,17571
|
|
6
6
|
ngio/common/_roi.py,sha256=IM0rYaekNvEDSMctYbAEZkeG9iPaJ1qjtnJ9kOVV8as,11416
|
|
7
7
|
ngio/common/_synt_images_utils.py,sha256=B6uYOW1NyrM06YMR-csca3_YnAAkPRTbvnbLdy9tk9E,3188
|
|
8
8
|
ngio/common/_zoom.py,sha256=U01c-vqXjzZkrpd9Yvs24frVfTls_xPJeeaFCGmUwYI,6727
|
|
@@ -17,13 +17,13 @@ ngio/experimental/iterators/_segmentation.py,sha256=xzotGvTn04HPeMeXZ_URnQqWco6d
|
|
|
17
17
|
ngio/hcs/__init__.py,sha256=G8j9vD-liLeB_UeGtKYIgshWvJnUA6ks9GwjvWBLdHs,357
|
|
18
18
|
ngio/hcs/_plate.py,sha256=l2a2ZMniutxRzZ88HOYwajug-svr6OanREG5mTy39x0,45773
|
|
19
19
|
ngio/images/__init__.py,sha256=9Whvt7GTiCgT_vXaEEqGnDaY1-UsRk3dhLTv091F_g4,1211
|
|
20
|
-
ngio/images/_abstract_image.py,sha256=
|
|
21
|
-
ngio/images/_create_synt_container.py,sha256=
|
|
22
|
-
ngio/images/_create_utils.py,sha256=
|
|
23
|
-
ngio/images/_image.py,sha256=
|
|
24
|
-
ngio/images/_label.py,sha256=
|
|
20
|
+
ngio/images/_abstract_image.py,sha256=SmVuFLrtqj2IVAFYrO6rWshsTO2G_wKd0WgW5TzQA18,34186
|
|
21
|
+
ngio/images/_create_synt_container.py,sha256=gCuT1SqZXJ_s7WRI_KbcoG1zrmEqFYKxKVZX04bR__A,5402
|
|
22
|
+
ngio/images/_create_utils.py,sha256=KohLQppIqECB65VzHaOejH3xHo9YcugmKIJ0WKam8fI,14348
|
|
23
|
+
ngio/images/_image.py,sha256=z5M4cfT_XmAGBQSHoUFn7BvwrmzwV0WjMIMcSIoKfPA,35246
|
|
24
|
+
ngio/images/_label.py,sha256=6H_nUobvmO2wvI_r0BJtBK47sprYtIzuoxSn8zVKET8,15905
|
|
25
25
|
ngio/images/_masked_image.py,sha256=YhbBzgPZMav6rX0WYue1BaxAzEIsfaQrxUIOK6ZWZcw,18848
|
|
26
|
-
ngio/images/_ome_zarr_container.py,sha256=
|
|
26
|
+
ngio/images/_ome_zarr_container.py,sha256=YheAO5nGRdZv_FT-ue-wJ0Cjz2aWhR4aIkJGo-tXgcE,49262
|
|
27
27
|
ngio/images/_table_ops.py,sha256=jFv_AMqoB4JBpoWsMtZppZVW7dAOC_u-JpfNm8b33kY,15292
|
|
28
28
|
ngio/io_pipes/__init__.py,sha256=arW_7GWzZs82kPNKdm_6B1sIDFV0lWwp-ZaORr9Q1FQ,2412
|
|
29
29
|
ngio/io_pipes/_io_pipes.py,sha256=l85mmjj1l0uYU3qzsSHg9l8cMIEevInm_MTD-8MlXgw,10603
|
|
@@ -47,10 +47,10 @@ ngio/ome_zarr_meta/ngio_specs/_ngio_image.py,sha256=g32ytm4jxDR5duHyO6_kU0MrcE2N
|
|
|
47
47
|
ngio/ome_zarr_meta/ngio_specs/_pixel_size.py,sha256=4VF1djY9T5tp6GCJXppFrUJwALI1XgIm0imoM5rNvdE,3876
|
|
48
48
|
ngio/ome_zarr_meta/v04/__init__.py,sha256=tRt3zGelL948EoLfy_gW-LKvJcBbSkbT9kwIgU0hQV8,721
|
|
49
49
|
ngio/ome_zarr_meta/v04/_custom_models.py,sha256=5GxiDERvLuvq4QvApcA6EiKLS6hLFX1R0R_9rSaa85A,530
|
|
50
|
-
ngio/ome_zarr_meta/v04/_v04_spec.py,sha256=
|
|
50
|
+
ngio/ome_zarr_meta/v04/_v04_spec.py,sha256=W8XPtMhDUuISPpwT41dZDMSSUCtdgLhTWJPj1WqJ7i0,15389
|
|
51
51
|
ngio/ome_zarr_meta/v05/__init__.py,sha256=B6VIUkrm5W4lcrvy4R7c7NZ6dEx-0a1AhqhZ7snCnCo,721
|
|
52
52
|
ngio/ome_zarr_meta/v05/_custom_models.py,sha256=ZN3bE9nwx4y3tElhsYafI4S2zp_WzdkQKcyuuBiaXXo,530
|
|
53
|
-
ngio/ome_zarr_meta/v05/_v05_spec.py,sha256=
|
|
53
|
+
ngio/ome_zarr_meta/v05/_v05_spec.py,sha256=avix0AIcRS143gKTb_C8Ab2BOhRU7tKlWdwj9jy6XTw,16312
|
|
54
54
|
ngio/resources/__init__.py,sha256=4E4TXTNYEgRHt26C1XcC4pPobJJsmZRYm1Ml4uAuAkE,1664
|
|
55
55
|
ngio/resources/resource_model.py,sha256=eE1m0dyk-2psPC4X8Ifyan524QHUOd52TEQdvoU0m8I,861
|
|
56
56
|
ngio/resources/20200812-CardiomyocyteDifferentiation14-Cycle1_B03/mask.png,sha256=g3QmxQdmeciAtBe5cTCRfR6yw3keG9cBYfjizMo6EGo,11890
|
|
@@ -82,7 +82,7 @@ ngio/utils/_datasets.py,sha256=YOV367skFA8nbKAqbyK0EsUU7E9UId_u5ButuLesrzk,5896
|
|
|
82
82
|
ngio/utils/_errors.py,sha256=pKQ12LUjQLYE1nUawemA5h7HsgznjaSvV1n2PQU33N0,759
|
|
83
83
|
ngio/utils/_fractal_fsspec_store.py,sha256=RdcCFOgHexRKX9zZvJV5RI-5OPc7VOPS6q_IeRxm24I,1548
|
|
84
84
|
ngio/utils/_zarr_utils.py,sha256=MVbW-a0S3iuzMaknqkliJa_lp8i6mEO4Q2YN2XxmeDw,18158
|
|
85
|
-
ngio-0.5.
|
|
86
|
-
ngio-0.5.
|
|
87
|
-
ngio-0.5.
|
|
88
|
-
ngio-0.5.
|
|
85
|
+
ngio-0.5.0b7.dist-info/METADATA,sha256=LRMT4aboyJ5z66FSJvBwrXkFxEz2YTX7Diu340KSc8Y,6382
|
|
86
|
+
ngio-0.5.0b7.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
87
|
+
ngio-0.5.0b7.dist-info/licenses/LICENSE,sha256=UgN_a1QCeNh9rZWfz-wORQFxE3elQzLWPQaoK6N6fxQ,1502
|
|
88
|
+
ngio-0.5.0b7.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|