lvpyioTools 2.7.0__tar.gz → 2.8.1__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.
- {lvpyiotools-2.7.0/src/lvpyioTools.egg-info → lvpyiotools-2.8.1}/PKG-INFO +8 -7
- {lvpyiotools-2.7.0 → lvpyiotools-2.8.1}/README.md +2 -2
- {lvpyiotools-2.7.0 → lvpyiotools-2.8.1}/pyproject.toml +11 -6
- lvpyiotools-2.8.1/src/lvpyioTools/__init__.py +8 -0
- {lvpyiotools-2.7.0 → lvpyiotools-2.8.1}/src/lvpyioTools/attribute.py +1 -1
- {lvpyiotools-2.7.0 → lvpyiotools-2.8.1}/src/lvpyioTools/calibration.py +1 -1
- {lvpyiotools-2.7.0 → lvpyiotools-2.8.1}/src/lvpyioTools/frame.py +11 -11
- lvpyiotools-2.8.1/src/lvpyioTools/scripts/experiment_parser.py +87 -0
- {lvpyiotools-2.7.0 → lvpyiotools-2.8.1}/src/lvpyioTools/scripts/viewer.py +6 -5
- {lvpyiotools-2.7.0 → lvpyiotools-2.8.1}/src/lvpyioTools/set.py +42 -28
- {lvpyiotools-2.7.0 → lvpyiotools-2.8.1}/src/lvpyioTools/setParser.py +20 -9
- {lvpyiotools-2.7.0 → lvpyiotools-2.8.1}/src/lvpyioTools/setProperties.py +13 -12
- lvpyiotools-2.8.1/src/lvpyioTools/utils.py +11 -0
- {lvpyiotools-2.7.0 → lvpyiotools-2.8.1/src/lvpyioTools.egg-info}/PKG-INFO +8 -7
- {lvpyiotools-2.7.0 → lvpyiotools-2.8.1}/src/lvpyioTools.egg-info/SOURCES.txt +2 -0
- {lvpyiotools-2.7.0 → lvpyiotools-2.8.1}/src/lvpyioTools.egg-info/entry_points.txt +1 -0
- lvpyiotools-2.8.1/src/lvpyioTools.egg-info/requires.txt +10 -0
- {lvpyiotools-2.7.0 → lvpyiotools-2.8.1}/src/lvpyioTools.egg-info/top_level.txt +0 -1
- lvpyiotools-2.7.0/src/lvpyioTools/__init__.py +0 -0
- lvpyiotools-2.7.0/src/lvpyioTools.egg-info/requires.txt +0 -9
- {lvpyiotools-2.7.0 → lvpyiotools-2.8.1}/LICENSE +0 -0
- {lvpyiotools-2.7.0 → lvpyiotools-2.8.1}/setup.cfg +0 -0
- {lvpyiotools-2.7.0 → lvpyiotools-2.8.1}/src/lvpyioTools/mask.py +0 -0
- {lvpyiotools-2.7.0 → lvpyiotools-2.8.1}/src/lvpyioTools/stubs/set.py +0 -0
- {lvpyiotools-2.7.0 → lvpyiotools-2.8.1}/src/lvpyioTools/stubs/set.pyi +0 -0
- {lvpyiotools-2.7.0 → lvpyiotools-2.8.1}/src/lvpyioTools.egg-info/dependency_links.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: lvpyioTools
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.8.1
|
|
4
4
|
Summary: A set of tools to handle LabView files and data via the lvpyio library.
|
|
5
5
|
Author-email: SimKDT <simon.cadet79+github@proton.me>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -19,13 +19,14 @@ Classifier: Topic :: Multimedia :: Video :: Display
|
|
|
19
19
|
Requires-Python: >=3.12.3
|
|
20
20
|
Description-Content-Type: text/markdown
|
|
21
21
|
License-File: LICENSE
|
|
22
|
-
Requires-Dist: numpy
|
|
23
|
-
Requires-Dist: matplotlib
|
|
24
|
-
Requires-Dist: Pillow
|
|
22
|
+
Requires-Dist: numpy>=2.5.1
|
|
23
|
+
Requires-Dist: matplotlib>=3.11.1
|
|
24
|
+
Requires-Dist: Pillow>=12.3.0
|
|
25
25
|
Requires-Dist: lvpyio>=1.4.0
|
|
26
|
+
Requires-Dist: rich>=15.0.0
|
|
26
27
|
Provides-Extra: docs
|
|
27
|
-
Requires-Dist: sphinx>=
|
|
28
|
-
Requires-Dist:
|
|
28
|
+
Requires-Dist: sphinx>=9.1.0; extra == "docs"
|
|
29
|
+
Requires-Dist: furo; extra == "docs"
|
|
29
30
|
Requires-Dist: sphinx-autodoc-typehints>=1.23.0; extra == "docs"
|
|
30
31
|
Dynamic: license-file
|
|
31
32
|
|
|
@@ -67,7 +68,7 @@ pip install .
|
|
|
67
68
|
|
|
68
69
|
## Usage
|
|
69
70
|
|
|
70
|
-
You can find the
|
|
71
|
+
You can find the full documentation in [https://simkdt.github.io/lvpyio-tools/](https://simkdt.github.io/lvpyio-tools/).
|
|
71
72
|
|
|
72
73
|
```python
|
|
73
74
|
from pathlib import Path
|
|
@@ -36,7 +36,7 @@ pip install .
|
|
|
36
36
|
|
|
37
37
|
## Usage
|
|
38
38
|
|
|
39
|
-
You can find the
|
|
39
|
+
You can find the full documentation in [https://simkdt.github.io/lvpyio-tools/](https://simkdt.github.io/lvpyio-tools/).
|
|
40
40
|
|
|
41
41
|
```python
|
|
42
42
|
from pathlib import Path
|
|
@@ -60,4 +60,4 @@ make serve
|
|
|
60
60
|
```
|
|
61
61
|
|
|
62
62
|
## License
|
|
63
|
-
See [LICENSE](LICENSE) for details.
|
|
63
|
+
See [LICENSE](LICENSE) for details.
|
|
@@ -3,17 +3,18 @@ name = "lvpyioTools"
|
|
|
3
3
|
description = "A set of tools to handle LabView files and data via the lvpyio library."
|
|
4
4
|
readme = { file = "README.md", content-type = "text/markdown" }
|
|
5
5
|
requires-python = ">=3.12.3"
|
|
6
|
-
version = "2.
|
|
6
|
+
version = "2.8.1"
|
|
7
7
|
license = "MIT"
|
|
8
8
|
license-files = ["LICENSE"]
|
|
9
9
|
authors = [
|
|
10
10
|
{ name = "SimKDT", email = "simon.cadet79+github@proton.me" },
|
|
11
11
|
]
|
|
12
12
|
dependencies = [
|
|
13
|
-
"numpy",
|
|
14
|
-
"matplotlib",
|
|
15
|
-
"Pillow",
|
|
13
|
+
"numpy>=2.5.1",
|
|
14
|
+
"matplotlib>=3.11.1",
|
|
15
|
+
"Pillow>=12.3.0",
|
|
16
16
|
"lvpyio>=1.4.0",
|
|
17
|
+
"rich>=15.0.0",
|
|
17
18
|
]
|
|
18
19
|
classifiers = [
|
|
19
20
|
"Programming Language :: Python :: 3.12",
|
|
@@ -36,10 +37,14 @@ Documentation = "https://simkdt.github.io/lvpyio-tools"
|
|
|
36
37
|
|
|
37
38
|
[project.optional-dependencies]
|
|
38
39
|
docs = [
|
|
39
|
-
"sphinx>=
|
|
40
|
-
"
|
|
40
|
+
"sphinx>=9.1.0",
|
|
41
|
+
"furo",
|
|
41
42
|
"sphinx-autodoc-typehints>=1.23.0",
|
|
42
43
|
]
|
|
43
44
|
|
|
44
45
|
[project.scripts]
|
|
45
46
|
lvpyioShow = "lvpyioTools.scripts.viewer:main"
|
|
47
|
+
lvpyioTree = "lvpyioTools.scripts.experiment_parser:main"
|
|
48
|
+
|
|
49
|
+
[tool.uv]
|
|
50
|
+
package = true
|
|
@@ -85,7 +85,7 @@ class BufferAttribute(StrEnum):
|
|
|
85
85
|
DEV_DATA_TRACE4 = "DevDataTrace4"
|
|
86
86
|
EX_PATH_VALUE_F = "ExPathValue_f"
|
|
87
87
|
LOAD_FILE = "LoadFile"
|
|
88
|
-
"""Source file of the buffer attributes and data. For
|
|
88
|
+
"""Source file of the buffer attributes and data. For ``.im7`` files this is the original ``.im7`` file for example."""
|
|
89
89
|
LOAD_SET = "LoadSet"
|
|
90
90
|
"""Original set file from which this buffer was loaded. The extension (.set) is omitted."""
|
|
91
91
|
LOAD_SET_INDEX = "LoadSetIndex"
|
|
@@ -27,7 +27,7 @@ def get_calibration(calibration_file: Path) -> Scales:
|
|
|
27
27
|
calibration_file (Path): Calibration file in XML format.
|
|
28
28
|
|
|
29
29
|
Returns:
|
|
30
|
-
Scales: A
|
|
30
|
+
Scales: A ``Scales`` object containing the calibration settings for x, y, z, and i axes.
|
|
31
31
|
"""
|
|
32
32
|
# Read and parse the XML file
|
|
33
33
|
tree = ET.parse(calibration_file)
|
|
@@ -85,19 +85,19 @@ class LVFrame():
|
|
|
85
85
|
def scale(self) -> Scales:
|
|
86
86
|
"""
|
|
87
87
|
Read the scale information from the frame, that is a class containing the following attributes:
|
|
88
|
-
-
|
|
89
|
-
-
|
|
90
|
-
-
|
|
91
|
-
-
|
|
88
|
+
- ``x``: The scale in the x-direction (in meters per pixel).
|
|
89
|
+
- ``y``: The scale in the y-direction (in meters per pixel).
|
|
90
|
+
- ``z``: The scale in the z-direction (in meters per pixel).
|
|
91
|
+
- ``i``: The scale in the intensity direction (generally with a slope of 1).
|
|
92
92
|
|
|
93
|
-
Each attributes are
|
|
94
|
-
-
|
|
95
|
-
-
|
|
96
|
-
-
|
|
97
|
-
-
|
|
93
|
+
Each attributes are ``Scale`` objects, which contain the following attributes:
|
|
94
|
+
- ``slope``: The slope of the scale
|
|
95
|
+
- ``offset``: The offset of the scale
|
|
96
|
+
- ``unit``: The unit of the scale (mm, counts, etc.)
|
|
97
|
+
- ``description``: Mostly just empty
|
|
98
98
|
|
|
99
99
|
Returns:
|
|
100
|
-
Scales: A
|
|
100
|
+
Scales: A ``Scales`` object containing the scale information for the frame.
|
|
101
101
|
"""
|
|
102
102
|
return self.frame.scales
|
|
103
103
|
|
|
@@ -109,7 +109,7 @@ class LVFrame():
|
|
|
109
109
|
attribute (FrameAttribute): The attribute to retrieve.
|
|
110
110
|
|
|
111
111
|
Returns:
|
|
112
|
-
Any: The value of the requested attribute, or
|
|
112
|
+
Any: The value of the requested attribute, or ``None`` if the attribute is not found in the frame.
|
|
113
113
|
"""
|
|
114
114
|
return self.frame.attributes.get(attribute.value, None)
|
|
115
115
|
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
r"""
|
|
2
|
+
Experiment set parser
|
|
3
|
+
---------------------
|
|
4
|
+
Shows a children tree hierarchy of the provided set.
|
|
5
|
+
|
|
6
|
+
Usage:
|
|
7
|
+
|
|
8
|
+
.. code-block:: bash
|
|
9
|
+
|
|
10
|
+
lvpyioTree path/to/set/file
|
|
11
|
+
"""
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
from rich import prompt, tree
|
|
14
|
+
from rich import print
|
|
15
|
+
|
|
16
|
+
if __name__ == "__main__":
|
|
17
|
+
import sys
|
|
18
|
+
sys.path.append(str(Path(__file__).parent.parent.parent))
|
|
19
|
+
from lvpyioTools.set import LVSet
|
|
20
|
+
else:
|
|
21
|
+
from ..set import LVSet
|
|
22
|
+
|
|
23
|
+
def make_tree(lvset:LVSet, parents: list[LVSet], children: list[LVSet]):
|
|
24
|
+
# list parents
|
|
25
|
+
parents_with_self = parents + [lvset]
|
|
26
|
+
print(len(parents_with_self))
|
|
27
|
+
top = tree.Tree(f"[bold]{parents_with_self[0].get_name()}[/bold]")
|
|
28
|
+
current = top
|
|
29
|
+
for parent in parents_with_self[1:]:
|
|
30
|
+
current = current.add(f"[bold]{parent.get_name()}[/bold]")
|
|
31
|
+
|
|
32
|
+
# add children
|
|
33
|
+
for i, child in enumerate(children):
|
|
34
|
+
current.add(f"[green]{i}[/green]: {child.get_name()}")
|
|
35
|
+
|
|
36
|
+
return top
|
|
37
|
+
|
|
38
|
+
def recursive_explorer(lv_set: LVSet, parents: list[LVSet] = []):
|
|
39
|
+
children = lv_set.get_children()
|
|
40
|
+
|
|
41
|
+
s = sorted(children, key=lambda c: c.get_name().lower())
|
|
42
|
+
print(make_tree(lv_set, parents, s))
|
|
43
|
+
|
|
44
|
+
if len(children) == 0:
|
|
45
|
+
return None
|
|
46
|
+
|
|
47
|
+
choice = prompt.Prompt.ask("Enter your choice",
|
|
48
|
+
choices=[str(i) for i in range(len(children))])
|
|
49
|
+
choice = int(choice)
|
|
50
|
+
if 0 <= choice < len(children):
|
|
51
|
+
child = children[choice]
|
|
52
|
+
return recursive_explorer(child, parents + [lv_set])
|
|
53
|
+
return None
|
|
54
|
+
|
|
55
|
+
def tree_set(lv_set: LVSet, current: tree.Tree | None = None, depth_max: int | None = None, depth: int | None = None):
|
|
56
|
+
if current is None:
|
|
57
|
+
current = tree.Tree(f"[bold]{lv_set.get_name()}[/bold]")
|
|
58
|
+
if depth is None:
|
|
59
|
+
depth = 1
|
|
60
|
+
|
|
61
|
+
children = lv_set.get_children()
|
|
62
|
+
for i, child in enumerate(children):
|
|
63
|
+
child_tree = current.add(f"[cyan]{child.get_name()}[/cyan]")
|
|
64
|
+
if depth_max is None or depth < depth_max:
|
|
65
|
+
tree_set(child, child_tree, depth_max=depth_max, depth=depth+1)
|
|
66
|
+
|
|
67
|
+
return current
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def main():
|
|
71
|
+
import argparse
|
|
72
|
+
|
|
73
|
+
doc = __doc__.strip() if __doc__ is not None else "Experiment set parser"
|
|
74
|
+
parser = argparse.ArgumentParser(
|
|
75
|
+
description=doc,
|
|
76
|
+
formatter_class=argparse.RawDescriptionHelpFormatter
|
|
77
|
+
)
|
|
78
|
+
parser.add_argument("set", type=Path, help="Path to the DaVis experiment set file")
|
|
79
|
+
parser.add_argument("--depth", type=int, default=None, help="Maximum depth to display in the tree")
|
|
80
|
+
args = parser.parse_args()
|
|
81
|
+
|
|
82
|
+
lv_set = LVSet(args.set)
|
|
83
|
+
# recursive_explorer(lv_set)
|
|
84
|
+
print(tree_set(lv_set, depth_max=args.depth))
|
|
85
|
+
|
|
86
|
+
if __name__ == "__main__":
|
|
87
|
+
main()
|
|
@@ -4,9 +4,10 @@ LVPyIO Tools Viewer
|
|
|
4
4
|
Show a specific image from a DaVis set file.
|
|
5
5
|
|
|
6
6
|
Usage:
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
|
|
8
|
+
.. code-block:: bash
|
|
9
|
+
|
|
10
|
+
lvpyioShow path/to/set/file
|
|
10
11
|
"""
|
|
11
12
|
from pathlib import Path
|
|
12
13
|
|
|
@@ -20,7 +21,7 @@ def main():
|
|
|
20
21
|
description=doc,
|
|
21
22
|
formatter_class=argparse.RawDescriptionHelpFormatter
|
|
22
23
|
)
|
|
23
|
-
parser.add_argument("set", type=
|
|
24
|
+
parser.add_argument("set", type=Path, help="Path to the DaVis set file")
|
|
24
25
|
parser.add_argument("--buffer", type=int, default=0, help="Buffer frame number to display (default: 0)")
|
|
25
26
|
parser.add_argument("--frame", type=int, default=0, help="Frame number to display (default: 0)")
|
|
26
27
|
parser.add_argument("--image", type=int, default=0, help="Image number to display (default: 0)")
|
|
@@ -29,7 +30,7 @@ def main():
|
|
|
29
30
|
parser.add_argument("--cmap", type=str, default='gray', help="Colormap for image display (default: 'gray')")
|
|
30
31
|
args = parser.parse_args()
|
|
31
32
|
|
|
32
|
-
with LVSet(
|
|
33
|
+
with LVSet(args.set) as lv_set:
|
|
33
34
|
try:
|
|
34
35
|
frame = lv_set.get_frame(args.buffer, args.frame)
|
|
35
36
|
frame.show(image_number=args.image,
|
|
@@ -3,7 +3,7 @@ Helper class for working with lvpyio sets.
|
|
|
3
3
|
"""
|
|
4
4
|
from pathlib import Path
|
|
5
5
|
from typing import Any
|
|
6
|
-
import
|
|
6
|
+
import logging
|
|
7
7
|
|
|
8
8
|
from PIL import Image
|
|
9
9
|
|
|
@@ -23,11 +23,11 @@ else:
|
|
|
23
23
|
if __name__ == "__main__":
|
|
24
24
|
import sys
|
|
25
25
|
sys.path.append(str(Path(__file__).parent.parent))
|
|
26
|
-
from lvpyioTools import setParser, calibration
|
|
26
|
+
from lvpyioTools import setParser, calibration, SetSuffix, SET_SUFFIXES
|
|
27
27
|
from lvpyioTools.frame import LVFrame
|
|
28
28
|
from lvpyioTools.mask import create_mask
|
|
29
29
|
else:
|
|
30
|
-
from . import setParser, calibration
|
|
30
|
+
from . import setParser, calibration, SetSuffix, SET_SUFFIXES
|
|
31
31
|
from .frame import LVFrame
|
|
32
32
|
from .mask import create_mask
|
|
33
33
|
|
|
@@ -56,7 +56,7 @@ def sanitize_set_path(path: Path | str) -> Path:
|
|
|
56
56
|
|
|
57
57
|
# if it's a set file already then we simply return it
|
|
58
58
|
if path.is_file():
|
|
59
|
-
if not path.suffix in
|
|
59
|
+
if not path.suffix in SET_SUFFIXES:
|
|
60
60
|
raise ValueError(f"Provided set file {path} is not a .set or .exp file.")
|
|
61
61
|
|
|
62
62
|
# if it's a directory then we try to find a .set or .exp file
|
|
@@ -82,6 +82,7 @@ class LVSet(): # numpydoc ignore=SA01
|
|
|
82
82
|
This provides a simple interface to easily manipulate and read the set files.
|
|
83
83
|
|
|
84
84
|
A set of images is handled this way in DaVis:
|
|
85
|
+
|
|
85
86
|
1. buffer (set[buffer_frame])
|
|
86
87
|
2. frame (set[buffer_frame][frame_number])
|
|
87
88
|
3. image (set[buffer_frame][frame_number].images[image_number])
|
|
@@ -93,16 +94,18 @@ class LVSet(): # numpydoc ignore=SA01
|
|
|
93
94
|
Examples
|
|
94
95
|
--------
|
|
95
96
|
|
|
96
|
-
|
|
97
|
-
|
|
97
|
+
.. code-block:: python
|
|
98
|
+
|
|
98
99
|
from pathlib import Path
|
|
100
|
+
from lvpyioTools.set import LVSet
|
|
99
101
|
|
|
100
102
|
set_file = Path("example/example.set")
|
|
101
|
-
with LVSet(set_file) as
|
|
102
|
-
|
|
103
|
-
print(f"Number of frames in the set: {len(
|
|
104
|
-
```
|
|
103
|
+
with LVSet(set_file) as lvset:
|
|
104
|
+
lvset.show()
|
|
105
|
+
print(f"Number of frames in the set: {len(lvset)}")
|
|
105
106
|
"""
|
|
107
|
+
_set_cache: dict[Path, 'LVSet'] = {}
|
|
108
|
+
|
|
106
109
|
def __init__(self, set_path: Path | str):
|
|
107
110
|
# sanitize file
|
|
108
111
|
set_path = sanitize_set_path(set_path)
|
|
@@ -113,16 +116,28 @@ class LVSet(): # numpydoc ignore=SA01
|
|
|
113
116
|
self.properties: dict[setParser.SetProperty, Any] = self.get_properties()
|
|
114
117
|
|
|
115
118
|
self.set: Set | None = None
|
|
116
|
-
"""Holds the active set instance. If None, needs to be first opened with
|
|
119
|
+
"""Holds the active set instance. If None, needs to be first opened with ``open()``."""
|
|
117
120
|
self.frames: tuple[LVFrame, ...] | None = None
|
|
118
121
|
"""Holds the frames of the currently opened set. If None, the set is not open."""
|
|
119
122
|
|
|
123
|
+
LVSet._set_cache[self.set_file] = self
|
|
124
|
+
|
|
125
|
+
def get_name(self) -> str:
|
|
126
|
+
"""
|
|
127
|
+
Get the name of the set file without its extension.
|
|
128
|
+
|
|
129
|
+
Returns:
|
|
130
|
+
str: The stem of the set file.
|
|
131
|
+
"""
|
|
132
|
+
return self.set_file.stem
|
|
133
|
+
|
|
120
134
|
def __repr__(self):
|
|
135
|
+
name = self.get_name()
|
|
121
136
|
if self.is_experiment():
|
|
122
|
-
return f"<LVSet: {
|
|
137
|
+
return f"<LVSet: {name}, experiment set, properties={len(self.properties)}>"
|
|
123
138
|
if self.is_open():
|
|
124
|
-
return f"<LVSet: {
|
|
125
|
-
return f"<LVSet: {
|
|
139
|
+
return f"<LVSet: {name}, {len(self)} frames, properties={len(self.properties)}>"
|
|
140
|
+
return f"<LVSet: {name}, closed, properties={len(self.properties)}>"
|
|
126
141
|
|
|
127
142
|
|
|
128
143
|
## LOADER / SAVER
|
|
@@ -162,7 +177,7 @@ class LVSet(): # numpydoc ignore=SA01
|
|
|
162
177
|
"""
|
|
163
178
|
Load the set with lvpyio.
|
|
164
179
|
"""
|
|
165
|
-
# safeguard to ensure we properly close the set
|
|
180
|
+
# safeguard to ensure we properly close the set before reopening it
|
|
166
181
|
self.close()
|
|
167
182
|
if self.is_experiment():
|
|
168
183
|
raise ValueError(f"Cannot open an experiment set (`.exp`) directly.")
|
|
@@ -183,7 +198,7 @@ class LVSet(): # numpydoc ignore=SA01
|
|
|
183
198
|
|
|
184
199
|
def is_experiment(self) -> bool:
|
|
185
200
|
"""
|
|
186
|
-
Check if the set is an experiment set (
|
|
201
|
+
Check if the set is an experiment set (``.exp``).
|
|
187
202
|
"""
|
|
188
203
|
return self.set_file.suffix == ".exp"
|
|
189
204
|
|
|
@@ -195,7 +210,7 @@ class LVSet(): # numpydoc ignore=SA01
|
|
|
195
210
|
init (bool, optional): If True, the folder will be created if it does not exist. Defaults to True.
|
|
196
211
|
|
|
197
212
|
Raises:
|
|
198
|
-
FileNotFoundError: If the folder does not exist and
|
|
213
|
+
FileNotFoundError: If the folder does not exist and ``init`` is False.
|
|
199
214
|
NotADirectoryError: If the path exists but is not a directory.
|
|
200
215
|
|
|
201
216
|
Returns:
|
|
@@ -229,7 +244,7 @@ class LVSet(): # numpydoc ignore=SA01
|
|
|
229
244
|
parent_dir = set_dir.parent
|
|
230
245
|
|
|
231
246
|
# find .set or .exp file if exists
|
|
232
|
-
for suffix in
|
|
247
|
+
for suffix in SET_SUFFIXES:
|
|
233
248
|
# try to access the set file
|
|
234
249
|
parent_set_file = parent_dir / (set_dir.name + suffix)
|
|
235
250
|
if parent_set_file.exists():
|
|
@@ -257,7 +272,7 @@ class LVSet(): # numpydoc ignore=SA01
|
|
|
257
272
|
# stop after too many iterations to avoid infinite loops
|
|
258
273
|
iteration += 1
|
|
259
274
|
if iteration > max_iteration:
|
|
260
|
-
|
|
275
|
+
logging.warning(f"Reached maximum iteration ({max_iteration}) while searching for experiment set. Stopping search.")
|
|
261
276
|
break
|
|
262
277
|
return None
|
|
263
278
|
|
|
@@ -269,20 +284,19 @@ class LVSet(): # numpydoc ignore=SA01
|
|
|
269
284
|
list[LVSet]: A list of child sets.
|
|
270
285
|
"""
|
|
271
286
|
children = []
|
|
272
|
-
set_dir = self.
|
|
287
|
+
set_dir = self.get_folder()
|
|
273
288
|
for child_dir in set_dir.iterdir():
|
|
274
|
-
if child_dir.
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
children.append(LVSet(child_set_file))
|
|
289
|
+
if not child_dir.is_file(): continue
|
|
290
|
+
child_set_file = child_dir.with_suffix(SetSuffix.SET)
|
|
291
|
+
if not child_set_file.exists(): continue
|
|
292
|
+
children.append(LVSet(child_set_file))
|
|
279
293
|
return children
|
|
280
294
|
|
|
281
295
|
def get_mask(self, init: bool = False) -> 'LVSet | None':
|
|
282
296
|
"""
|
|
283
297
|
Retrieve the mask set associated with the current set.
|
|
284
298
|
|
|
285
|
-
If the mask set does not exist and
|
|
299
|
+
If the mask set does not exist and ``init`` is True, a new mask set will be created.
|
|
286
300
|
|
|
287
301
|
A mask is a specifically named set file "MASK.set" inside the set folder. Using some operations you can apply that mask on your current set from within DaVis.
|
|
288
302
|
|
|
@@ -322,13 +336,13 @@ class LVSet(): # numpydoc ignore=SA01
|
|
|
322
336
|
"""
|
|
323
337
|
experiment = self.get_experiment()
|
|
324
338
|
if experiment is None:
|
|
325
|
-
|
|
339
|
+
logging.warning(f"No experiment set found for {self.set_file}. Cannot retrieve calibration.")
|
|
326
340
|
return None
|
|
327
341
|
|
|
328
342
|
# get calibration file
|
|
329
343
|
calibration_file = experiment.set_file.with_suffix("") / "Properties" / "Calibration" / "Calibration.xml"
|
|
330
344
|
if not calibration_file.exists():
|
|
331
|
-
|
|
345
|
+
logging.warning(f"Calibration file {calibration_file} does not exist. Cannot retrieve calibration.")
|
|
332
346
|
return None
|
|
333
347
|
|
|
334
348
|
return calibration.get_calibration(calibration_file)
|
|
@@ -1,9 +1,18 @@
|
|
|
1
|
+
r"""
|
|
2
|
+
Provide utilities to parse and read properties from set files.
|
|
3
|
+
"""
|
|
4
|
+
import logging
|
|
1
5
|
from pathlib import Path
|
|
2
6
|
from typing import Any
|
|
3
|
-
import warnings
|
|
4
|
-
|
|
5
|
-
from .setProperties import SetProperty, property_types
|
|
6
7
|
|
|
8
|
+
if __name__ == "__main__":
|
|
9
|
+
import sys
|
|
10
|
+
sys.path.append(str(Path(__file__).parent.parent))
|
|
11
|
+
from lvpyioTools.setProperties import SetProperty, property_types
|
|
12
|
+
from lvpyioTools.utils import is_set_file
|
|
13
|
+
else:
|
|
14
|
+
from .setProperties import SetProperty, property_types
|
|
15
|
+
from .utils import is_set_file
|
|
7
16
|
|
|
8
17
|
_PROPERTY_PATTERN = r"(?P<property>\w+) = \"?(?P<value>[\S\s]*?)\"?;"
|
|
9
18
|
|
|
@@ -17,30 +26,30 @@ def read_property(key: str, value: str):
|
|
|
17
26
|
value (str): The property value from the set file.
|
|
18
27
|
|
|
19
28
|
Returns:
|
|
20
|
-
tuple[SetProperty | None, Any]: A tuple containing the property key as a
|
|
29
|
+
tuple[SetProperty | None, Any]: A tuple containing the property key as a ``SetProperty`` enum member (or ``None`` if unknown) and the converted property value (or ``None`` if conversion failed).
|
|
21
30
|
"""
|
|
22
31
|
try:
|
|
23
32
|
prop = SetProperty(key)
|
|
24
33
|
except ValueError:
|
|
25
|
-
|
|
34
|
+
logging.warning(f"Unknown property '{key}' found in the set file.")
|
|
26
35
|
return None, None
|
|
27
36
|
|
|
28
37
|
# convert to type
|
|
29
38
|
prop_type = property_types.get(prop, None)
|
|
30
39
|
if prop_type is None:
|
|
31
|
-
|
|
40
|
+
logging.warning(f"Unknown property '{key}' found in the set file.")
|
|
32
41
|
else:
|
|
33
42
|
try:
|
|
34
43
|
value = prop_type(value) # convert to the appropriate type
|
|
35
44
|
except Exception as e:
|
|
36
|
-
|
|
45
|
+
logging.warning(f"Error converting property '{key}' with value '{value}': {e}")
|
|
37
46
|
return None, None
|
|
38
47
|
|
|
39
48
|
return prop, value
|
|
40
49
|
|
|
41
50
|
def read(file: Path) -> dict[SetProperty, Any]:
|
|
42
51
|
"""
|
|
43
|
-
Read the contents of a file.
|
|
52
|
+
Read the contents of a set file and extract its properties.
|
|
44
53
|
|
|
45
54
|
Args:
|
|
46
55
|
file (Path): The path to the file to read.
|
|
@@ -48,6 +57,8 @@ def read(file: Path) -> dict[SetProperty, Any]:
|
|
|
48
57
|
Returns:
|
|
49
58
|
dict[SetProperty, Any]: A dictionary containing the set properties and their values.
|
|
50
59
|
"""
|
|
60
|
+
if not is_set_file(file):
|
|
61
|
+
raise ValueError(f"The file '{file}' is not a valid .set file.")
|
|
51
62
|
with open(file, 'r') as f:
|
|
52
63
|
content = f.read().strip()
|
|
53
64
|
lines = content.splitlines()
|
|
@@ -55,7 +66,7 @@ def read(file: Path) -> dict[SetProperty, Any]:
|
|
|
55
66
|
# identify line with "#GROUP Sets"
|
|
56
67
|
group_line_index = None
|
|
57
68
|
for i, line in enumerate(lines):
|
|
58
|
-
if line.strip()
|
|
69
|
+
if line.strip().startswith("#GROUP"):
|
|
59
70
|
group_line_index = i
|
|
60
71
|
break
|
|
61
72
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from enum import Enum, StrEnum
|
|
2
2
|
from datetime import datetime
|
|
3
|
-
import locale
|
|
3
|
+
import locale
|
|
4
|
+
import logging
|
|
4
5
|
|
|
5
6
|
def _read_date(value: str) -> datetime | None:
|
|
6
7
|
"""
|
|
@@ -15,7 +16,7 @@ def _read_date(value: str) -> datetime | None:
|
|
|
15
16
|
value (str): The date string from the .set file.
|
|
16
17
|
|
|
17
18
|
Returns:
|
|
18
|
-
datetime | None: The corresponding datetime object, or
|
|
19
|
+
datetime | None: The corresponding datetime object, or ``None`` if parsing failed.
|
|
19
20
|
"""
|
|
20
21
|
try:
|
|
21
22
|
# use 'C' locale to ensure parsing works regardless of system locale
|
|
@@ -31,23 +32,23 @@ def _read_date(value: str) -> datetime | None:
|
|
|
31
32
|
# restoration fails, just proceed
|
|
32
33
|
pass
|
|
33
34
|
except ValueError:
|
|
34
|
-
|
|
35
|
+
logging.warning(f"Could not parse date from value '{value}'")
|
|
35
36
|
return None
|
|
36
37
|
|
|
37
38
|
|
|
38
39
|
|
|
39
40
|
class SetType(Enum):
|
|
40
41
|
"""
|
|
41
|
-
Classifications of the different values of the
|
|
42
|
+
Classifications of the different values of the ``SetType`` property.
|
|
42
43
|
"""
|
|
43
44
|
IMAGE = 256
|
|
44
|
-
"""
|
|
45
|
+
"""``.im7`` images"""
|
|
45
46
|
VECTORS = 512
|
|
46
|
-
"""
|
|
47
|
+
"""``.vc7`` files"""
|
|
47
48
|
CINE = 4352
|
|
48
|
-
"""
|
|
49
|
+
"""``.cine`` file"""
|
|
49
50
|
PROPERTIES = 8192
|
|
50
|
-
"""
|
|
51
|
+
"""``Properties`` folder"""
|
|
51
52
|
FOLDER = 16384
|
|
52
53
|
"""Simple folder"""
|
|
53
54
|
CALIBRATION = 131072
|
|
@@ -55,26 +56,26 @@ class SetType(Enum):
|
|
|
55
56
|
|
|
56
57
|
def _read_set_type(value: str) -> SetType | None:
|
|
57
58
|
"""
|
|
58
|
-
Convert a string value to a
|
|
59
|
+
Convert a string value to a ``SetType`` enum member.
|
|
59
60
|
|
|
60
61
|
Args:
|
|
61
62
|
value (str): The string representation of the set type, which is expected to be an integer in string format.
|
|
62
63
|
|
|
63
64
|
Returns:
|
|
64
|
-
SetType: The corresponding
|
|
65
|
+
SetType: The corresponding ``SetType`` enum member.
|
|
65
66
|
"""
|
|
66
67
|
# convert to int
|
|
67
68
|
try:
|
|
68
69
|
value_int = int(value)
|
|
69
70
|
except ValueError:
|
|
70
|
-
|
|
71
|
+
logging.warning(f"Could not convert value '{value}' to int for SetType")
|
|
71
72
|
return None
|
|
72
73
|
|
|
73
74
|
# try to convert to SetType
|
|
74
75
|
try:
|
|
75
76
|
return SetType(value_int)
|
|
76
77
|
except ValueError:
|
|
77
|
-
|
|
78
|
+
logging.warning(f"Unknown SetType value '{value_int}'")
|
|
78
79
|
return None
|
|
79
80
|
|
|
80
81
|
class SetProperty(StrEnum):
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: lvpyioTools
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.8.1
|
|
4
4
|
Summary: A set of tools to handle LabView files and data via the lvpyio library.
|
|
5
5
|
Author-email: SimKDT <simon.cadet79+github@proton.me>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -19,13 +19,14 @@ Classifier: Topic :: Multimedia :: Video :: Display
|
|
|
19
19
|
Requires-Python: >=3.12.3
|
|
20
20
|
Description-Content-Type: text/markdown
|
|
21
21
|
License-File: LICENSE
|
|
22
|
-
Requires-Dist: numpy
|
|
23
|
-
Requires-Dist: matplotlib
|
|
24
|
-
Requires-Dist: Pillow
|
|
22
|
+
Requires-Dist: numpy>=2.5.1
|
|
23
|
+
Requires-Dist: matplotlib>=3.11.1
|
|
24
|
+
Requires-Dist: Pillow>=12.3.0
|
|
25
25
|
Requires-Dist: lvpyio>=1.4.0
|
|
26
|
+
Requires-Dist: rich>=15.0.0
|
|
26
27
|
Provides-Extra: docs
|
|
27
|
-
Requires-Dist: sphinx>=
|
|
28
|
-
Requires-Dist:
|
|
28
|
+
Requires-Dist: sphinx>=9.1.0; extra == "docs"
|
|
29
|
+
Requires-Dist: furo; extra == "docs"
|
|
29
30
|
Requires-Dist: sphinx-autodoc-typehints>=1.23.0; extra == "docs"
|
|
30
31
|
Dynamic: license-file
|
|
31
32
|
|
|
@@ -67,7 +68,7 @@ pip install .
|
|
|
67
68
|
|
|
68
69
|
## Usage
|
|
69
70
|
|
|
70
|
-
You can find the
|
|
71
|
+
You can find the full documentation in [https://simkdt.github.io/lvpyio-tools/](https://simkdt.github.io/lvpyio-tools/).
|
|
71
72
|
|
|
72
73
|
```python
|
|
73
74
|
from pathlib import Path
|
|
@@ -9,12 +9,14 @@ src/lvpyioTools/mask.py
|
|
|
9
9
|
src/lvpyioTools/set.py
|
|
10
10
|
src/lvpyioTools/setParser.py
|
|
11
11
|
src/lvpyioTools/setProperties.py
|
|
12
|
+
src/lvpyioTools/utils.py
|
|
12
13
|
src/lvpyioTools.egg-info/PKG-INFO
|
|
13
14
|
src/lvpyioTools.egg-info/SOURCES.txt
|
|
14
15
|
src/lvpyioTools.egg-info/dependency_links.txt
|
|
15
16
|
src/lvpyioTools.egg-info/entry_points.txt
|
|
16
17
|
src/lvpyioTools.egg-info/requires.txt
|
|
17
18
|
src/lvpyioTools.egg-info/top_level.txt
|
|
19
|
+
src/lvpyioTools/scripts/experiment_parser.py
|
|
18
20
|
src/lvpyioTools/scripts/viewer.py
|
|
19
21
|
src/lvpyioTools/stubs/set.py
|
|
20
22
|
src/lvpyioTools/stubs/set.pyi
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|