mlarray 0.0.45__tar.gz → 0.0.47__tar.gz
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.
- {mlarray-0.0.45 → mlarray-0.0.47}/PKG-INFO +24 -12
- {mlarray-0.0.45 → mlarray-0.0.47}/README.md +23 -11
- {mlarray-0.0.45 → mlarray-0.0.47}/docs/optimization.md +10 -7
- {mlarray-0.0.45 → mlarray-0.0.47}/docs/usage.md +24 -11
- {mlarray-0.0.45 → mlarray-0.0.47}/examples/example_asarray.py +1 -1
- {mlarray-0.0.45 → mlarray-0.0.47}/examples/example_non_spatial.py +2 -2
- {mlarray-0.0.45 → mlarray-0.0.47}/mlarray/mlarray.py +672 -697
- {mlarray-0.0.45 → mlarray-0.0.47}/mlarray.egg-info/PKG-INFO +24 -12
- {mlarray-0.0.45 → mlarray-0.0.47}/tests/test_asarray.py +10 -17
- {mlarray-0.0.45 → mlarray-0.0.47}/tests/test_constructors.py +3 -4
- {mlarray-0.0.45 → mlarray-0.0.47}/tests/test_optimization.py +7 -7
- {mlarray-0.0.45 → mlarray-0.0.47}/tests/test_usage.py +5 -5
- {mlarray-0.0.45 → mlarray-0.0.47}/.github/workflows/workflow.yml +0 -0
- {mlarray-0.0.45 → mlarray-0.0.47}/.gitignore +0 -0
- {mlarray-0.0.45 → mlarray-0.0.47}/LICENSE +0 -0
- {mlarray-0.0.45 → mlarray-0.0.47}/MANIFEST.in +0 -0
- {mlarray-0.0.45 → mlarray-0.0.47}/assets/banner.png +0 -0
- {mlarray-0.0.45 → mlarray-0.0.47}/assets/banner.png~ +0 -0
- {mlarray-0.0.45 → mlarray-0.0.47}/docs/api.md +0 -0
- {mlarray-0.0.45 → mlarray-0.0.47}/docs/cli.md +0 -0
- {mlarray-0.0.45 → mlarray-0.0.47}/docs/index.md +0 -0
- {mlarray-0.0.45 → mlarray-0.0.47}/docs/schema.md +0 -0
- {mlarray-0.0.45 → mlarray-0.0.47}/docs/why.md +0 -0
- {mlarray-0.0.45 → mlarray-0.0.47}/examples/example_bboxes_only.py +0 -0
- {mlarray-0.0.45 → mlarray-0.0.47}/examples/example_channel.py +0 -0
- {mlarray-0.0.45 → mlarray-0.0.47}/examples/example_in_memory_constructors.py +0 -0
- {mlarray-0.0.45 → mlarray-0.0.47}/examples/example_metadata_only.py +0 -0
- {mlarray-0.0.45 → mlarray-0.0.47}/examples/example_open.py +0 -0
- {mlarray-0.0.45 → mlarray-0.0.47}/examples/example_save_load.py +0 -0
- {mlarray-0.0.45 → mlarray-0.0.47}/mkdocs.yml +0 -0
- {mlarray-0.0.45 → mlarray-0.0.47}/mlarray/__init__.py +0 -0
- {mlarray-0.0.45 → mlarray-0.0.47}/mlarray/cli.py +0 -0
- {mlarray-0.0.45 → mlarray-0.0.47}/mlarray/meta.py +0 -0
- {mlarray-0.0.45 → mlarray-0.0.47}/mlarray/utils.py +0 -0
- {mlarray-0.0.45 → mlarray-0.0.47}/mlarray.egg-info/SOURCES.txt +0 -0
- {mlarray-0.0.45 → mlarray-0.0.47}/mlarray.egg-info/dependency_links.txt +0 -0
- {mlarray-0.0.45 → mlarray-0.0.47}/mlarray.egg-info/entry_points.txt +0 -0
- {mlarray-0.0.45 → mlarray-0.0.47}/mlarray.egg-info/requires.txt +0 -0
- {mlarray-0.0.45 → mlarray-0.0.47}/mlarray.egg-info/top_level.txt +0 -0
- {mlarray-0.0.45 → mlarray-0.0.47}/pyproject.toml +0 -0
- {mlarray-0.0.45 → mlarray-0.0.47}/setup.cfg +0 -0
- {mlarray-0.0.45 → mlarray-0.0.47}/tests/test_bboxes.py +0 -0
- {mlarray-0.0.45 → mlarray-0.0.47}/tests/test_create.py +0 -0
- {mlarray-0.0.45 → mlarray-0.0.47}/tests/test_metadata.py +0 -0
- {mlarray-0.0.45 → mlarray-0.0.47}/tests/test_open.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mlarray
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.47
|
|
4
4
|
Summary: Array format specialized for Machine Learning with Blosc2 backend and standardized metadata.
|
|
5
5
|
Author-email: Karol Gotkowski <karol.gotkowski@dkfz.de>
|
|
6
6
|
License: MIT
|
|
@@ -174,42 +174,54 @@ Default patch size (192):
|
|
|
174
174
|
```python
|
|
175
175
|
from mlarray import MLArray
|
|
176
176
|
|
|
177
|
-
image = MLArray("sample.mla")
|
|
178
|
-
image.save("default-patch.mla") #
|
|
179
|
-
|
|
177
|
+
image = MLArray("sample.mla") # Existing file
|
|
178
|
+
image.save("default-patch.mla") # Keeps existing layout metadata
|
|
179
|
+
|
|
180
|
+
loaded = MLArray("sample.mla")
|
|
181
|
+
image = MLArray(loaded.to_numpy(), patch_size='default')
|
|
182
|
+
image.save("default-patch-relayout.mla") # Uses constructor patch_size='default' (192)
|
|
180
183
|
```
|
|
181
184
|
|
|
182
185
|
Custom isotropic patch size (512):
|
|
183
186
|
```python
|
|
184
187
|
from mlarray import MLArray
|
|
185
188
|
|
|
186
|
-
|
|
187
|
-
image.
|
|
189
|
+
loaded = MLArray("sample.mla")
|
|
190
|
+
image = MLArray(loaded.to_numpy(), patch_size=512)
|
|
191
|
+
image.save("patch-512.mla")
|
|
188
192
|
```
|
|
189
193
|
|
|
190
194
|
Custom non-isotropic patch size:
|
|
191
195
|
```python
|
|
192
196
|
from mlarray import MLArray
|
|
193
197
|
|
|
194
|
-
|
|
195
|
-
image.
|
|
198
|
+
loaded = MLArray("sample.mla")
|
|
199
|
+
image = MLArray(loaded.to_numpy(), patch_size=(128, 192, 256))
|
|
200
|
+
image.save("patch-non-iso.mla")
|
|
196
201
|
```
|
|
197
202
|
|
|
198
203
|
Manual chunk/block size:
|
|
199
204
|
```python
|
|
200
205
|
from mlarray import MLArray
|
|
201
206
|
|
|
202
|
-
|
|
203
|
-
image
|
|
207
|
+
loaded = MLArray("sample.mla")
|
|
208
|
+
image = MLArray(
|
|
209
|
+
loaded.to_numpy(),
|
|
210
|
+
patch_size=None,
|
|
211
|
+
chunk_size=(1, 128, 128),
|
|
212
|
+
block_size=(1, 32, 32),
|
|
213
|
+
)
|
|
214
|
+
image.save("manual-chunk-block.mla")
|
|
204
215
|
```
|
|
205
216
|
|
|
206
217
|
Let Blosc2 itself configure chunk/block size:
|
|
207
218
|
```python
|
|
208
219
|
from mlarray import MLArray
|
|
209
220
|
|
|
210
|
-
|
|
221
|
+
loaded = MLArray("sample.mla")
|
|
222
|
+
image = MLArray(loaded.to_numpy(), patch_size=None)
|
|
211
223
|
# If patch_size, chunk_size and block_size are all None, Blosc2 will auto-configure chunk and block size
|
|
212
|
-
image.save("
|
|
224
|
+
image.save("blosc2-auto.mla")
|
|
213
225
|
```
|
|
214
226
|
|
|
215
227
|
## CLI
|
|
@@ -140,42 +140,54 @@ Default patch size (192):
|
|
|
140
140
|
```python
|
|
141
141
|
from mlarray import MLArray
|
|
142
142
|
|
|
143
|
-
image = MLArray("sample.mla")
|
|
144
|
-
image.save("default-patch.mla") #
|
|
145
|
-
|
|
143
|
+
image = MLArray("sample.mla") # Existing file
|
|
144
|
+
image.save("default-patch.mla") # Keeps existing layout metadata
|
|
145
|
+
|
|
146
|
+
loaded = MLArray("sample.mla")
|
|
147
|
+
image = MLArray(loaded.to_numpy(), patch_size='default')
|
|
148
|
+
image.save("default-patch-relayout.mla") # Uses constructor patch_size='default' (192)
|
|
146
149
|
```
|
|
147
150
|
|
|
148
151
|
Custom isotropic patch size (512):
|
|
149
152
|
```python
|
|
150
153
|
from mlarray import MLArray
|
|
151
154
|
|
|
152
|
-
|
|
153
|
-
image.
|
|
155
|
+
loaded = MLArray("sample.mla")
|
|
156
|
+
image = MLArray(loaded.to_numpy(), patch_size=512)
|
|
157
|
+
image.save("patch-512.mla")
|
|
154
158
|
```
|
|
155
159
|
|
|
156
160
|
Custom non-isotropic patch size:
|
|
157
161
|
```python
|
|
158
162
|
from mlarray import MLArray
|
|
159
163
|
|
|
160
|
-
|
|
161
|
-
image.
|
|
164
|
+
loaded = MLArray("sample.mla")
|
|
165
|
+
image = MLArray(loaded.to_numpy(), patch_size=(128, 192, 256))
|
|
166
|
+
image.save("patch-non-iso.mla")
|
|
162
167
|
```
|
|
163
168
|
|
|
164
169
|
Manual chunk/block size:
|
|
165
170
|
```python
|
|
166
171
|
from mlarray import MLArray
|
|
167
172
|
|
|
168
|
-
|
|
169
|
-
image
|
|
173
|
+
loaded = MLArray("sample.mla")
|
|
174
|
+
image = MLArray(
|
|
175
|
+
loaded.to_numpy(),
|
|
176
|
+
patch_size=None,
|
|
177
|
+
chunk_size=(1, 128, 128),
|
|
178
|
+
block_size=(1, 32, 32),
|
|
179
|
+
)
|
|
180
|
+
image.save("manual-chunk-block.mla")
|
|
170
181
|
```
|
|
171
182
|
|
|
172
183
|
Let Blosc2 itself configure chunk/block size:
|
|
173
184
|
```python
|
|
174
185
|
from mlarray import MLArray
|
|
175
186
|
|
|
176
|
-
|
|
187
|
+
loaded = MLArray("sample.mla")
|
|
188
|
+
image = MLArray(loaded.to_numpy(), patch_size=None)
|
|
177
189
|
# If patch_size, chunk_size and block_size are all None, Blosc2 will auto-configure chunk and block size
|
|
178
|
-
image.save("
|
|
190
|
+
image.save("blosc2-auto.mla")
|
|
179
191
|
```
|
|
180
192
|
|
|
181
193
|
## CLI
|
|
@@ -75,10 +75,10 @@ import numpy as np
|
|
|
75
75
|
from mlarray import MLArray
|
|
76
76
|
|
|
77
77
|
array = np.random.random((128, 256, 256))
|
|
78
|
-
image = MLArray(array)
|
|
78
|
+
image = MLArray(array, patch_size=(128, 192, 256))
|
|
79
79
|
|
|
80
80
|
# Optimize storage layout for 3D patches of 128×192×256 (spatial axes)
|
|
81
|
-
image.save("patch-non-iso.mla"
|
|
81
|
+
image.save("patch-non-iso.mla")
|
|
82
82
|
```
|
|
83
83
|
|
|
84
84
|
When to use:
|
|
@@ -164,12 +164,14 @@ If you already know what you’re doing (or want to reproduce a very specific la
|
|
|
164
164
|
```python
|
|
165
165
|
from mlarray import MLArray
|
|
166
166
|
|
|
167
|
-
|
|
168
|
-
image
|
|
169
|
-
|
|
167
|
+
loaded = MLArray("sample.mla")
|
|
168
|
+
image = MLArray(
|
|
169
|
+
loaded.to_numpy(),
|
|
170
|
+
patch_size=None,
|
|
170
171
|
chunk_size=(1, 128, 128),
|
|
171
172
|
block_size=(1, 32, 32),
|
|
172
173
|
)
|
|
174
|
+
image.save("manual-layout.mla")
|
|
173
175
|
```
|
|
174
176
|
|
|
175
177
|
When to use:
|
|
@@ -186,10 +188,11 @@ If you set `patch_size=None` (and don’t provide chunk/block sizes), Blosc2 wil
|
|
|
186
188
|
```python
|
|
187
189
|
from mlarray import MLArray
|
|
188
190
|
|
|
189
|
-
|
|
191
|
+
loaded = MLArray("sample.mla")
|
|
192
|
+
image = MLArray(loaded.to_numpy(), patch_size=None)
|
|
190
193
|
|
|
191
194
|
# If patch_size, chunk_size and block_size are all None, Blosc2 auto-configures
|
|
192
|
-
image.save("blosc2-auto.mla"
|
|
195
|
+
image.save("blosc2-auto.mla")
|
|
193
196
|
```
|
|
194
197
|
|
|
195
198
|
When to use:
|
|
@@ -156,11 +156,12 @@ image = MLArray(
|
|
|
156
156
|
spacing=(2.5, 0.7, 0.7), # spatial axes only (z, y, x)
|
|
157
157
|
origin=(0.0, 0.0, 0.0),
|
|
158
158
|
axis_labels=axis_labels,
|
|
159
|
+
patch_size=None,
|
|
159
160
|
)
|
|
160
161
|
|
|
161
162
|
# Optional per-axis units (length = full array ndims)
|
|
162
163
|
image.meta.spatial.axis_units = ["s", "mm", "mm", "mm", ""]
|
|
163
|
-
image.save("time-series.mla"
|
|
164
|
+
image.save("time-series.mla")
|
|
164
165
|
```
|
|
165
166
|
|
|
166
167
|
|
|
@@ -177,8 +178,11 @@ Uses the default patch configuration, optimized for typical ML patch-based acces
|
|
|
177
178
|
from mlarray import MLArray
|
|
178
179
|
|
|
179
180
|
image = MLArray("sample.mla")
|
|
180
|
-
image.save("default-patch.mla") #
|
|
181
|
-
|
|
181
|
+
image.save("default-patch.mla") # Keeps existing layout metadata
|
|
182
|
+
|
|
183
|
+
loaded = MLArray("sample.mla")
|
|
184
|
+
image = MLArray(loaded.to_numpy(), patch_size='default')
|
|
185
|
+
image.save("default-patch-relayout.mla") # Uses constructor patch_size='default' (192)
|
|
182
186
|
```
|
|
183
187
|
|
|
184
188
|
### Custom isotropic patch size (512)
|
|
@@ -188,8 +192,9 @@ A larger patch size can improve throughput when you typically load large regions
|
|
|
188
192
|
```python
|
|
189
193
|
from mlarray import MLArray
|
|
190
194
|
|
|
191
|
-
|
|
192
|
-
image.
|
|
195
|
+
loaded = MLArray("sample.mla")
|
|
196
|
+
image = MLArray(loaded.to_numpy(), patch_size=512)
|
|
197
|
+
image.save("patch-512.mla")
|
|
193
198
|
```
|
|
194
199
|
|
|
195
200
|
### Custom non-isotropic patch size
|
|
@@ -199,8 +204,9 @@ Non-isotropic patches are useful when one axis behaves differently (e.g., fewer
|
|
|
199
204
|
```python
|
|
200
205
|
from mlarray import MLArray
|
|
201
206
|
|
|
202
|
-
|
|
203
|
-
image.
|
|
207
|
+
loaded = MLArray("sample.mla")
|
|
208
|
+
image = MLArray(loaded.to_numpy(), patch_size=(128, 192, 256))
|
|
209
|
+
image.save("patch-non-iso.mla")
|
|
204
210
|
```
|
|
205
211
|
|
|
206
212
|
### Manual chunk/block size
|
|
@@ -210,8 +216,14 @@ For advanced use cases, you can explicitly define the chunk and block size used
|
|
|
210
216
|
```python
|
|
211
217
|
from mlarray import MLArray
|
|
212
218
|
|
|
213
|
-
|
|
214
|
-
image
|
|
219
|
+
loaded = MLArray("sample.mla")
|
|
220
|
+
image = MLArray(
|
|
221
|
+
loaded.to_numpy(),
|
|
222
|
+
patch_size=None,
|
|
223
|
+
chunk_size=(1, 128, 128),
|
|
224
|
+
block_size=(1, 32, 32),
|
|
225
|
+
)
|
|
226
|
+
image.save("manual-chunk-block.mla")
|
|
215
227
|
```
|
|
216
228
|
|
|
217
229
|
### Let Blosc2 itself configure chunk/block size
|
|
@@ -221,7 +233,8 @@ If you disable MLArray patch sizing, Blosc2 can choose chunk and block sizes aut
|
|
|
221
233
|
```python
|
|
222
234
|
from mlarray import MLArray
|
|
223
235
|
|
|
224
|
-
|
|
236
|
+
loaded = MLArray("sample.mla")
|
|
237
|
+
image = MLArray(loaded.to_numpy(), patch_size=None)
|
|
225
238
|
# If patch_size, chunk_size and block_size are all None, Blosc2 will auto-configure chunk and block size
|
|
226
|
-
image.save("
|
|
239
|
+
image.save("blosc2-auto.mla")
|
|
227
240
|
```
|
|
@@ -69,7 +69,7 @@ if __name__ == "__main__":
|
|
|
69
69
|
|
|
70
70
|
# Convert to in-memory compressed MLArray.
|
|
71
71
|
start_time = time.time()
|
|
72
|
-
image = MLArray.asarray(array
|
|
72
|
+
image = MLArray.asarray(array)
|
|
73
73
|
print("MLArray conversion duration: ", time.time() - start_time)
|
|
74
74
|
rss_after_compressed = get_process_rss_bytes()
|
|
75
75
|
|
|
@@ -27,10 +27,10 @@ if __name__ == '__main__':
|
|
|
27
27
|
os.remove(filepath)
|
|
28
28
|
|
|
29
29
|
print("Initializing image...")
|
|
30
|
-
image = MLArray(array, spacing=spacing, origin=origin, direction=direction, axis_labels=axis_labels, meta=Meta(source=source_meta, bbox=MetaBbox(bboxes)))
|
|
30
|
+
image = MLArray(array, spacing=spacing, origin=origin, direction=direction, axis_labels=axis_labels, meta=Meta(source=source_meta, bbox=MetaBbox(bboxes)), patch_size=None)
|
|
31
31
|
image.meta.spatial.axis_units = ["s", "mm", "mm", "mm", ""]
|
|
32
32
|
print("Saving image...")
|
|
33
|
-
image.save(filepath
|
|
33
|
+
image.save(filepath)
|
|
34
34
|
|
|
35
35
|
print("Loading image...")
|
|
36
36
|
image = MLArray(filepath)
|