mlarray 0.0.35__tar.gz → 0.0.37__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 (38) hide show
  1. {mlarray-0.0.35 → mlarray-0.0.37}/PKG-INFO +1 -1
  2. {mlarray-0.0.35 → mlarray-0.0.37}/docs/usage.md +37 -0
  3. mlarray-0.0.37/examples/example_non_spatial.py +42 -0
  4. {mlarray-0.0.35 → mlarray-0.0.37}/mlarray.egg-info/PKG-INFO +1 -1
  5. {mlarray-0.0.35 → mlarray-0.0.37}/mlarray.egg-info/SOURCES.txt +1 -0
  6. {mlarray-0.0.35 → mlarray-0.0.37}/.github/workflows/workflow.yml +0 -0
  7. {mlarray-0.0.35 → mlarray-0.0.37}/.gitignore +0 -0
  8. {mlarray-0.0.35 → mlarray-0.0.37}/LICENSE +0 -0
  9. {mlarray-0.0.35 → mlarray-0.0.37}/MANIFEST.in +0 -0
  10. {mlarray-0.0.35 → mlarray-0.0.37}/README.md +0 -0
  11. {mlarray-0.0.35 → mlarray-0.0.37}/assets/banner.png +0 -0
  12. {mlarray-0.0.35 → mlarray-0.0.37}/assets/banner.png~ +0 -0
  13. {mlarray-0.0.35 → mlarray-0.0.37}/docs/api.md +0 -0
  14. {mlarray-0.0.35 → mlarray-0.0.37}/docs/cli.md +0 -0
  15. {mlarray-0.0.35 → mlarray-0.0.37}/docs/index.md +0 -0
  16. {mlarray-0.0.35 → mlarray-0.0.37}/docs/optimization.md +0 -0
  17. {mlarray-0.0.35 → mlarray-0.0.37}/docs/schema.md +0 -0
  18. {mlarray-0.0.35 → mlarray-0.0.37}/docs/why.md +0 -0
  19. {mlarray-0.0.35 → mlarray-0.0.37}/examples/example_channel.py +0 -0
  20. {mlarray-0.0.35 → mlarray-0.0.37}/examples/example_metadata_only.py +0 -0
  21. {mlarray-0.0.35 → mlarray-0.0.37}/examples/example_open.py +0 -0
  22. {mlarray-0.0.35 → mlarray-0.0.37}/examples/example_save_load.py +0 -0
  23. {mlarray-0.0.35 → mlarray-0.0.37}/mkdocs.yml +0 -0
  24. {mlarray-0.0.35 → mlarray-0.0.37}/mlarray/__init__.py +0 -0
  25. {mlarray-0.0.35 → mlarray-0.0.37}/mlarray/cli.py +0 -0
  26. {mlarray-0.0.35 → mlarray-0.0.37}/mlarray/meta.py +0 -0
  27. {mlarray-0.0.35 → mlarray-0.0.37}/mlarray/mlarray.py +0 -0
  28. {mlarray-0.0.35 → mlarray-0.0.37}/mlarray/utils.py +0 -0
  29. {mlarray-0.0.35 → mlarray-0.0.37}/mlarray.egg-info/dependency_links.txt +0 -0
  30. {mlarray-0.0.35 → mlarray-0.0.37}/mlarray.egg-info/entry_points.txt +0 -0
  31. {mlarray-0.0.35 → mlarray-0.0.37}/mlarray.egg-info/requires.txt +0 -0
  32. {mlarray-0.0.35 → mlarray-0.0.37}/mlarray.egg-info/top_level.txt +0 -0
  33. {mlarray-0.0.35 → mlarray-0.0.37}/pyproject.toml +0 -0
  34. {mlarray-0.0.35 → mlarray-0.0.37}/setup.cfg +0 -0
  35. {mlarray-0.0.35 → mlarray-0.0.37}/tests/test_bboxes.py +0 -0
  36. {mlarray-0.0.35 → mlarray-0.0.37}/tests/test_metadata.py +0 -0
  37. {mlarray-0.0.35 → mlarray-0.0.37}/tests/test_optimization.py +0 -0
  38. {mlarray-0.0.35 → mlarray-0.0.37}/tests/test_usage.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mlarray
3
- Version: 0.0.35
3
+ Version: 0.0.37
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
@@ -128,6 +128,43 @@ image.save("with-metadata.mla")
128
128
 
129
129
  ---
130
130
 
131
+ ## Non-spatial data usage
132
+
133
+ Use `axis_labels` to mark which axes are spatial and which are non-spatial
134
+ (channels, temporal, components, etc.). Spatial metadata (`spacing`, `origin`,
135
+ `direction`) is specified only for the spatial axes, while the full array shape
136
+ includes both spatial and non-spatial axes.
137
+
138
+ ```python
139
+ import numpy as np
140
+ from mlarray import MLArray, MetaSpatial
141
+
142
+ # Example shape: (time, z, y, x, channels)
143
+ array = np.random.random((2, 6, 4, 4, 3, 2))
144
+
145
+ axis_labels = [
146
+ MetaSpatial.AxisLabel.temporal,
147
+ MetaSpatial.AxisLabel.spatial_z,
148
+ MetaSpatial.AxisLabel.spatial_y,
149
+ "spatial_x", # Possible to pass predefined labels as string as well
150
+ MetaSpatial.AxisLabel.channel,
151
+ "some-other-type" # Possible to pass arbitrary strings as well
152
+ ]
153
+
154
+ image = MLArray(
155
+ array,
156
+ spacing=(2.5, 0.7, 0.7), # spatial axes only (z, y, x)
157
+ origin=(0.0, 0.0, 0.0),
158
+ axis_labels=axis_labels,
159
+ )
160
+
161
+ # Optional per-axis units (length = full array ndims)
162
+ image.meta.spatial.axis_units = ["s", "mm", "mm", "mm", ""]
163
+ image.save("time-series.mla", patch_size=None)
164
+ ```
165
+
166
+
167
+
131
168
  ## Patch size variants
132
169
 
133
170
  MLArray stores arrays in a chunked layout to enable efficient partial reads. You can control how data is chunked using `patch_size` (recommended in most cases), or manually specify chunk and block sizes when you need full control.
@@ -0,0 +1,42 @@
1
+ import numpy as np
2
+ import os
3
+ from pathlib import Path
4
+ from mlarray import MLArray, Meta, MetaBbox, MetaSpatial
5
+ import json
6
+
7
+
8
+ if __name__ == '__main__':
9
+ print("Creating array...")
10
+ array = np.random.random((2, 6, 4, 4, 3, 2))
11
+ axis_labels = [
12
+ MetaSpatial.AxisLabel.temporal,
13
+ MetaSpatial.AxisLabel.spatial_z,
14
+ MetaSpatial.AxisLabel.spatial_y,
15
+ "spatial_x", # Possible to pass predefined labels as string as well
16
+ MetaSpatial.AxisLabel.channel,
17
+ "some-other-type" # Possible to pass arbitrary strings as well
18
+ ]
19
+ spacing = np.array((2, 2.5, 4))
20
+ origin = (1, 1, 1)
21
+ direction = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
22
+ source_meta = {"tmp1": "This is an image", "tmp2": 5, "tmp3": {"test1": 16.4587, "test2": [1, 2, 3, 4, 5, 6]}}
23
+ bboxes = [[[0, 1], [0, 1], [0, 1]]]
24
+ filepath = "tmp.mla"
25
+
26
+ if Path(filepath).is_file():
27
+ os.remove(filepath)
28
+
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)))
31
+ image.meta.spatial.axis_units = ["s", "mm", "mm", "mm", ""]
32
+ print("Saving image...")
33
+ image.save(filepath, patch_size=None)
34
+
35
+ print("Loading image...")
36
+ image = MLArray(filepath)
37
+ print(json.dumps(image.meta.to_mapping(), indent=2, sort_keys=True))
38
+ print("Image mean value: ", np.mean(image.to_numpy()))
39
+ print("Some array data: \n", image[:2, :2, 0])
40
+
41
+ if Path(filepath).is_file():
42
+ os.remove(filepath)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mlarray
3
- Version: 0.0.35
3
+ Version: 0.0.37
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
@@ -21,6 +21,7 @@ docs/usage.md
21
21
  docs/why.md
22
22
  examples/example_channel.py
23
23
  examples/example_metadata_only.py
24
+ examples/example_non_spatial.py
24
25
  examples/example_open.py
25
26
  examples/example_save_load.py
26
27
  mlarray/__init__.py
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes