csa-header 2.0.0__tar.gz → 2.0.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.
- {csa_header-2.0.0 → csa_header-2.0.1}/CHANGELOG.md +14 -0
- {csa_header-2.0.0 → csa_header-2.0.1}/PKG-INFO +4 -3
- {csa_header-2.0.0 → csa_header-2.0.1}/README.md +1 -1
- {csa_header-2.0.0 → csa_header-2.0.1}/csa_header/__about__.py +1 -1
- {csa_header-2.0.0 → csa_header-2.0.1}/csa_header/ascii/ascconv.py +26 -6
- {csa_header-2.0.0 → csa_header-2.0.1}/pyproject.toml +2 -1
- {csa_header-2.0.0 → csa_header-2.0.1}/tests/ascii/test_ascconv_sample.py +18 -0
- {csa_header-2.0.0 → csa_header-2.0.1}/.gitignore +0 -0
- {csa_header-2.0.0 → csa_header-2.0.1}/CODE_OF_CONDUCT.md +0 -0
- {csa_header-2.0.0 → csa_header-2.0.1}/CONTRIBUTING.md +0 -0
- {csa_header-2.0.0 → csa_header-2.0.1}/LICENSE.txt +0 -0
- {csa_header-2.0.0 → csa_header-2.0.1}/SECURITY.md +0 -0
- {csa_header-2.0.0 → csa_header-2.0.1}/csa_header/__init__.py +0 -0
- {csa_header-2.0.0 → csa_header-2.0.1}/csa_header/ascii/__init__.py +0 -0
- {csa_header-2.0.0 → csa_header-2.0.1}/csa_header/ascii/header.py +0 -0
- {csa_header-2.0.0 → csa_header-2.0.1}/csa_header/ascii/messages.py +0 -0
- {csa_header-2.0.0 → csa_header-2.0.1}/csa_header/examples.py +0 -0
- {csa_header-2.0.0 → csa_header-2.0.1}/csa_header/exceptions.py +0 -0
- {csa_header-2.0.0 → csa_header-2.0.1}/csa_header/header.py +0 -0
- {csa_header-2.0.0 → csa_header-2.0.1}/csa_header/messages.py +0 -0
- {csa_header-2.0.0 → csa_header-2.0.1}/csa_header/unpacker.py +0 -0
- {csa_header-2.0.0 → csa_header-2.0.1}/csa_header/utils.py +0 -0
- {csa_header-2.0.0 → csa_header-2.0.1}/examples/README.md +0 -0
- {csa_header-2.0.0 → csa_header-2.0.1}/examples/basic_usage_example.py +0 -0
- {csa_header-2.0.0 → csa_header-2.0.1}/examples/nibabel_integration.py +0 -0
- {csa_header-2.0.0 → csa_header-2.0.1}/tests/__init__.py +0 -0
- {csa_header-2.0.0 → csa_header-2.0.1}/tests/ascii/__init__.py +0 -0
- {csa_header-2.0.0 → csa_header-2.0.1}/tests/ascii/fixtures.py +0 -0
- {csa_header-2.0.0 → csa_header-2.0.1}/tests/ascii/test_ascconv_parsing.py +0 -0
- {csa_header-2.0.0 → csa_header-2.0.1}/tests/ascii/test_header.py +0 -0
- {csa_header-2.0.0 → csa_header-2.0.1}/tests/benchmarks/__init__.py +0 -0
- {csa_header-2.0.0 → csa_header-2.0.1}/tests/benchmarks/bench_parsing.py +0 -0
- {csa_header-2.0.0 → csa_header-2.0.1}/tests/files/__init__.py +0 -0
- {csa_header-2.0.0 → csa_header-2.0.1}/tests/files/ascconv_sample.txt +0 -0
- {csa_header-2.0.0 → csa_header-2.0.1}/tests/files/dwi_image_header_info +0 -0
- {csa_header-2.0.0 → csa_header-2.0.1}/tests/files/e11_series_header_info +0 -0
- {csa_header-2.0.0 → csa_header-2.0.1}/tests/files/rsfmri_series_header_info +0 -0
- {csa_header-2.0.0 → csa_header-2.0.1}/tests/fixtures.py +0 -0
- {csa_header-2.0.0 → csa_header-2.0.1}/tests/test_documentation_examples.py +0 -0
- {csa_header-2.0.0 → csa_header-2.0.1}/tests/test_examples.py +0 -0
- {csa_header-2.0.0 → csa_header-2.0.1}/tests/test_header.py +0 -0
- {csa_header-2.0.0 → csa_header-2.0.1}/tests/test_unpacker.py +0 -0
|
@@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [2.0.1] - 2026-12-03
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
- **Python 3.14 compatibility**: parsing an ASCCONV protocol (such as `MrPhoenixProtocol` in a series CSA header)
|
|
14
|
+
no longer fails with `AttributeError: module 'ast' has no attribute 'Num'`. Python 3.14 removed the `ast.Num` and
|
|
15
|
+
`ast.Str` aliases, so literal values are now read from `ast.Constant`. The fix follows Julia's
|
|
16
|
+
([@juliam98](https://github.com/juliam98)) fix for the same code in dicom_parser
|
|
17
|
+
([open-dicom/dicom_parser#127](https://github.com/open-dicom/dicom_parser/pull/127)).
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
- Python 3.14 is now tested in CI and listed in the package classifiers.
|
|
21
|
+
|
|
10
22
|
## [2.0.0] - 2025-11-01
|
|
11
23
|
|
|
12
24
|
### 🔥 Breaking Changes
|
|
@@ -221,6 +233,8 @@ Potential features for future releases:
|
|
|
221
233
|
|
|
222
234
|
---
|
|
223
235
|
|
|
236
|
+
[2.0.1]: https://github.com/open-dicom/csa_header/compare/v2.0.0...v2.0.1
|
|
237
|
+
[2.0.0]: https://github.com/open-dicom/csa_header/compare/v1.0.2...v2.0.0
|
|
224
238
|
[1.0.1]: https://github.com/open-dicom/csa_header/compare/v1.0.0...v1.0.1
|
|
225
239
|
[1.0.0]: https://github.com/open-dicom/csa_header/compare/v0.0.1...v1.0.0
|
|
226
240
|
[0.0.1]: https://github.com/open-dicom/csa_header/releases/tag/v0.0.1
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: csa_header
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.1
|
|
4
4
|
Summary: Parse Siemens CSA header information
|
|
5
5
|
Project-URL: Documentation, https://github.com/open-dicom/csa_header#readme
|
|
6
6
|
Project-URL: Issues, https://github.com/open-dicom/csa_header/issues
|
|
@@ -16,6 +16,7 @@ Classifier: Programming Language :: Python :: 3.10
|
|
|
16
16
|
Classifier: Programming Language :: Python :: 3.11
|
|
17
17
|
Classifier: Programming Language :: Python :: 3.12
|
|
18
18
|
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
19
20
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
20
21
|
Requires-Python: >=3.9
|
|
21
22
|
Requires-Dist: numpy>=1.20.0
|
|
@@ -74,7 +75,7 @@ The _CSA Image Header Info_ and _CSA Series Header Info_ elements contain encode
|
|
|
74
75
|
- **ASCCONV Support**: Automatic parsing of embedded ASCCONV protocol parameters
|
|
75
76
|
- **Type-Safe**: Complete type hints for all public APIs
|
|
76
77
|
- **Well-Tested**: 96% test coverage with 161 tests
|
|
77
|
-
- **Python 3.9+**: Modern Python with support through Python 3.
|
|
78
|
+
- **Python 3.9+**: Modern Python with support through Python 3.14
|
|
78
79
|
- **NiBabel Compatible**: Integrates seamlessly with neuroimaging workflows
|
|
79
80
|
|
|
80
81
|
**Table of Contents**
|
|
@@ -44,7 +44,7 @@ The _CSA Image Header Info_ and _CSA Series Header Info_ elements contain encode
|
|
|
44
44
|
- **ASCCONV Support**: Automatic parsing of embedded ASCCONV protocol parameters
|
|
45
45
|
- **Type-Safe**: Complete type hints for all public APIs
|
|
46
46
|
- **Well-Tested**: 96% test coverage with 161 tests
|
|
47
|
-
- **Python 3.9+**: Modern Python with support through Python 3.
|
|
47
|
+
- **Python 3.9+**: Modern Python with support through Python 3.14
|
|
48
48
|
- **NiBabel Compatible**: Integrates seamlessly with neuroimaging workflows
|
|
49
49
|
|
|
50
50
|
**Table of Contents**
|
|
@@ -59,6 +59,12 @@ TERMINAL_DIGIT_PATTERN = r"^(.*)\.(\d+)(\s+=)"
|
|
|
59
59
|
#: Regular expression to replace terminal integer identifiers.
|
|
60
60
|
TERMINAL_DIGIT_RE = re.compile(TERMINAL_DIGIT_PATTERN, re.M)
|
|
61
61
|
|
|
62
|
+
#: Types of the literal values an ASCCONV assignment may hold.
|
|
63
|
+
LITERAL_VALUE_TYPES = (int, float, str)
|
|
64
|
+
|
|
65
|
+
#: Types of the literal values an ASCCONV assignment may negate.
|
|
66
|
+
NUMERIC_VALUE_TYPES = (int, float)
|
|
67
|
+
|
|
62
68
|
|
|
63
69
|
class AscconvParseError(Exception):
|
|
64
70
|
"""
|
|
@@ -203,13 +209,27 @@ def obj_from_atoms(
|
|
|
203
209
|
|
|
204
210
|
|
|
205
211
|
def _get_value(assign: ast.Assign) -> int | float | str:
|
|
212
|
+
"""
|
|
213
|
+
Return the literal value assigned by one ASCCONV line.
|
|
214
|
+
|
|
215
|
+
Every literal parses as ``ast.Constant`` (Python 3.8+); the ``ast.Num``
|
|
216
|
+
and ``ast.Str`` aliases this used to check were removed in Python 3.14.
|
|
217
|
+
|
|
218
|
+
Raises
|
|
219
|
+
------
|
|
220
|
+
AscconvParseError
|
|
221
|
+
The assigned value is not a number, a string or a negated number
|
|
222
|
+
"""
|
|
206
223
|
value = assign.value
|
|
207
|
-
if isinstance(value, ast.
|
|
208
|
-
return value.
|
|
209
|
-
if
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
224
|
+
if isinstance(value, ast.Constant) and isinstance(value.value, LITERAL_VALUE_TYPES):
|
|
225
|
+
return value.value
|
|
226
|
+
if (
|
|
227
|
+
isinstance(value, ast.UnaryOp)
|
|
228
|
+
and isinstance(value.op, ast.USub)
|
|
229
|
+
and isinstance(value.operand, ast.Constant)
|
|
230
|
+
and isinstance(value.operand.value, NUMERIC_VALUE_TYPES)
|
|
231
|
+
):
|
|
232
|
+
return -value.operand.value
|
|
213
233
|
message = messages.UNEXPECTED_RHS.format(value=value)
|
|
214
234
|
raise AscconvParseError(message)
|
|
215
235
|
|
|
@@ -12,6 +12,7 @@ classifiers = [
|
|
|
12
12
|
"Programming Language :: Python :: 3.11",
|
|
13
13
|
"Programming Language :: Python :: 3.12",
|
|
14
14
|
"Programming Language :: Python :: 3.13",
|
|
15
|
+
"Programming Language :: Python :: 3.14",
|
|
15
16
|
"Programming Language :: Python :: Implementation :: CPython",
|
|
16
17
|
]
|
|
17
18
|
dependencies = ["numpy>=1.20.0", "pydicom>=2.2.0,<4.0"]
|
|
@@ -82,7 +83,7 @@ exclude = [
|
|
|
82
83
|
]
|
|
83
84
|
|
|
84
85
|
[[tool.hatch.envs.all.matrix]]
|
|
85
|
-
python = ["3.9", "3.10", "3.11", "3.12", "3.13"]
|
|
86
|
+
python = ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
|
|
86
87
|
|
|
87
88
|
[tool.hatch.envs.default]
|
|
88
89
|
dependencies = ["ipython", "pre-commit"]
|
|
@@ -188,3 +188,21 @@ foo.bar[0] = 1
|
|
|
188
188
|
"""
|
|
189
189
|
with pytest.raises(AscconvParseError):
|
|
190
190
|
out = parse_ascconv_text(val_then_list)
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
def test_literal_values():
|
|
194
|
+
in_text = """\
|
|
195
|
+
lCount = 3
|
|
196
|
+
dRatio = 0.5
|
|
197
|
+
lOffset = -4
|
|
198
|
+
dShift = -0.25
|
|
199
|
+
tName = ""ep2d_bold""
|
|
200
|
+
"""
|
|
201
|
+
out = parse_ascconv_text(in_text, delimiter='""')
|
|
202
|
+
assert out == {"lCount": 3, "dRatio": 0.5, "lOffset": -4, "dShift": -0.25, "tName": "ep2d_bold"}
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
def test_unexpected_values():
|
|
206
|
+
for unexpected_value in ("[1]", "-foo", '-"text"', "None"):
|
|
207
|
+
with pytest.raises(AscconvParseError):
|
|
208
|
+
parse_ascconv_text(f"foo = {unexpected_value}\n")
|
|
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
|
|
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
|