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.
Files changed (45) hide show
  1. {mlarray-0.0.45 → mlarray-0.0.47}/PKG-INFO +24 -12
  2. {mlarray-0.0.45 → mlarray-0.0.47}/README.md +23 -11
  3. {mlarray-0.0.45 → mlarray-0.0.47}/docs/optimization.md +10 -7
  4. {mlarray-0.0.45 → mlarray-0.0.47}/docs/usage.md +24 -11
  5. {mlarray-0.0.45 → mlarray-0.0.47}/examples/example_asarray.py +1 -1
  6. {mlarray-0.0.45 → mlarray-0.0.47}/examples/example_non_spatial.py +2 -2
  7. {mlarray-0.0.45 → mlarray-0.0.47}/mlarray/mlarray.py +672 -697
  8. {mlarray-0.0.45 → mlarray-0.0.47}/mlarray.egg-info/PKG-INFO +24 -12
  9. {mlarray-0.0.45 → mlarray-0.0.47}/tests/test_asarray.py +10 -17
  10. {mlarray-0.0.45 → mlarray-0.0.47}/tests/test_constructors.py +3 -4
  11. {mlarray-0.0.45 → mlarray-0.0.47}/tests/test_optimization.py +7 -7
  12. {mlarray-0.0.45 → mlarray-0.0.47}/tests/test_usage.py +5 -5
  13. {mlarray-0.0.45 → mlarray-0.0.47}/.github/workflows/workflow.yml +0 -0
  14. {mlarray-0.0.45 → mlarray-0.0.47}/.gitignore +0 -0
  15. {mlarray-0.0.45 → mlarray-0.0.47}/LICENSE +0 -0
  16. {mlarray-0.0.45 → mlarray-0.0.47}/MANIFEST.in +0 -0
  17. {mlarray-0.0.45 → mlarray-0.0.47}/assets/banner.png +0 -0
  18. {mlarray-0.0.45 → mlarray-0.0.47}/assets/banner.png~ +0 -0
  19. {mlarray-0.0.45 → mlarray-0.0.47}/docs/api.md +0 -0
  20. {mlarray-0.0.45 → mlarray-0.0.47}/docs/cli.md +0 -0
  21. {mlarray-0.0.45 → mlarray-0.0.47}/docs/index.md +0 -0
  22. {mlarray-0.0.45 → mlarray-0.0.47}/docs/schema.md +0 -0
  23. {mlarray-0.0.45 → mlarray-0.0.47}/docs/why.md +0 -0
  24. {mlarray-0.0.45 → mlarray-0.0.47}/examples/example_bboxes_only.py +0 -0
  25. {mlarray-0.0.45 → mlarray-0.0.47}/examples/example_channel.py +0 -0
  26. {mlarray-0.0.45 → mlarray-0.0.47}/examples/example_in_memory_constructors.py +0 -0
  27. {mlarray-0.0.45 → mlarray-0.0.47}/examples/example_metadata_only.py +0 -0
  28. {mlarray-0.0.45 → mlarray-0.0.47}/examples/example_open.py +0 -0
  29. {mlarray-0.0.45 → mlarray-0.0.47}/examples/example_save_load.py +0 -0
  30. {mlarray-0.0.45 → mlarray-0.0.47}/mkdocs.yml +0 -0
  31. {mlarray-0.0.45 → mlarray-0.0.47}/mlarray/__init__.py +0 -0
  32. {mlarray-0.0.45 → mlarray-0.0.47}/mlarray/cli.py +0 -0
  33. {mlarray-0.0.45 → mlarray-0.0.47}/mlarray/meta.py +0 -0
  34. {mlarray-0.0.45 → mlarray-0.0.47}/mlarray/utils.py +0 -0
  35. {mlarray-0.0.45 → mlarray-0.0.47}/mlarray.egg-info/SOURCES.txt +0 -0
  36. {mlarray-0.0.45 → mlarray-0.0.47}/mlarray.egg-info/dependency_links.txt +0 -0
  37. {mlarray-0.0.45 → mlarray-0.0.47}/mlarray.egg-info/entry_points.txt +0 -0
  38. {mlarray-0.0.45 → mlarray-0.0.47}/mlarray.egg-info/requires.txt +0 -0
  39. {mlarray-0.0.45 → mlarray-0.0.47}/mlarray.egg-info/top_level.txt +0 -0
  40. {mlarray-0.0.45 → mlarray-0.0.47}/pyproject.toml +0 -0
  41. {mlarray-0.0.45 → mlarray-0.0.47}/setup.cfg +0 -0
  42. {mlarray-0.0.45 → mlarray-0.0.47}/tests/test_bboxes.py +0 -0
  43. {mlarray-0.0.45 → mlarray-0.0.47}/tests/test_create.py +0 -0
  44. {mlarray-0.0.45 → mlarray-0.0.47}/tests/test_metadata.py +0 -0
  45. {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.45
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") # Default patch_size is 'default' -> Isotropic patch size of 192 pixels
179
- image.save("default-patch.mla", patch_size='default')
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
- image = MLArray("sample.mla")
187
- image.save("patch-512.mla", patch_size=512)
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
- image = MLArray("sample.mla")
195
- image.save("patch-non-iso.mla", patch_size=(128, 192, 256))
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
- image = MLArray("sample.mla")
203
- image.save("manual-chunk-block.mla", chunk_size=(1, 128, 128), block_size=(1, 32, 32))
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
- image = MLArray("sample.mla")
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("manual-chunk-block.mla", patch_size=None)
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") # Default patch_size is 'default' -> Isotropic patch size of 192 pixels
145
- image.save("default-patch.mla", patch_size='default')
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
- image = MLArray("sample.mla")
153
- image.save("patch-512.mla", patch_size=512)
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
- image = MLArray("sample.mla")
161
- image.save("patch-non-iso.mla", patch_size=(128, 192, 256))
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
- image = MLArray("sample.mla")
169
- image.save("manual-chunk-block.mla", chunk_size=(1, 128, 128), block_size=(1, 32, 32))
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
- image = MLArray("sample.mla")
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("manual-chunk-block.mla", patch_size=None)
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", patch_size=(128, 192, 256))
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
- image = MLArray("sample.mla")
168
- image.save(
169
- "manual-layout.mla",
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
- image = MLArray("sample.mla")
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", patch_size=None)
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", patch_size=None)
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") # Default patch_size is 'default' -> Isotropic patch size of 192 pixels
181
- image.save("default-patch.mla", patch_size='default')
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
- image = MLArray("sample.mla")
192
- image.save("patch-512.mla", patch_size=512)
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
- image = MLArray("sample.mla")
203
- image.save("patch-non-iso.mla", patch_size=(128, 192, 256))
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
- image = MLArray("sample.mla")
214
- image.save("manual-chunk-block.mla", chunk_size=(1, 128, 128), block_size=(1, 32, 32))
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
- image = MLArray("sample.mla")
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("manual-chunk-block.mla", patch_size=None)
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, memory_compressed=True)
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, patch_size=None)
33
+ image.save(filepath)
34
34
 
35
35
  print("Loading image...")
36
36
  image = MLArray(filepath)