ngio 0.3.4__py3-none-any.whl → 0.4.0__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 +7 -2
- ngio/common/__init__.py +5 -52
- ngio/common/_dimensions.py +270 -55
- ngio/common/_masking_roi.py +38 -10
- ngio/common/_pyramid.py +51 -30
- ngio/common/_roi.py +269 -82
- ngio/common/_synt_images_utils.py +101 -0
- ngio/common/_zoom.py +49 -19
- 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 +127 -0
- ngio/experimental/iterators/_segmentation.py +235 -0
- ngio/hcs/_plate.py +41 -36
- ngio/images/__init__.py +22 -1
- ngio/images/_abstract_image.py +403 -176
- ngio/images/_create.py +31 -15
- ngio/images/_create_synt_container.py +138 -0
- ngio/images/_image.py +452 -63
- ngio/images/_label.py +56 -30
- ngio/images/_masked_image.py +387 -129
- ngio/images/_ome_zarr_container.py +237 -67
- ngio/{common → images}/_table_ops.py +41 -41
- 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 +152 -0
- ngio/io_pipes/_io_pipes_types.py +56 -0
- ngio/io_pipes/_match_shape.py +376 -0
- ngio/io_pipes/_ops_axes.py +344 -0
- ngio/io_pipes/_ops_slices.py +446 -0
- ngio/io_pipes/_ops_slices_utils.py +196 -0
- ngio/io_pipes/_ops_transforms.py +104 -0
- ngio/io_pipes/_zoom_transform.py +175 -0
- ngio/ome_zarr_meta/__init__.py +4 -2
- ngio/ome_zarr_meta/ngio_specs/__init__.py +4 -10
- ngio/ome_zarr_meta/ngio_specs/_axes.py +186 -175
- ngio/ome_zarr_meta/ngio_specs/_channels.py +55 -18
- ngio/ome_zarr_meta/ngio_specs/_dataset.py +48 -122
- ngio/ome_zarr_meta/ngio_specs/_ngio_hcs.py +6 -15
- ngio/ome_zarr_meta/ngio_specs/_ngio_image.py +38 -87
- ngio/ome_zarr_meta/ngio_specs/_pixel_size.py +17 -1
- ngio/ome_zarr_meta/v04/_v04_spec_utils.py +34 -31
- 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/backends/_abstract_backend.py +5 -6
- ngio/tables/backends/_anndata.py +1 -2
- ngio/tables/backends/_anndata_utils.py +3 -3
- ngio/tables/backends/_non_zarr_backends.py +1 -1
- ngio/tables/backends/_table_backends.py +0 -1
- ngio/tables/backends/_utils.py +3 -3
- ngio/tables/v1/_roi_table.py +165 -70
- ngio/transforms/__init__.py +5 -0
- ngio/transforms/_zoom.py +19 -0
- ngio/utils/__init__.py +2 -3
- ngio/utils/_datasets.py +5 -0
- ngio/utils/_logger.py +19 -0
- ngio/utils/_zarr_utils.py +6 -6
- {ngio-0.3.4.dist-info → ngio-0.4.0.dist-info}/METADATA +24 -22
- ngio-0.4.0.dist-info/RECORD +85 -0
- ngio/common/_array_pipe.py +0 -288
- ngio/common/_axes_transforms.py +0 -64
- ngio/common/_common_types.py +0 -5
- ngio/common/_slicer.py +0 -96
- ngio-0.3.4.dist-info/RECORD +0 -61
- {ngio-0.3.4.dist-info → ngio-0.4.0.dist-info}/WHEEL +0 -0
- {ngio-0.3.4.dist-info → ngio-0.4.0.dist-info}/licenses/LICENSE +0 -0
ngio/utils/_zarr_utils.py
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"""Common utilities for working with Zarr groups in consistent ways."""
|
|
2
2
|
|
|
3
|
-
# %%
|
|
4
3
|
from pathlib import Path
|
|
5
4
|
from typing import Literal
|
|
6
5
|
|
|
@@ -9,6 +8,7 @@ import zarr
|
|
|
9
8
|
from filelock import BaseFileLock, FileLock
|
|
10
9
|
from zarr.errors import ContainsGroupError, GroupNotFoundError
|
|
11
10
|
from zarr.storage import DirectoryStore, FSStore, MemoryStore, Store, StoreLike
|
|
11
|
+
from zarr.types import DIMENSION_SEPARATOR
|
|
12
12
|
|
|
13
13
|
from ngio.utils import NgioFileExistsError, NgioFileNotFoundError, NgioValueError
|
|
14
14
|
from ngio.utils._errors import NgioError
|
|
@@ -164,7 +164,7 @@ class ZarrGroupHandler:
|
|
|
164
164
|
@property
|
|
165
165
|
def mode(self) -> AccessModeLiteral:
|
|
166
166
|
"""Return the mode of the group."""
|
|
167
|
-
return self._mode # type: ignore
|
|
167
|
+
return self._mode # type: ignore (return type is Literal)
|
|
168
168
|
|
|
169
169
|
@property
|
|
170
170
|
def lock(self) -> BaseFileLock:
|
|
@@ -343,6 +343,8 @@ class ZarrGroupHandler:
|
|
|
343
343
|
shape: tuple[int, ...],
|
|
344
344
|
dtype: str,
|
|
345
345
|
chunks: tuple[int, ...] | None = None,
|
|
346
|
+
dimension_separator: DIMENSION_SEPARATOR = "/",
|
|
347
|
+
compressor: str = "default",
|
|
346
348
|
overwrite: bool = False,
|
|
347
349
|
) -> zarr.Array:
|
|
348
350
|
if self.mode == "r":
|
|
@@ -354,7 +356,8 @@ class ZarrGroupHandler:
|
|
|
354
356
|
shape=shape,
|
|
355
357
|
dtype=dtype,
|
|
356
358
|
chunks=chunks,
|
|
357
|
-
dimension_separator=
|
|
359
|
+
dimension_separator=dimension_separator,
|
|
360
|
+
compressor=compressor,
|
|
358
361
|
overwrite=overwrite,
|
|
359
362
|
)
|
|
360
363
|
except ContainsGroupError as e:
|
|
@@ -410,6 +413,3 @@ class ZarrGroupHandler:
|
|
|
410
413
|
f"Error copying group to {handler.full_url}, "
|
|
411
414
|
f"#{n_skipped} files where skipped."
|
|
412
415
|
)
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
# %%
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ngio
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: Next Generation file format IO
|
|
5
|
-
Project-URL: homepage, https://github.com/
|
|
6
|
-
Project-URL: repository, https://github.com/
|
|
5
|
+
Project-URL: homepage, https://github.com/BioVisionCenter/ngio
|
|
6
|
+
Project-URL: repository, https://github.com/BioVisionCenter/ngio
|
|
7
7
|
Author-email: Lorenzo Cerrone <lorenzo.cerrone@uzh.ch>
|
|
8
8
|
License: BSD-3-Clause
|
|
9
9
|
License-File: LICENSE
|
|
@@ -16,7 +16,7 @@ Classifier: Programming Language :: Python :: 3.13
|
|
|
16
16
|
Classifier: Typing :: Typed
|
|
17
17
|
Requires-Python: <3.14,>=3.11
|
|
18
18
|
Requires-Dist: aiohttp
|
|
19
|
-
Requires-Dist: anndata
|
|
19
|
+
Requires-Dist: anndata<0.11.4,>=0.8.0
|
|
20
20
|
Requires-Dist: dask[array]
|
|
21
21
|
Requires-Dist: dask[distributed]
|
|
22
22
|
Requires-Dist: filelock
|
|
@@ -28,7 +28,6 @@ Requires-Dist: pooch
|
|
|
28
28
|
Requires-Dist: pyarrow
|
|
29
29
|
Requires-Dist: pydantic
|
|
30
30
|
Requires-Dist: requests
|
|
31
|
-
Requires-Dist: xarray
|
|
32
31
|
Requires-Dist: zarr<3
|
|
33
32
|
Provides-Extra: dev
|
|
34
33
|
Requires-Dist: devtools; extra == 'dev'
|
|
@@ -38,11 +37,13 @@ Requires-Dist: napari; extra == 'dev'
|
|
|
38
37
|
Requires-Dist: notebook; extra == 'dev'
|
|
39
38
|
Requires-Dist: pdbpp; extra == 'dev'
|
|
40
39
|
Requires-Dist: pre-commit; extra == 'dev'
|
|
40
|
+
Requires-Dist: pympler; extra == 'dev'
|
|
41
41
|
Requires-Dist: pyqt5; extra == 'dev'
|
|
42
42
|
Requires-Dist: rich; extra == 'dev'
|
|
43
43
|
Requires-Dist: ruff; extra == 'dev'
|
|
44
44
|
Requires-Dist: scikit-image; extra == 'dev'
|
|
45
45
|
Provides-Extra: docs
|
|
46
|
+
Requires-Dist: griffe-typingdoc; extra == 'docs'
|
|
46
47
|
Requires-Dist: markdown-exec[ansi]; extra == 'docs'
|
|
47
48
|
Requires-Dist: matplotlib; extra == 'docs'
|
|
48
49
|
Requires-Dist: mike; extra == 'docs'
|
|
@@ -65,11 +66,11 @@ Description-Content-Type: text/markdown
|
|
|
65
66
|
|
|
66
67
|
# Ngio - Next Generation file format IO
|
|
67
68
|
|
|
68
|
-
[](https://github.com/
|
|
69
|
+
[](https://github.com/BioVisionCenter/ngio/raw/main/LICENSE)
|
|
69
70
|
[](https://pypi.org/project/ngio)
|
|
70
71
|
[](https://python.org)
|
|
71
|
-
[](https://github.com/BioVisionCenter/ngio/actions/workflows/ci.yml)
|
|
73
|
+
[](https://codecov.io/gh/BioVisionCenter/ngio)
|
|
73
74
|
|
|
74
75
|
ngio is a Python library designed to simplify bioimage analysis workflows, offering an intuitive interface for working with OME-Zarr files.
|
|
75
76
|
|
|
@@ -81,20 +82,22 @@ Ngio's mission is to streamline working with OME-Zarr files by providing a simpl
|
|
|
81
82
|
|
|
82
83
|
## Key Features
|
|
83
84
|
|
|
84
|
-
###
|
|
85
|
+
### 🔍 Simple Object-Based API
|
|
85
86
|
|
|
86
87
|
- Easily open, explore, and manipulate OME-Zarr images and HCS plates
|
|
87
88
|
- Create and derive new images and labels with minimal boilerplate code
|
|
88
89
|
|
|
89
|
-
###
|
|
90
|
+
### 📊 Rich Tables and Regions of Interest (ROI) Support
|
|
90
91
|
|
|
92
|
+
- Tight integration with [tabular data](https://biovisioncenter.github.io/ngio/stable/table_specs/overview/)
|
|
91
93
|
- Extract and analyze specific regions of interest
|
|
92
|
-
-
|
|
94
|
+
- Store measurements and other metadata in the OME-Zarr container
|
|
95
|
+
- Extensible & modular allowing users to define custom table schemas and on disk serialization
|
|
93
96
|
|
|
94
|
-
### 🔄 Scalable Data Processing
|
|
97
|
+
### 🔄 Scalable Data Processing
|
|
95
98
|
|
|
96
|
-
- Powerful iterators for
|
|
97
|
-
-
|
|
99
|
+
- Powerful iterators for building scalable and generalizable image processing pipelines
|
|
100
|
+
- Extensible mapping mechanism for custom parallelization strategies
|
|
98
101
|
|
|
99
102
|
## Installation
|
|
100
103
|
|
|
@@ -104,7 +107,7 @@ You can install ngio via pip:
|
|
|
104
107
|
pip install ngio
|
|
105
108
|
```
|
|
106
109
|
|
|
107
|
-
To get started check out the [Quickstart Guide](https://
|
|
110
|
+
To get started check out the [Quickstart Guide](https://BioVisionCenter.github.io/ngio/stable/getting_started/0_quickstart/).
|
|
108
111
|
|
|
109
112
|
## Supported OME-Zarr versions
|
|
110
113
|
|
|
@@ -112,23 +115,22 @@ Currently, ngio only supports OME-Zarr v0.4. Support for version 0.5 and higher
|
|
|
112
115
|
|
|
113
116
|
## Development Status
|
|
114
117
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
We follow [Semantic Versioning](https://semver.org/). Which means for 0.x releases potentially breaking changes can be introduced in minor releases.
|
|
118
|
+
Ngio is under active development and is not yet stable. The API is subject to change, and bugs and breaking changes are expected.
|
|
119
|
+
We follow [Semantic Versioning](https://semver.org/). Which means for 0.x releases potentially breaking changes can be introduced in minor releases.
|
|
118
120
|
|
|
119
121
|
### Available Features
|
|
120
122
|
|
|
121
123
|
- ✅ OME-Zarr metadata handling and validation
|
|
122
124
|
- ✅ Image and label access across pyramid levels
|
|
123
125
|
- ✅ ROI and table support
|
|
126
|
+
- ✅ Image processing iterators
|
|
124
127
|
- ✅ Streaming from remote sources
|
|
125
128
|
- ✅ Documentation and examples
|
|
126
129
|
|
|
127
130
|
### Upcoming Features
|
|
128
131
|
|
|
129
|
-
-
|
|
130
|
-
-
|
|
131
|
-
- Support for OME-Zarr v0.5 and Zarr v3
|
|
132
|
+
- Support for OME-Zarr v0.5 and Zarr v3 (via `zarr-python` v3)
|
|
133
|
+
- Enhanced performance optimizations (parallel iterators, optimized io strategies)
|
|
132
134
|
|
|
133
135
|
## Contributors
|
|
134
136
|
|
|
@@ -136,4 +138,4 @@ Ngio is developed at the [BioVisionCenter](https://www.biovisioncenter.uzh.ch/en
|
|
|
136
138
|
|
|
137
139
|
## License
|
|
138
140
|
|
|
139
|
-
Ngio is released under the BSD-3-Clause License. See [LICENSE](https://github.com/
|
|
141
|
+
Ngio is released under the BSD-3-Clause License. See [LICENSE](https://github.com/BioVisionCenter/ngio/blob/main/LICENSE) for details.
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
ngio/__init__.py,sha256=rEgnXuU6TCejUUGsxt4eKmjMhxjYh0fYBxWF4o5YjbE,1435
|
|
2
|
+
ngio/common/__init__.py,sha256=aPSuUbdGryrxbnlWrsVNe3LZoBAWC4GijR1BNH1UwuU,612
|
|
3
|
+
ngio/common/_dimensions.py,sha256=w8PYgyWxA8hgJETjFbw5CXf7WrasCL5FbzgfL1in86M,11361
|
|
4
|
+
ngio/common/_masking_roi.py,sha256=ZZTXordEZoq_ADk0OzADvq-5dPOwUBSuNobzFR8fpTw,5697
|
|
5
|
+
ngio/common/_pyramid.py,sha256=F5OI_mULxzMTpMeihC4Y22cjuB5GKN2jRdpwfMXJHiE,8018
|
|
6
|
+
ngio/common/_roi.py,sha256=DFI2BJdJ-JNC5uZARxlvL25ZYHb9HJhCP-sOID_Db20,10196
|
|
7
|
+
ngio/common/_synt_images_utils.py,sha256=B6uYOW1NyrM06YMR-csca3_YnAAkPRTbvnbLdy9tk9E,3188
|
|
8
|
+
ngio/common/_zoom.py,sha256=U01c-vqXjzZkrpd9Yvs24frVfTls_xPJeeaFCGmUwYI,6727
|
|
9
|
+
ngio/experimental/__init__.py,sha256=3pmBtHi-i8bKjTsvrOJM56ZyRX3Pv_dceCdt88-8COQ,147
|
|
10
|
+
ngio/experimental/iterators/__init__.py,sha256=TECOMGb5PEEZ0yXxt8pqIGvLKG41g_L1fTJU-zGPeV8,488
|
|
11
|
+
ngio/experimental/iterators/_abstract_iterator.py,sha256=7aAoMI-6vYGCMKxO3M10WpuBMTdqX4zr0K-TutAOp88,13195
|
|
12
|
+
ngio/experimental/iterators/_feature.py,sha256=g03yHIzYpTVeD3KUq2a4TwX29Dt48XaaGdZNSykYy7M,6749
|
|
13
|
+
ngio/experimental/iterators/_image_processing.py,sha256=cM7sL7xgdcjSOKAu-6367Aov89o6wgiJ_wqCGkU2Bsw,5091
|
|
14
|
+
ngio/experimental/iterators/_mappers.py,sha256=VVVsjems57wJUnWeufUFcgqa23k7VPeFL4Nc04HVw4o,1399
|
|
15
|
+
ngio/experimental/iterators/_rois_utils.py,sha256=Q-8lQ26neYn63h_RvfypYqvrq2UUN2O3xqVe57k_ufU,4363
|
|
16
|
+
ngio/experimental/iterators/_segmentation.py,sha256=xzotGvTn04HPeMeXZ_URnQqWco6d2lH6Ng6vkCUh9NM,9153
|
|
17
|
+
ngio/hcs/__init__.py,sha256=G8j9vD-liLeB_UeGtKYIgshWvJnUA6ks9GwjvWBLdHs,357
|
|
18
|
+
ngio/hcs/_plate.py,sha256=qfRwbCKaoz_AWTi8RDFFwOxy5geSknfJrPcqFVno9zI,44288
|
|
19
|
+
ngio/images/__init__.py,sha256=9Whvt7GTiCgT_vXaEEqGnDaY1-UsRk3dhLTv091F_g4,1211
|
|
20
|
+
ngio/images/_abstract_image.py,sha256=hrB9xn4MFRxnxE1d7HKnM8SXVPUGhMD9u32yBHTsFiU,18517
|
|
21
|
+
ngio/images/_create.py,sha256=61cuco2jUK25WzOY-Sel9s931FtGPL2ut25L9W10bJ4,10171
|
|
22
|
+
ngio/images/_create_synt_container.py,sha256=il_rr5_2KIQ5Xsskj2rb2fEm100ZErZq89aW06kn_7k,5444
|
|
23
|
+
ngio/images/_image.py,sha256=1WQOI26ITn1R2raR9JWVEhp6nKBE3ntXXAQr7EMTOEo,33054
|
|
24
|
+
ngio/images/_label.py,sha256=RIfXrLSKMQ-j8q-aaSiWeIwFEKdxAkQT1HbJNq4PJv0,11800
|
|
25
|
+
ngio/images/_masked_image.py,sha256=YhbBzgPZMav6rX0WYue1BaxAzEIsfaQrxUIOK6ZWZcw,18848
|
|
26
|
+
ngio/images/_ome_zarr_container.py,sha256=UJERXEgBkwclpLaHzWqUIQc6P-TG4zYuKuxPukJGa4Y,38433
|
|
27
|
+
ngio/images/_table_ops.py,sha256=jFv_AMqoB4JBpoWsMtZppZVW7dAOC_u-JpfNm8b33kY,15292
|
|
28
|
+
ngio/io_pipes/__init__.py,sha256=arW_7GWzZs82kPNKdm_6B1sIDFV0lWwp-ZaORr9Q1FQ,2412
|
|
29
|
+
ngio/io_pipes/_io_pipes.py,sha256=KuwMYofE11EKx0iplWXBQZ-eE1A9YpGDprWh98cUlAI,10710
|
|
30
|
+
ngio/io_pipes/_io_pipes_masked.py,sha256=077j1XNgyCNOHlOsbjPOWcLtb2ccFvbLp-cPzWL1j3c,16999
|
|
31
|
+
ngio/io_pipes/_io_pipes_roi.py,sha256=E_t3Lb5JD6zgsIok2w98xKks_6vhLIfaKDJIf2J95sA,4809
|
|
32
|
+
ngio/io_pipes/_io_pipes_types.py,sha256=xCeUd9rZe2wsgoZR1pUq6L4LSeawoPsb-9pmz5C6ztA,1393
|
|
33
|
+
ngio/io_pipes/_match_shape.py,sha256=eDy_Eqzld08m9zDuIjAvJnIhWh_HVjQS-5Pw9BMjdbw,13200
|
|
34
|
+
ngio/io_pipes/_ops_axes.py,sha256=Geg4ZXxB0njWWopX9YeiwRJJ9Ef2GKfG0NIUafOmi2c,10043
|
|
35
|
+
ngio/io_pipes/_ops_slices.py,sha256=7wBXucmIOW0a1r9MzEVevPOEefyhS27-yhaF8aeyD6Y,15804
|
|
36
|
+
ngio/io_pipes/_ops_slices_utils.py,sha256=mKbAEccwsQjg6XyyJ5Ph5Xr9z6pUUCO3tZ4Yal-wYMs,6590
|
|
37
|
+
ngio/io_pipes/_ops_transforms.py,sha256=uITs6v6sZ7DQ_Hpw3JdX8MuPOzir-bihvGzY84Qn4wY,2934
|
|
38
|
+
ngio/io_pipes/_zoom_transform.py,sha256=bUeFTeGUbz3Io4uArqyHXkvLZmuKsOri1lvMhDXWchA,6716
|
|
39
|
+
ngio/ome_zarr_meta/__init__.py,sha256=tzxW2oVhfeMBVuv3XkcbOLzMnbDvUnie-AVsvSxRkdE,1265
|
|
40
|
+
ngio/ome_zarr_meta/_meta_handlers.py,sha256=ctknNDT8jxwyvxQf9on5gW31H1tRRsnneO38GT2UXoE,25880
|
|
41
|
+
ngio/ome_zarr_meta/ngio_specs/__init__.py,sha256=U2FqZR91Ob2N6CqKdyw-_Ll-wMgmGuPZGVRCr6wuRFY,1698
|
|
42
|
+
ngio/ome_zarr_meta/ngio_specs/_axes.py,sha256=gNzxCddn53m9dlNJlV5CL-aQS-nGJrbCDGfAp5L97LY,16412
|
|
43
|
+
ngio/ome_zarr_meta/ngio_specs/_channels.py,sha256=CVsbG52U31TaMdTj8XqvClUdBya2Ar3qBjDo_xhP-NM,16967
|
|
44
|
+
ngio/ome_zarr_meta/ngio_specs/_dataset.py,sha256=CrHnjVWBGYPqErKkHR-E2DKrE3DmGznXMkd3Y9Z4uYo,3434
|
|
45
|
+
ngio/ome_zarr_meta/ngio_specs/_ngio_hcs.py,sha256=N1CGPOubwf0pvm8tiTnh-C1cOu9lToyDe3WagnEnPN4,17207
|
|
46
|
+
ngio/ome_zarr_meta/ngio_specs/_ngio_image.py,sha256=XmqeffYRspBZmv8gCrfJvnykmBViWgDo2AtJJkR7OEs,15886
|
|
47
|
+
ngio/ome_zarr_meta/ngio_specs/_pixel_size.py,sha256=SofMjLERvCxqP-ACxqyTEwYYAPeq0hjxt8Ujn4OZhZY,4656
|
|
48
|
+
ngio/ome_zarr_meta/v04/__init__.py,sha256=dJRzzxyYc81kf-0Hip_bqvbdManaM8XTdQX2meWyCSs,583
|
|
49
|
+
ngio/ome_zarr_meta/v04/_custom_models.py,sha256=5GxiDERvLuvq4QvApcA6EiKLS6hLFX1R0R_9rSaa85A,530
|
|
50
|
+
ngio/ome_zarr_meta/v04/_v04_spec_utils.py,sha256=OFMAKYvjhgCRhN_RNs8mJmOtyFHuw3k-lqOOrTRXvzU,15764
|
|
51
|
+
ngio/resources/__init__.py,sha256=4E4TXTNYEgRHt26C1XcC4pPobJJsmZRYm1Ml4uAuAkE,1664
|
|
52
|
+
ngio/resources/resource_model.py,sha256=eE1m0dyk-2psPC4X8Ifyan524QHUOd52TEQdvoU0m8I,861
|
|
53
|
+
ngio/resources/20200812-CardiomyocyteDifferentiation14-Cycle1_B03/mask.png,sha256=g3QmxQdmeciAtBe5cTCRfR6yw3keG9cBYfjizMo6EGo,11890
|
|
54
|
+
ngio/resources/20200812-CardiomyocyteDifferentiation14-Cycle1_B03/nuclei.png,sha256=Yw0k5pn2EHDMWTwyb7N51NX7WVk6-MlwfP9WZrhY-Ic,19446
|
|
55
|
+
ngio/resources/20200812-CardiomyocyteDifferentiation14-Cycle1_B03/raw.jpg,sha256=82lejQAIokj5w9g-qqhysDTWpHtNvJTkdURG_BjqIxQ,37743
|
|
56
|
+
ngio/tables/__init__.py,sha256=_BV3sclNMLITu_J8_3DkkUrCB6Kro0HzeWLDCD1ivKM,877
|
|
57
|
+
ngio/tables/_abstract_table.py,sha256=rwGa47TzbFmosucBWVfFq6JEXtgGvOdUVtU9DIelV88,8204
|
|
58
|
+
ngio/tables/_tables_container.py,sha256=3xmpREaN671l40MPprnl1BD-VoOb6xfjECb5mNoMW0w,12173
|
|
59
|
+
ngio/tables/backends/__init__.py,sha256=MwSRXNF1rWQBFOTDA_vT3oGoNZpviVgytsL5Txnu08I,1619
|
|
60
|
+
ngio/tables/backends/_abstract_backend.py,sha256=54Vh9yPfLx1NixGVfFkW4msD51nsim0zIfHRnO80Xt8,7276
|
|
61
|
+
ngio/tables/backends/_anndata.py,sha256=97RWG4Hjc42JBxm-YxjHEU8HHd14NiayelKlI1PTsCo,2868
|
|
62
|
+
ngio/tables/backends/_anndata_utils.py,sha256=HsmP27fm7JW1kjahl4lUnnViK_iqmu2bnsu86z43U98,3116
|
|
63
|
+
ngio/tables/backends/_csv.py,sha256=Ev61D-AUKo4LIhXRmWPJgYbHI7eQdxiajQR574DevEM,932
|
|
64
|
+
ngio/tables/backends/_json.py,sha256=1ZsEuXDJm1rOZV_KjFm8CB0qhv7L1W7L2EGWPf4q_p0,3137
|
|
65
|
+
ngio/tables/backends/_non_zarr_backends.py,sha256=BybUl800pqCdqJJmsGnUi4jsH1ibpQSUl0ZnumkFDwY,7298
|
|
66
|
+
ngio/tables/backends/_parquet.py,sha256=ic-p86h8lce8q9luBJGRzy6vxlWyJvA0-2l5cUD6OqY,1398
|
|
67
|
+
ngio/tables/backends/_table_backends.py,sha256=ksP2NAosXZkNMZf-IMrLx7bjQgp_eKfvPYK4vMdT1A8,7250
|
|
68
|
+
ngio/tables/backends/_utils.py,sha256=YFB7u2_l8lLAK_jrmlSfzH-2sOAFaDP1bmeUfuNo7YM,19719
|
|
69
|
+
ngio/tables/v1/__init__.py,sha256=Wr1_9RZFpaN8FYMTnxT9Yjkw4AS7y9FMWailmB_uj5g,617
|
|
70
|
+
ngio/tables/v1/_condition_table.py,sha256=T0Uq5BKkmMoEspt_Rx0U99Ow6S9GAMZDHqvUO5obCAM,1780
|
|
71
|
+
ngio/tables/v1/_feature_table.py,sha256=n9uMHwoBh-_dlOhUXCFbmAjXFVXncNCR3SjE2qzXI68,3821
|
|
72
|
+
ngio/tables/v1/_generic_table.py,sha256=1ktJHeuv7U1g5Z8PFUuTkCjOzcYMQd8xegKHKUedJB8,1240
|
|
73
|
+
ngio/tables/v1/_roi_table.py,sha256=g7UpMmpf3uAfaG59WYRnimUBgiB_T1qUJRwMZpMt9cI,17099
|
|
74
|
+
ngio/transforms/__init__.py,sha256=JA0-Ui7skbXkm9ofN-AEhU1FTLutkMkwTdVD-310frQ,113
|
|
75
|
+
ngio/transforms/_zoom.py,sha256=otyE-vxFnywUJ8U4mHjat-bNG_7_jv62ckTpqDMxyVQ,550
|
|
76
|
+
ngio/utils/__init__.py,sha256=XPYh8ehC7uXNU2cFFXZAw-S3DpWpX1Yq2xGkffZv5vI,1142
|
|
77
|
+
ngio/utils/_datasets.py,sha256=6GtxfPkjutNaeg5BHuJDBP0GudvQXHLU6mmHp_o0bGA,5650
|
|
78
|
+
ngio/utils/_errors.py,sha256=pKQ12LUjQLYE1nUawemA5h7HsgznjaSvV1n2PQU33N0,759
|
|
79
|
+
ngio/utils/_fractal_fsspec_store.py,sha256=RdcCFOgHexRKX9zZvJV5RI-5OPc7VOPS6q_IeRxm24I,1548
|
|
80
|
+
ngio/utils/_logger.py,sha256=N5W0a_xwze4blS1MolidBkTMbjTbg8GPguJZNun3mAE,1392
|
|
81
|
+
ngio/utils/_zarr_utils.py,sha256=GUOcAx02IcfrJ5tIdKu8ChtRUUaBbkkddW5jaCCYnS8,13797
|
|
82
|
+
ngio-0.4.0.dist-info/METADATA,sha256=30FPHkdQVkhZFWp3mlJc2CJPnAZdqFAyXWW36aQ085c,6095
|
|
83
|
+
ngio-0.4.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
84
|
+
ngio-0.4.0.dist-info/licenses/LICENSE,sha256=UgN_a1QCeNh9rZWfz-wORQFxE3elQzLWPQaoK6N6fxQ,1502
|
|
85
|
+
ngio-0.4.0.dist-info/RECORD,,
|
ngio/common/_array_pipe.py
DELETED
|
@@ -1,288 +0,0 @@
|
|
|
1
|
-
from collections.abc import Collection, Iterable
|
|
2
|
-
from typing import Literal
|
|
3
|
-
|
|
4
|
-
import dask.array as da
|
|
5
|
-
import numpy as np
|
|
6
|
-
import zarr
|
|
7
|
-
from dask.array import Array as DaskArray
|
|
8
|
-
from dask.delayed import Delayed, delayed
|
|
9
|
-
|
|
10
|
-
from ngio.common._axes_transforms import transform_dask_array, transform_numpy_array
|
|
11
|
-
from ngio.common._common_types import ArrayLike
|
|
12
|
-
from ngio.common._dimensions import Dimensions
|
|
13
|
-
from ngio.common._slicer import (
|
|
14
|
-
SliceTransform,
|
|
15
|
-
compute_and_slices,
|
|
16
|
-
dask_get_slice,
|
|
17
|
-
dask_set_slice,
|
|
18
|
-
numpy_get_slice,
|
|
19
|
-
numpy_set_slice,
|
|
20
|
-
)
|
|
21
|
-
from ngio.ome_zarr_meta.ngio_specs import AxesTransformation
|
|
22
|
-
from ngio.utils import NgioValueError
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
def _compute_from_disk_transforms(
|
|
26
|
-
*,
|
|
27
|
-
dimensions: Dimensions,
|
|
28
|
-
axes_order: Collection[str] | None = None,
|
|
29
|
-
**slice_kwargs: slice | int | Iterable[int],
|
|
30
|
-
) -> tuple[SliceTransform, tuple[AxesTransformation, ...]]:
|
|
31
|
-
slices = compute_and_slices(dimensions=dimensions, **slice_kwargs)
|
|
32
|
-
|
|
33
|
-
if axes_order is None:
|
|
34
|
-
return slices, ()
|
|
35
|
-
|
|
36
|
-
additional_transformations = dimensions._axes_mapper.to_order(axes_order)
|
|
37
|
-
return slices, additional_transformations
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
def _compute_to_disk_transforms(
|
|
41
|
-
*,
|
|
42
|
-
dimensions: Dimensions,
|
|
43
|
-
axes_order: Collection[str] | None = None,
|
|
44
|
-
**slice_kwargs: slice | int | Iterable[int],
|
|
45
|
-
) -> tuple[SliceTransform, tuple[AxesTransformation, ...]]:
|
|
46
|
-
slices = compute_and_slices(dimensions=dimensions, **slice_kwargs)
|
|
47
|
-
if axes_order is None:
|
|
48
|
-
return slices, ()
|
|
49
|
-
|
|
50
|
-
additional_transformations = dimensions._axes_mapper.from_order(axes_order)
|
|
51
|
-
return slices, additional_transformations
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
def _numpy_get_pipe(
|
|
55
|
-
array: zarr.Array,
|
|
56
|
-
slices: SliceTransform,
|
|
57
|
-
transformations: tuple[AxesTransformation, ...],
|
|
58
|
-
) -> np.ndarray:
|
|
59
|
-
_array = numpy_get_slice(array, slices)
|
|
60
|
-
return transform_numpy_array(_array, transformations)
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
def _delayed_numpy_get_pipe(
|
|
64
|
-
array: zarr.Array,
|
|
65
|
-
slices: SliceTransform,
|
|
66
|
-
transformations: tuple[AxesTransformation, ...],
|
|
67
|
-
) -> Delayed:
|
|
68
|
-
_array = delayed(numpy_get_slice)(array, slices)
|
|
69
|
-
return delayed(transform_numpy_array)(_array, transformations)
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
def _dask_get_pipe(
|
|
73
|
-
array: zarr.Array,
|
|
74
|
-
slices: SliceTransform,
|
|
75
|
-
transformations: tuple[AxesTransformation, ...],
|
|
76
|
-
) -> DaskArray:
|
|
77
|
-
_array = dask_get_slice(array, slices)
|
|
78
|
-
return transform_dask_array(_array, transformations)
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
def _numpy_set_pipe(
|
|
82
|
-
array: zarr.Array,
|
|
83
|
-
patch: np.ndarray,
|
|
84
|
-
slices: SliceTransform,
|
|
85
|
-
transformations: tuple[AxesTransformation, ...],
|
|
86
|
-
) -> None:
|
|
87
|
-
patch = transform_numpy_array(patch, transformations)
|
|
88
|
-
numpy_set_slice(array, patch, slices)
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
def _dask_set_pipe(
|
|
92
|
-
array: zarr.Array,
|
|
93
|
-
patch: DaskArray,
|
|
94
|
-
slices: SliceTransform,
|
|
95
|
-
transformations: tuple[AxesTransformation, ...],
|
|
96
|
-
) -> None:
|
|
97
|
-
_patch = transform_dask_array(patch, transformations)
|
|
98
|
-
dask_set_slice(array, _patch, slices)
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
def _delayed_numpy_set_pipe(
|
|
102
|
-
array: zarr.Array,
|
|
103
|
-
patch: np.ndarray | Delayed,
|
|
104
|
-
slices: SliceTransform,
|
|
105
|
-
transformations: tuple[AxesTransformation, ...],
|
|
106
|
-
) -> Delayed:
|
|
107
|
-
_patch = delayed(transform_numpy_array)(patch, transformations)
|
|
108
|
-
return delayed(numpy_set_slice)(array, _patch, slices)
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
def get_pipe(
|
|
112
|
-
array: zarr.Array,
|
|
113
|
-
*,
|
|
114
|
-
dimensions: Dimensions,
|
|
115
|
-
axes_order: Collection[str] | None = None,
|
|
116
|
-
mode: Literal["numpy", "dask", "delayed"] = "numpy",
|
|
117
|
-
**slice_kwargs: slice | int | Iterable[int],
|
|
118
|
-
):
|
|
119
|
-
slices, transformations = _compute_from_disk_transforms(
|
|
120
|
-
dimensions=dimensions, axes_order=axes_order, **slice_kwargs
|
|
121
|
-
)
|
|
122
|
-
match mode:
|
|
123
|
-
case "numpy":
|
|
124
|
-
return _numpy_get_pipe(array, slices, transformations)
|
|
125
|
-
case "dask":
|
|
126
|
-
return _dask_get_pipe(array, slices, transformations)
|
|
127
|
-
|
|
128
|
-
case "delayed":
|
|
129
|
-
return _delayed_numpy_get_pipe(array, slices, transformations)
|
|
130
|
-
|
|
131
|
-
case _:
|
|
132
|
-
raise NgioValueError(
|
|
133
|
-
f"Unknown get pipe mode {mode}, expected 'numpy', 'dask' or 'delayed'."
|
|
134
|
-
)
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
def set_pipe(
|
|
138
|
-
array: zarr.Array,
|
|
139
|
-
patch: ArrayLike,
|
|
140
|
-
*,
|
|
141
|
-
dimensions: Dimensions,
|
|
142
|
-
axes_order: Collection[str] | None = None,
|
|
143
|
-
**slice_kwargs: slice | int | Iterable[int],
|
|
144
|
-
):
|
|
145
|
-
slices, transformations = _compute_to_disk_transforms(
|
|
146
|
-
dimensions=dimensions, axes_order=axes_order, **slice_kwargs
|
|
147
|
-
)
|
|
148
|
-
if isinstance(patch, DaskArray):
|
|
149
|
-
_dask_set_pipe(
|
|
150
|
-
array=array, patch=patch, slices=slices, transformations=transformations
|
|
151
|
-
)
|
|
152
|
-
elif isinstance(patch, np.ndarray):
|
|
153
|
-
_numpy_set_pipe(
|
|
154
|
-
array=array, patch=patch, slices=slices, transformations=transformations
|
|
155
|
-
)
|
|
156
|
-
elif isinstance(patch, Delayed):
|
|
157
|
-
_delayed_numpy_set_pipe(
|
|
158
|
-
array=array, patch=patch, slices=slices, transformations=transformations
|
|
159
|
-
)
|
|
160
|
-
else:
|
|
161
|
-
raise NgioValueError("Unknown patch type, expected numpy, dask or delayed.")
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
def _mask_pipe_common(
|
|
165
|
-
array: zarr.Array,
|
|
166
|
-
label_array: zarr.Array,
|
|
167
|
-
label: int,
|
|
168
|
-
*,
|
|
169
|
-
dimensions_array: Dimensions,
|
|
170
|
-
dimensions_label: Dimensions,
|
|
171
|
-
axes_order: Collection[str] | None = None,
|
|
172
|
-
mode: Literal["numpy", "dask", "delayed"] = "numpy",
|
|
173
|
-
**slice_kwargs: slice | int | Iterable[int],
|
|
174
|
-
):
|
|
175
|
-
array_patch = get_pipe(
|
|
176
|
-
array,
|
|
177
|
-
dimensions=dimensions_array,
|
|
178
|
-
axes_order=axes_order,
|
|
179
|
-
mode=mode,
|
|
180
|
-
**slice_kwargs,
|
|
181
|
-
)
|
|
182
|
-
|
|
183
|
-
if not dimensions_label.has_axis("c"):
|
|
184
|
-
# Remove the 'c' from the slice_kwargs
|
|
185
|
-
# This will not work if the query uses non-default
|
|
186
|
-
# axes names for channel
|
|
187
|
-
slice_kwargs = {k: v for k, v in slice_kwargs.items() if k != "c"}
|
|
188
|
-
|
|
189
|
-
label_patch = get_pipe(
|
|
190
|
-
label_array,
|
|
191
|
-
dimensions=dimensions_label,
|
|
192
|
-
axes_order=axes_order,
|
|
193
|
-
mode=mode,
|
|
194
|
-
**slice_kwargs,
|
|
195
|
-
)
|
|
196
|
-
|
|
197
|
-
if isinstance(array_patch, np.ndarray) and isinstance(label_patch, np.ndarray):
|
|
198
|
-
label_patch = np.broadcast_to(label_patch, array_patch.shape)
|
|
199
|
-
elif isinstance(array_patch, DaskArray) and isinstance(label_patch, DaskArray):
|
|
200
|
-
label_patch = da.broadcast_to(label_patch, array_patch.shape)
|
|
201
|
-
else:
|
|
202
|
-
raise NgioValueError(
|
|
203
|
-
"Incompatible types for array and label: "
|
|
204
|
-
f"{type(array_patch)} and {type(label_patch)}"
|
|
205
|
-
)
|
|
206
|
-
|
|
207
|
-
mask = label_patch == label
|
|
208
|
-
return array_patch, mask
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
def get_masked_pipe(
|
|
212
|
-
array: zarr.Array,
|
|
213
|
-
label_array: zarr.Array,
|
|
214
|
-
label: int,
|
|
215
|
-
*,
|
|
216
|
-
dimensions_array: Dimensions,
|
|
217
|
-
dimensions_label: Dimensions,
|
|
218
|
-
axes_order: Collection[str] | None = None,
|
|
219
|
-
mode: Literal["numpy", "dask", "delayed"] = "numpy",
|
|
220
|
-
**slice_kwargs: slice | int | Iterable[int],
|
|
221
|
-
):
|
|
222
|
-
array_patch, mask = _mask_pipe_common(
|
|
223
|
-
array=array,
|
|
224
|
-
label_array=label_array,
|
|
225
|
-
label=label,
|
|
226
|
-
dimensions_array=dimensions_array,
|
|
227
|
-
dimensions_label=dimensions_label,
|
|
228
|
-
axes_order=axes_order,
|
|
229
|
-
mode=mode,
|
|
230
|
-
**slice_kwargs,
|
|
231
|
-
)
|
|
232
|
-
if isinstance(array_patch, np.ndarray):
|
|
233
|
-
array_patch[~mask] = 0
|
|
234
|
-
elif isinstance(array_patch, DaskArray):
|
|
235
|
-
array_patch = da.where(mask, array_patch, 0)
|
|
236
|
-
else:
|
|
237
|
-
raise NgioValueError(
|
|
238
|
-
"Mode not yet supported for masked array. Expected a numpy or dask array."
|
|
239
|
-
)
|
|
240
|
-
return array_patch
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
def set_masked_pipe(
|
|
244
|
-
array: zarr.Array,
|
|
245
|
-
label_array: zarr.Array,
|
|
246
|
-
label: int,
|
|
247
|
-
patch: ArrayLike,
|
|
248
|
-
*,
|
|
249
|
-
dimensions_array: Dimensions,
|
|
250
|
-
dimensions_label: Dimensions,
|
|
251
|
-
axes_order: Collection[str] | None = None,
|
|
252
|
-
**slice_kwargs: slice | int | Iterable[int],
|
|
253
|
-
):
|
|
254
|
-
if isinstance(patch, DaskArray):
|
|
255
|
-
mode = "dask"
|
|
256
|
-
elif isinstance(patch, np.ndarray):
|
|
257
|
-
mode = "numpy"
|
|
258
|
-
else:
|
|
259
|
-
raise NgioValueError(
|
|
260
|
-
"Mode not yet supported for masked array. Expected a numpy or dask array."
|
|
261
|
-
)
|
|
262
|
-
|
|
263
|
-
array_patch, mask = _mask_pipe_common(
|
|
264
|
-
array=array,
|
|
265
|
-
label_array=label_array,
|
|
266
|
-
label=label,
|
|
267
|
-
dimensions_array=dimensions_array,
|
|
268
|
-
dimensions_label=dimensions_label,
|
|
269
|
-
axes_order=axes_order,
|
|
270
|
-
mode=mode,
|
|
271
|
-
**slice_kwargs,
|
|
272
|
-
)
|
|
273
|
-
if isinstance(patch, np.ndarray):
|
|
274
|
-
assert isinstance(array_patch, np.ndarray)
|
|
275
|
-
_patch = np.where(mask, patch, array_patch)
|
|
276
|
-
elif isinstance(patch, DaskArray):
|
|
277
|
-
_patch = da.where(mask, patch, array_patch)
|
|
278
|
-
else:
|
|
279
|
-
raise NgioValueError(
|
|
280
|
-
"Mode not yet supported for masked array. Expected a numpy or dask array."
|
|
281
|
-
)
|
|
282
|
-
set_pipe(
|
|
283
|
-
array,
|
|
284
|
-
_patch,
|
|
285
|
-
dimensions=dimensions_array,
|
|
286
|
-
axes_order=axes_order,
|
|
287
|
-
**slice_kwargs,
|
|
288
|
-
)
|
ngio/common/_axes_transforms.py
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
from typing import TypeVar
|
|
2
|
-
|
|
3
|
-
import dask.array as da
|
|
4
|
-
import numpy as np
|
|
5
|
-
|
|
6
|
-
from ngio.ome_zarr_meta.ngio_specs._axes import (
|
|
7
|
-
AxesExpand,
|
|
8
|
-
AxesSqueeze,
|
|
9
|
-
AxesTransformation,
|
|
10
|
-
AxesTranspose,
|
|
11
|
-
)
|
|
12
|
-
from ngio.utils import NgioValueError
|
|
13
|
-
|
|
14
|
-
T = TypeVar("T")
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
def transform_list(
|
|
18
|
-
input_list: list[T], default: T, operations: tuple[AxesTransformation, ...]
|
|
19
|
-
) -> list[T]:
|
|
20
|
-
if isinstance(input_list, tuple):
|
|
21
|
-
input_list = list(input_list)
|
|
22
|
-
|
|
23
|
-
for operation in operations:
|
|
24
|
-
if isinstance(operation, AxesTranspose):
|
|
25
|
-
input_list = [input_list[i] for i in operation.axes]
|
|
26
|
-
|
|
27
|
-
if isinstance(operation, AxesExpand):
|
|
28
|
-
for ax in operation.axes:
|
|
29
|
-
input_list.insert(ax, default)
|
|
30
|
-
elif isinstance(operation, AxesSqueeze):
|
|
31
|
-
for offset, ax in enumerate(operation.axes):
|
|
32
|
-
input_list.pop(ax - offset)
|
|
33
|
-
|
|
34
|
-
return input_list
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
def transform_numpy_array(
|
|
38
|
-
array: np.ndarray, operations: tuple[AxesTransformation, ...]
|
|
39
|
-
) -> np.ndarray:
|
|
40
|
-
for operation in operations:
|
|
41
|
-
if isinstance(operation, AxesTranspose):
|
|
42
|
-
array = np.transpose(array, operation.axes)
|
|
43
|
-
elif isinstance(operation, AxesExpand):
|
|
44
|
-
array = np.expand_dims(array, axis=operation.axes)
|
|
45
|
-
elif isinstance(operation, AxesSqueeze):
|
|
46
|
-
array = np.squeeze(array, axis=operation.axes)
|
|
47
|
-
else:
|
|
48
|
-
raise NgioValueError(f"Unknown operation {operation}")
|
|
49
|
-
return array
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
def transform_dask_array(
|
|
53
|
-
array: da.Array, operations: tuple[AxesTransformation, ...]
|
|
54
|
-
) -> da.Array:
|
|
55
|
-
for operation in operations:
|
|
56
|
-
if isinstance(operation, AxesTranspose):
|
|
57
|
-
array = da.transpose(array, axes=operation.axes)
|
|
58
|
-
elif isinstance(operation, AxesExpand):
|
|
59
|
-
array = da.expand_dims(array, axis=operation.axes)
|
|
60
|
-
elif isinstance(operation, AxesSqueeze):
|
|
61
|
-
array = da.squeeze(array, axis=operation.axes)
|
|
62
|
-
else:
|
|
63
|
-
raise NgioValueError(f"Unknown operation {operation}")
|
|
64
|
-
return array
|