TemDataBrowser 1.2__tar.gz → 1.3__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.
@@ -12,6 +12,8 @@ jobs:
12
12
 
13
13
  steps:
14
14
  - uses: actions/checkout@v4
15
+ with:
16
+ fetch-depth: 0
15
17
  - name: Set up Python
16
18
  uses: actions/setup-python@v5
17
19
  with:
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Peter Ercius
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1,16 +1,29 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: TemDataBrowser
3
- Version: 1.2
3
+ Version: 1.3
4
4
  Summary: Graphical user interface to view transmission electron microscopy data.
5
5
  Author-email: Peter Ercius <percius@lbl.gov>
6
+ License-Expression: MIT
7
+ Project-URL: Repository, https://github.com/ercius/TemDataBrowser
8
+ Project-URL: Homepage, https://github.com/ercius/TemDataBrowser
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Intended Audience :: Science/Research
11
+ Classifier: Topic :: Scientific/Engineering :: Visualization
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
6
16
  Requires-Python: >=3.10
7
17
  Description-Content-Type: text/markdown
18
+ License-File: LICENSE
8
19
  Requires-Dist: numpy
9
20
  Requires-Dist: pyqtgraph
21
+ Requires-Dist: qtpy
10
22
  Requires-Dist: ScopeFoundry>=1.5
11
23
  Requires-Dist: ncempy>=1.15
12
24
  Requires-Dist: scipy
13
25
  Requires-Dist: imageio>2.17
26
+ Dynamic: license-file
14
27
 
15
28
  # TemDataBrowser
16
29
  A graphical user interface based on ScopeFoundry for viewing TEM data.
@@ -20,7 +33,7 @@ A graphical user interface based on ScopeFoundry for viewing TEM data.
20
33
  # Installation
21
34
  First install QT bindings. For example:
22
35
 
23
- `$ pip install PyQt5`
36
+ `$ pip install PyQt6`
24
37
 
25
38
  Then install this package and the rest of the dependencies:
26
39
 
@@ -6,7 +6,7 @@ A graphical user interface based on ScopeFoundry for viewing TEM data.
6
6
  # Installation
7
7
  First install QT bindings. For example:
8
8
 
9
- `$ pip install PyQt5`
9
+ `$ pip install PyQt6`
10
10
 
11
11
  Then install this package and the rest of the dependencies:
12
12
 
@@ -3,6 +3,8 @@ from pathlib import Path
3
3
 
4
4
  __version__ = version("TemDataBrowser")
5
5
  import functools
6
+ import json
7
+ import re
6
8
 
7
9
  from ScopeFoundry import BaseApp
8
10
  from ScopeFoundry.helper_funcs import load_qt_ui_from_pkg
@@ -17,6 +19,91 @@ import ncempy
17
19
  # Use row-major instead of col-major
18
20
  pg.setConfigOption('imageAxisOrder', 'row-major')
19
21
 
22
+ # Every line of the FEI tomography-parameter log is prefixed with a fixed-width
23
+ # "MM/DD/YY HH:MM:SS " timestamp; what follows it is indented to show which section a
24
+ # parameter belongs to.
25
+ _TIMESTAMP_RE = re.compile(r'^\d{2}/\d{2}/\d{2} \d{2}:\d{2}:\d{2} ')
26
+ _VALUE_KEY = '_value'
27
+
28
+
29
+ def _parse_fei_value(raw):
30
+ raw = raw.strip()
31
+ if raw == '':
32
+ return None
33
+ if raw in ('Yes', 'ON'):
34
+ return True
35
+ if raw in ('No', 'OFF'):
36
+ return False
37
+ try:
38
+ return float(raw)
39
+ except ValueError:
40
+ return raw
41
+
42
+
43
+ def _parse_fei_parameters(lines):
44
+ """Parse the vendor tomography-parameter log into a nested dict.
45
+
46
+ Section headers (e.g. "STEM imaging mode", "Check Focus") repeat parameter names
47
+ like "Periodicity (high tilt range)" under different settings, so a flat dict would
48
+ have later sections silently overwrite earlier ones. Indentation depth tells sections
49
+ apart from their children, so it is used to nest rather than flatten them.
50
+
51
+ A line can be a leaf, a header with no value of its own ("STEM imaging mode"), or
52
+ both at once ("Check Focus: Yes" has its own value and also has Periodicity settings
53
+ indented beneath it) -- every line is therefore pushed as a potential parent, and
54
+ _collapse resolves what it actually turned out to be once all its children are known.
55
+ """
56
+ root = {}
57
+ stack = [(-1, root)]
58
+ for raw_line in lines:
59
+ line = _TIMESTAMP_RE.sub('', raw_line)
60
+ stripped = line.strip()
61
+ if not stripped:
62
+ continue
63
+
64
+ # The stack must unwind to this line's depth before deciding whether to skip it,
65
+ # or a skipped section header (e.g. a "-----" rule right after a depth-1 line)
66
+ # would leave a stale frame on the stack and misparent everything that follows.
67
+ depth = len(line) - len(line.lstrip(' '))
68
+ while stack[-1][0] >= depth:
69
+ stack.pop()
70
+
71
+ if set(stripped) == {'-'}:
72
+ continue # decorative rule; never has children of its own
73
+ parent = stack[-1][1]
74
+
75
+ if ':' in stripped:
76
+ key, _, value = stripped.partition(':')
77
+ key, value = key.strip(), _parse_fei_value(value)
78
+ else:
79
+ key, value = stripped, None
80
+
81
+ node = {_VALUE_KEY: value}
82
+ parent[key] = node
83
+ stack.append((depth, node))
84
+
85
+ _collapse(root)
86
+ return root
87
+
88
+
89
+ def _collapse(node):
90
+ """Resolve each {_value, ...children} node into its final shape.
91
+
92
+ No children and no value -> True (a bare flag like "STEM imaging mode" turned out
93
+ to introduce no sub-parameters). No children, a value -> that value. Children and no
94
+ value -> a dict of just the children. Both -> a dict of the children plus 'value'.
95
+ """
96
+ for key, child in node.items():
97
+ value = child.pop(_VALUE_KEY)
98
+ _collapse(child)
99
+ if not child:
100
+ node[key] = value if value is not None else True
101
+ elif value is not None:
102
+ child['value'] = value
103
+ node[key] = child
104
+ else:
105
+ node[key] = child
106
+
20
107
  class imageioView(DataBrowserView):
21
108
  """ Handles most normal image types like TIF, PNG, etc."""
22
109
 
@@ -183,16 +270,13 @@ class TemMetadataView(DataBrowserView):
183
270
  # Read FEI parameters from .txt file if it exists
184
271
  FEIparameters = Path(path).with_suffix('.txt')
185
272
  if FEIparameters.exists():
186
- with open(FEIparameters, 'r') as f2:
187
- lines = f2.readlines()
188
- pp1 = list([ii[18:].strip().split(':')] for ii in lines[3:-1])
189
- pp2 = {}
190
- for ll in pp1:
191
- try:
192
- pp2[ll[0]] = float(ll[1])
193
- except:
194
- pass # skip lines with no data
195
- meta_data.update(pp2)
273
+ try:
274
+ with open(FEIparameters, 'r', encoding='utf-8-sig') as f2:
275
+ lines = f2.readlines()
276
+ except UnicodeDecodeError:
277
+ with open(FEIparameters, 'r', encoding='cp1252') as f2:
278
+ lines = f2.readlines()
279
+ meta_data['fei_parameters'] = _parse_fei_parameters(lines)
196
280
 
197
281
  return meta_data
198
282
 
@@ -273,6 +357,8 @@ class TemMetadataView(DataBrowserView):
273
357
 
274
358
  txt = f'file name = {fname}\n'
275
359
  for k, v in meta_data.items():
360
+ if isinstance(v, dict):
361
+ v = json.dumps(v, indent=2, default=str)
276
362
  line = f'{k} = {v}\n'
277
363
  txt += line
278
364
  self.ui.setText(txt)
@@ -1,16 +1,29 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: TemDataBrowser
3
- Version: 1.2
3
+ Version: 1.3
4
4
  Summary: Graphical user interface to view transmission electron microscopy data.
5
5
  Author-email: Peter Ercius <percius@lbl.gov>
6
+ License-Expression: MIT
7
+ Project-URL: Repository, https://github.com/ercius/TemDataBrowser
8
+ Project-URL: Homepage, https://github.com/ercius/TemDataBrowser
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Intended Audience :: Science/Research
11
+ Classifier: Topic :: Scientific/Engineering :: Visualization
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
6
16
  Requires-Python: >=3.10
7
17
  Description-Content-Type: text/markdown
18
+ License-File: LICENSE
8
19
  Requires-Dist: numpy
9
20
  Requires-Dist: pyqtgraph
21
+ Requires-Dist: qtpy
10
22
  Requires-Dist: ScopeFoundry>=1.5
11
23
  Requires-Dist: ncempy>=1.15
12
24
  Requires-Dist: scipy
13
25
  Requires-Dist: imageio>2.17
26
+ Dynamic: license-file
14
27
 
15
28
  # TemDataBrowser
16
29
  A graphical user interface based on ScopeFoundry for viewing TEM data.
@@ -20,7 +33,7 @@ A graphical user interface based on ScopeFoundry for viewing TEM data.
20
33
  # Installation
21
34
  First install QT bindings. For example:
22
35
 
23
- `$ pip install PyQt5`
36
+ `$ pip install PyQt6`
24
37
 
25
38
  Then install this package and the rest of the dependencies:
26
39
 
@@ -1,4 +1,5 @@
1
1
  .gitignore
2
+ LICENSE
2
3
  README.md
3
4
  pyproject.toml
4
5
  run_TemDataBrowser.py
@@ -9,5 +10,7 @@ TemDataBrowser.egg-info/SOURCES.txt
9
10
  TemDataBrowser.egg-info/dependency_links.txt
10
11
  TemDataBrowser.egg-info/entry_points.txt
11
12
  TemDataBrowser.egg-info/requires.txt
13
+ TemDataBrowser.egg-info/scm_file_list.json
14
+ TemDataBrowser.egg-info/scm_version.json
12
15
  TemDataBrowser.egg-info/top_level.txt
13
16
  TemDataBrowser/images/TemDataBrowser_window.png
@@ -1,5 +1,6 @@
1
1
  numpy
2
2
  pyqtgraph
3
+ qtpy
3
4
  ScopeFoundry>=1.5
4
5
  ncempy>=1.15
5
6
  scipy
@@ -0,0 +1,12 @@
1
+ {
2
+ "files": [
3
+ ".github/workflows/publish-to-pypi.yml",
4
+ ".gitignore",
5
+ "LICENSE",
6
+ "README.md",
7
+ "TemDataBrowser/__init__.py",
8
+ "TemDataBrowser/images/TemDataBrowser_window.png",
9
+ "pyproject.toml",
10
+ "run_TemDataBrowser.py"
11
+ ]
12
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "tag": "1.3",
3
+ "distance": 0,
4
+ "node": "gce406edf0b29367fc7a38fc35023bb4aa14d72db",
5
+ "dirty": false,
6
+ "branch": "HEAD",
7
+ "node_date": "2026-09-14"
8
+ }
@@ -0,0 +1,32 @@
1
+ [build-system]
2
+ requires = ["setuptools", "setuptools-scm"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "TemDataBrowser"
7
+ authors = [{name = "Peter Ercius", email="percius@lbl.gov"}]
8
+ description = "Graphical user interface to view transmission electron microscopy data."
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = "MIT"
12
+ license-files = ["LICENSE"]
13
+ classifiers = [
14
+ "Development Status :: 4 - Beta",
15
+ "Intended Audience :: Science/Research",
16
+ "Topic :: Scientific/Engineering :: Visualization",
17
+ "Programming Language :: Python :: 3",
18
+ "Programming Language :: Python :: 3.10",
19
+ "Programming Language :: Python :: 3.11",
20
+ "Programming Language :: Python :: 3.12",
21
+ ]
22
+ dependencies = ["numpy","pyqtgraph","qtpy","ScopeFoundry>=1.5","ncempy>=1.15","scipy","imageio>2.17"]
23
+ dynamic = ["version"]
24
+
25
+ [tool.setuptools_scm]
26
+
27
+ [project.urls]
28
+ Repository = "https://github.com/ercius/TemDataBrowser"
29
+ Homepage = "https://github.com/ercius/TemDataBrowser"
30
+
31
+ [project.scripts]
32
+ TemDataBrowser = "TemDataBrowser:open_file"
@@ -1,15 +0,0 @@
1
- [build-system]
2
- requires = ["setuptools", "setuptools-scm"]
3
- build-backend = "setuptools.build_meta"
4
-
5
- [project]
6
- name = "TemDataBrowser"
7
- authors = [{name = "Peter Ercius", email="percius@lbl.gov"}]
8
- description = "Graphical user interface to view transmission electron microscopy data."
9
- readme = "README.md"
10
- requires-python = ">=3.10"
11
- dependencies = ["numpy","pyqtgraph","ScopeFoundry>=1.5","ncempy>=1.15","scipy","imageio>2.17"]
12
- version = "1.2"
13
-
14
- [project.scripts]
15
- TemDataBrowser = "TemDataBrowser:open_file"
File without changes
File without changes