dicom-validator 0.7.0__tar.gz → 0.7.2__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.
- {dicom_validator-0.7.0 → dicom_validator-0.7.2}/PKG-INFO +3 -2
- dicom_validator-0.7.2/dicom_validator/__init__.py +1 -0
- {dicom_validator-0.7.0 → dicom_validator-0.7.2}/dicom_validator/dump_dcm_info.py +1 -1
- {dicom_validator-0.7.0 → dicom_validator-0.7.2}/dicom_validator/spec_reader/condition.py +10 -10
- {dicom_validator-0.7.0 → dicom_validator-0.7.2}/dicom_validator/spec_reader/condition_grammar.py +34 -35
- {dicom_validator-0.7.0 → dicom_validator-0.7.2}/dicom_validator/spec_reader/condition_parser.py +4 -4
- {dicom_validator-0.7.0 → dicom_validator-0.7.2}/dicom_validator/spec_reader/enum_parser.py +6 -6
- {dicom_validator-0.7.0 → dicom_validator-0.7.2}/dicom_validator/spec_reader/part3_reader.py +11 -6
- {dicom_validator-0.7.0 → dicom_validator-0.7.2}/dicom_validator/spec_reader/part4_reader.py +1 -1
- {dicom_validator-0.7.0 → dicom_validator-0.7.2}/dicom_validator/spec_reader/part6_reader.py +1 -1
- {dicom_validator-0.7.0 → dicom_validator-0.7.2}/dicom_validator/spec_reader/serializer.py +1 -1
- {dicom_validator-0.7.0 → dicom_validator-0.7.2}/dicom_validator/tests/spec_reader/conftest.py +1 -1
- {dicom_validator-0.7.0 → dicom_validator-0.7.2}/dicom_validator/tests/spec_reader/test_condition.py +8 -8
- {dicom_validator-0.7.0 → dicom_validator-0.7.2}/dicom_validator/tests/spec_reader/test_condition_parser.py +77 -16
- {dicom_validator-0.7.0 → dicom_validator-0.7.2}/dicom_validator/tests/spec_reader/test_edition_reader.py +1 -1
- {dicom_validator-0.7.0 → dicom_validator-0.7.2}/dicom_validator/tests/spec_reader/test_enum_parser.py +2 -1
- {dicom_validator-0.7.0 → dicom_validator-0.7.2}/dicom_validator/tests/spec_reader/test_part3_reader.py +29 -11
- {dicom_validator-0.7.0 → dicom_validator-0.7.2}/dicom_validator/tests/spec_reader/test_part6_reader.py +3 -3
- {dicom_validator-0.7.0 → dicom_validator-0.7.2}/dicom_validator/tests/test_cmdline_tools.py +1 -1
- {dicom_validator-0.7.0 → dicom_validator-0.7.2}/dicom_validator/tests/validator/conftest.py +1 -1
- {dicom_validator-0.7.0 → dicom_validator-0.7.2}/dicom_validator/tests/validator/test_iod_validator_func_groups.py +3 -1
- {dicom_validator-0.7.0 → dicom_validator-0.7.2}/dicom_validator/validator/iod_validator.py +7 -2
- {dicom_validator-0.7.0 → dicom_validator-0.7.2}/dicom_validator.egg-info/PKG-INFO +3 -2
- {dicom_validator-0.7.0 → dicom_validator-0.7.2}/dicom_validator.egg-info/requires.txt +2 -1
- {dicom_validator-0.7.0 → dicom_validator-0.7.2}/pyproject.toml +2 -1
- dicom_validator-0.7.0/dicom_validator/__init__.py +0 -1
- {dicom_validator-0.7.0 → dicom_validator-0.7.2}/LICENSE +0 -0
- {dicom_validator-0.7.0 → dicom_validator-0.7.2}/README.md +0 -0
- {dicom_validator-0.7.0 → dicom_validator-0.7.2}/dicom_validator/spec_reader/__init__.py +0 -0
- {dicom_validator-0.7.0 → dicom_validator-0.7.2}/dicom_validator/spec_reader/edition_reader.py +0 -0
- {dicom_validator-0.7.0 → dicom_validator-0.7.2}/dicom_validator/spec_reader/spec_reader.py +0 -0
- {dicom_validator-0.7.0 → dicom_validator-0.7.2}/dicom_validator/tag_tools.py +0 -0
- {dicom_validator-0.7.0 → dicom_validator-0.7.2}/dicom_validator/tests/__init__.py +0 -0
- {dicom_validator-0.7.0 → dicom_validator-0.7.2}/dicom_validator/tests/spec_reader/__init__.py +0 -0
- {dicom_validator-0.7.0 → dicom_validator-0.7.2}/dicom_validator/tests/spec_reader/test_part4_reader.py +0 -0
- {dicom_validator-0.7.0 → dicom_validator-0.7.2}/dicom_validator/tests/spec_reader/test_spec_reader.py +0 -0
- {dicom_validator-0.7.0 → dicom_validator-0.7.2}/dicom_validator/tests/utils.py +0 -0
- {dicom_validator-0.7.0 → dicom_validator-0.7.2}/dicom_validator/tests/validator/__init__.py +0 -0
- {dicom_validator-0.7.0 → dicom_validator-0.7.2}/dicom_validator/tests/validator/test_dicom_file_validator.py +0 -0
- {dicom_validator-0.7.0 → dicom_validator-0.7.2}/dicom_validator/tests/validator/test_iod_validator.py +0 -0
- {dicom_validator-0.7.0 → dicom_validator-0.7.2}/dicom_validator/validate_iods.py +0 -0
- {dicom_validator-0.7.0 → dicom_validator-0.7.2}/dicom_validator/validator/__init__.py +0 -0
- {dicom_validator-0.7.0 → dicom_validator-0.7.2}/dicom_validator/validator/dicom_file_validator.py +0 -0
- {dicom_validator-0.7.0 → dicom_validator-0.7.2}/dicom_validator.egg-info/SOURCES.txt +0 -0
- {dicom_validator-0.7.0 → dicom_validator-0.7.2}/dicom_validator.egg-info/dependency_links.txt +0 -0
- {dicom_validator-0.7.0 → dicom_validator-0.7.2}/dicom_validator.egg-info/entry_points.txt +0 -0
- {dicom_validator-0.7.0 → dicom_validator-0.7.2}/dicom_validator.egg-info/top_level.txt +0 -0
- {dicom_validator-0.7.0 → dicom_validator-0.7.2}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dicom-validator
|
|
3
|
-
Version: 0.7.
|
|
3
|
+
Version: 0.7.2
|
|
4
4
|
Summary: Python DICOM validator using input from DICOM specs in docbook format
|
|
5
5
|
Author-email: mrbean-bremen and contributors <hansemrbean@googlemail.com>
|
|
6
6
|
License: MIT
|
|
@@ -27,12 +27,13 @@ Classifier: Topic :: Scientific/Engineering :: Medical Science Apps.
|
|
|
27
27
|
Requires-Python: >=3.9
|
|
28
28
|
Description-Content-Type: text/markdown
|
|
29
29
|
License-File: LICENSE
|
|
30
|
-
Requires-Dist: pydicom
|
|
30
|
+
Requires-Dist: pydicom>=2.3
|
|
31
31
|
Requires-Dist: lxml
|
|
32
32
|
Requires-Dist: pyparsing>=3.2
|
|
33
33
|
Provides-Extra: dev
|
|
34
34
|
Requires-Dist: pyfakefs>=5.0.0; extra == "dev"
|
|
35
35
|
Requires-Dist: pytest; extra == "dev"
|
|
36
|
+
Requires-Dist: pytest-order; extra == "dev"
|
|
36
37
|
Dynamic: license-file
|
|
37
38
|
|
|
38
39
|
# dicom-validator
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.7.2"
|
|
@@ -62,7 +62,7 @@ class DataElementDumper:
|
|
|
62
62
|
value = value[: self.max_value_len] + "..."
|
|
63
63
|
|
|
64
64
|
indent = 2 * self.level
|
|
65
|
-
format_string = "{{}}{{}} {{:{}}} {{}} {{:4}} {{}} [{{}}]"
|
|
65
|
+
format_string = f"{{}}{{}} {{:{40 - indent}}} {{}} {{:4}} {{}} [{{}}]"
|
|
66
66
|
print(
|
|
67
67
|
format_string.format(
|
|
68
68
|
" " * indent, tag_id, name[: 40 - indent], vr, vm, prop, value
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import enum
|
|
2
|
-
from typing import Optional,
|
|
2
|
+
from typing import Optional, Any, Union
|
|
3
3
|
|
|
4
4
|
from dicom_validator.tag_tools import tag_name_from_id
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
ValuesType =
|
|
7
|
+
ValuesType = list[Union[str, int]]
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
class ConditionType(str, enum.Enum): # replace later with StrEnum from Python 3.11
|
|
@@ -132,8 +132,8 @@ class Condition:
|
|
|
132
132
|
self.tag = tag
|
|
133
133
|
self.index = index
|
|
134
134
|
self.values: ValuesType = values or []
|
|
135
|
-
self.and_conditions:
|
|
136
|
-
self.or_conditions:
|
|
135
|
+
self.and_conditions: list[Condition] = []
|
|
136
|
+
self.or_conditions: list[Condition] = []
|
|
137
137
|
self.other_condition: Optional[Condition] = None
|
|
138
138
|
|
|
139
139
|
def __repr__(self):
|
|
@@ -162,7 +162,7 @@ class Condition:
|
|
|
162
162
|
|
|
163
163
|
@classmethod
|
|
164
164
|
def read_condition(
|
|
165
|
-
cls, condition_dict:
|
|
165
|
+
cls, condition_dict: dict, condition: Optional["Condition"] = None
|
|
166
166
|
) -> "Condition":
|
|
167
167
|
"""Create or update a Condition object from a condition dict.
|
|
168
168
|
Parameters
|
|
@@ -194,14 +194,14 @@ class Condition:
|
|
|
194
194
|
condition.other_condition.type = condition_dict["other_cond"].get("type")
|
|
195
195
|
return condition
|
|
196
196
|
|
|
197
|
-
def
|
|
197
|
+
def result_dict(self) -> dict[str, Any]:
|
|
198
198
|
result = {"type": self.type}
|
|
199
199
|
result.update(self.write_condition(self))
|
|
200
200
|
return result
|
|
201
201
|
|
|
202
202
|
@classmethod
|
|
203
|
-
def write_condition(cls, condition: "Condition") ->
|
|
204
|
-
result:
|
|
203
|
+
def write_condition(cls, condition: "Condition") -> dict[str, Any]:
|
|
204
|
+
result: dict[str, Any] = {}
|
|
205
205
|
if condition.operator is not None:
|
|
206
206
|
result["op"] = condition.operator
|
|
207
207
|
if condition.tag is not None:
|
|
@@ -218,10 +218,10 @@ class Condition:
|
|
|
218
218
|
for or_condition in condition.or_conditions:
|
|
219
219
|
result["or"].append(cls.write_condition(or_condition))
|
|
220
220
|
if condition.other_condition is not None:
|
|
221
|
-
result["other_cond"] = condition.other_condition.
|
|
221
|
+
result["other_cond"] = condition.other_condition.result_dict()
|
|
222
222
|
return result
|
|
223
223
|
|
|
224
|
-
def to_string(self, dict_info:
|
|
224
|
+
def to_string(self, dict_info: dict) -> str:
|
|
225
225
|
"""Return a condition readable as part of a sentence."""
|
|
226
226
|
result = ""
|
|
227
227
|
if self.and_conditions:
|
{dicom_validator-0.7.0 → dicom_validator-0.7.2}/dicom_validator/spec_reader/condition_grammar.py
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import string
|
|
2
2
|
from re import RegexFlag
|
|
3
|
-
from typing import
|
|
3
|
+
from typing import Optional
|
|
4
4
|
from urllib.parse import ParseResult
|
|
5
5
|
|
|
6
6
|
from pyparsing import (
|
|
@@ -200,7 +200,7 @@ class ConditionGrammar:
|
|
|
200
200
|
def _condition_grammar(self, values_grammar):
|
|
201
201
|
operator_grammar = self._operator_grammar()
|
|
202
202
|
condition_expression = (
|
|
203
|
-
Suppress(Opt(Keyword("value") | "the value"))
|
|
203
|
+
Suppress(Opt(Keyword("value") | "the value" | "the Value"))
|
|
204
204
|
+ operator_grammar
|
|
205
205
|
+ Opt(values_grammar)
|
|
206
206
|
)
|
|
@@ -261,65 +261,65 @@ class ConditionGrammar:
|
|
|
261
261
|
def _operator_grammar() -> ParserElement:
|
|
262
262
|
absent_op = (
|
|
263
263
|
Keyword("is not sent")
|
|
264
|
-
|
|
|
264
|
+
| CaselessKeyword("is not present in this Sequence Item")
|
|
265
265
|
| Keyword("is not present")
|
|
266
266
|
| Keyword("is absent")
|
|
267
267
|
| Keyword("are not present")
|
|
268
268
|
).set_parse_action(lambda: ConditionOperator.Absent)
|
|
269
269
|
not_empty_op1 = (
|
|
270
|
-
|
|
270
|
+
CaselessKeyword("is non-null") | CaselessKeyword("is non-zero length")
|
|
271
271
|
).set_parse_action(lambda: ConditionOperator.NotEmpty)
|
|
272
272
|
not_equals_op = (
|
|
273
273
|
Keyword("equals other than")
|
|
274
|
-
|
|
|
274
|
+
| CaselessKeyword("value is not")
|
|
275
275
|
| Keyword("is not equal to")
|
|
276
276
|
| Keyword("is not any of")
|
|
277
277
|
| Keyword("is not:")
|
|
278
278
|
| Keyword("is not")
|
|
279
279
|
| Keyword("not")
|
|
280
280
|
| Keyword("is other than")
|
|
281
|
-
|
|
|
281
|
+
| CaselessKeyword("is present with a value other than")
|
|
282
282
|
).set_parse_action(lambda: ConditionOperator.NotEqualsValue)
|
|
283
283
|
greater_op = (
|
|
284
|
-
|
|
284
|
+
CaselessKeyword("has a value of more than")
|
|
285
285
|
| Keyword("is greater than")
|
|
286
|
-
|
|
|
287
|
-
|
|
|
286
|
+
| CaselessKeyword("has a value greater than")
|
|
287
|
+
| CaselessKeyword("is present and has a value greater than")
|
|
288
288
|
).set_parse_action(lambda: ConditionOperator.GreaterValue)
|
|
289
289
|
less_op = (Keyword("is less than")).set_parse_action(
|
|
290
290
|
lambda: ConditionOperator.LessValue
|
|
291
291
|
)
|
|
292
|
-
non_zero_op =
|
|
292
|
+
non_zero_op = CaselessKeyword("is non-zero").set_parse_action(
|
|
293
293
|
lambda: ConditionOperator.NonZero
|
|
294
294
|
)
|
|
295
295
|
equals_op = (
|
|
296
|
-
|
|
297
|
-
|
|
|
298
|
-
|
|
|
296
|
+
CaselessKeyword("is present and the value is")
|
|
297
|
+
| CaselessKeyword("is present and has a value of")
|
|
298
|
+
| CaselessKeyword("is present and has the value")
|
|
299
299
|
| Keyword("is present and is either")
|
|
300
|
-
|
|
|
300
|
+
| CaselessKeyword("is present with value")
|
|
301
301
|
| Keyword("is present and equals")
|
|
302
|
-
|
|
|
302
|
+
| CaselessKeyword("is present with a value of")
|
|
303
303
|
| Keyword("is set to")
|
|
304
|
-
|
|
|
305
|
-
|
|
|
306
|
-
|
|
|
304
|
+
| CaselessKeyword("equals one of the following values:")
|
|
305
|
+
| CaselessKeyword("has a value of")
|
|
306
|
+
| CaselessKeyword("has value")
|
|
307
307
|
| Keyword("=")
|
|
308
|
-
|
|
|
308
|
+
| CaselessKeyword("at the image level equals")
|
|
309
309
|
| Keyword("equals")
|
|
310
310
|
| Keyword("is one of the following:")
|
|
311
|
-
|
|
|
311
|
+
| CaselessKeyword("value is")
|
|
312
312
|
| Keyword("is equal to")
|
|
313
313
|
| Keyword("equals")
|
|
314
|
-
|
|
|
314
|
+
| CaselessKeyword("has the value")
|
|
315
315
|
).set_parse_action(lambda: ConditionOperator.EqualsValue)
|
|
316
316
|
not_empty_op2 = (
|
|
317
|
-
|
|
318
|
-
|
|
|
319
|
-
|
|
|
317
|
+
CaselessKeyword("is present and has a value")
|
|
318
|
+
| CaselessKeyword("is present with a value")
|
|
319
|
+
| CaselessKeyword("has a value")
|
|
320
320
|
).set_parse_action(lambda: ConditionOperator.NotEmpty)
|
|
321
321
|
present_op = (
|
|
322
|
-
|
|
322
|
+
CaselessKeyword("is present in this Sequence Item")
|
|
323
323
|
| Keyword("is present")
|
|
324
324
|
| Keyword("exists")
|
|
325
325
|
| Keyword("is sent")
|
|
@@ -364,13 +364,13 @@ class ConditionGrammar:
|
|
|
364
364
|
).set_parse_action(" ".join)
|
|
365
365
|
# Tag value number
|
|
366
366
|
value_index1 = (
|
|
367
|
-
Suppress("the")
|
|
367
|
+
Suppress(CaselessKeyword("the"))
|
|
368
368
|
+ (
|
|
369
369
|
Keyword("first").set_parse_action(lambda: "1")
|
|
370
370
|
| Keyword("second").set_parse_action(lambda: "2")
|
|
371
371
|
| Keyword("third").set_parse_action(lambda: "3")
|
|
372
372
|
)
|
|
373
|
-
+ Suppress("value of")
|
|
373
|
+
+ Suppress(CaselessKeyword("value") + "of")
|
|
374
374
|
)
|
|
375
375
|
value_index2 = Regex(r"Value (?P<index>\d) of").set_parse_action(
|
|
376
376
|
lambda r: r.index
|
|
@@ -378,12 +378,11 @@ class ConditionGrammar:
|
|
|
378
378
|
value_index3 = Regex(r"(, )?Value (?P<index>\d)").set_parse_action(
|
|
379
379
|
lambda r: r.index
|
|
380
380
|
)
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
tag_expr_prefix = Suppress(
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
)
|
|
381
|
+
prefix1_regex = "((the|a) )?[vV]alue( (of|for))?"
|
|
382
|
+
prefix2_regex = "(the|either|Attribute)?"
|
|
383
|
+
tag_expr_prefix = Suppress(
|
|
384
|
+
Regex(f"({prefix1_regex}|{prefix2_regex})( the( [vV]alue))?")
|
|
385
|
+
) + Opt(tag_id)
|
|
387
386
|
tag_name_expr = Opt(value_index1 | value_index2 | tag_expr_prefix) + tag_name
|
|
388
387
|
action = (
|
|
389
388
|
self._tag_value_from_expression if is_value else self._tag_from_expression
|
|
@@ -392,7 +391,7 @@ class ConditionGrammar:
|
|
|
392
391
|
tag_name_expr
|
|
393
392
|
+ Opt(tag_id)
|
|
394
393
|
+ Opt(value_index3)
|
|
395
|
-
+ Suppress(Opt("of this frame"))
|
|
394
|
+
+ Suppress(Opt(Keyword("of this frame") | "of this Frame"))
|
|
396
395
|
+ self._in_module_grammar()
|
|
397
396
|
).set_parse_action(lambda result: action(result[0]))
|
|
398
397
|
|
|
@@ -480,7 +479,7 @@ class ConditionGrammar:
|
|
|
480
479
|
group, element = tag[1:-1].split(",")
|
|
481
480
|
return (int(group, 16) << 16) + int(element, 16)
|
|
482
481
|
|
|
483
|
-
def _tag_from_expression(self, tag_expr: ParseResult) ->
|
|
482
|
+
def _tag_from_expression(self, tag_expr: ParseResult) -> tuple[str, int]:
|
|
484
483
|
def is_index(item):
|
|
485
484
|
return len(item) == 1 and item.isnumeric()
|
|
486
485
|
|
{dicom_validator-0.7.0 → dicom_validator-0.7.2}/dicom_validator/spec_reader/condition_parser.py
RENAMED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
from typing import Dict
|
|
2
|
-
|
|
3
1
|
from pyparsing import ParseException
|
|
4
2
|
|
|
5
3
|
from dicom_validator.spec_reader.condition import (
|
|
@@ -21,7 +19,7 @@ class ConditionParser:
|
|
|
21
19
|
other data sets) are ignored.
|
|
22
20
|
"""
|
|
23
21
|
|
|
24
|
-
def __init__(self, dict_info:
|
|
22
|
+
def __init__(self, dict_info: dict) -> None:
|
|
25
23
|
self._dict_info = dict_info
|
|
26
24
|
self._uid_dict_info = {}
|
|
27
25
|
for tag, info in dict_info.items():
|
|
@@ -40,7 +38,9 @@ class ConditionParser:
|
|
|
40
38
|
"""
|
|
41
39
|
cache_key = condition_str
|
|
42
40
|
if not debug and cache_key in self._condition_cache:
|
|
43
|
-
return Condition.read_condition(
|
|
41
|
+
return Condition.read_condition(
|
|
42
|
+
self._condition_cache[cache_key].result_dict()
|
|
43
|
+
)
|
|
44
44
|
|
|
45
45
|
condition = self._parse_with_grammar(condition_str, self._grammar, debug)
|
|
46
46
|
if not debug:
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import re
|
|
2
|
-
from typing import Callable, Optional,
|
|
2
|
+
from typing import Callable, Optional, Any
|
|
3
3
|
|
|
4
4
|
from pydicom.valuerep import VR, INT_VR, STR_VR
|
|
5
5
|
|
|
@@ -21,9 +21,9 @@ class EnumParser:
|
|
|
21
21
|
self, find_section: Callable[[str], Optional[ElementTree.Element]]
|
|
22
22
|
) -> None:
|
|
23
23
|
self._find_section = find_section
|
|
24
|
-
self._enum_cache:
|
|
24
|
+
self._enum_cache: dict[str, dict] = {}
|
|
25
25
|
|
|
26
|
-
def parse(self, node: ElementTree.Element, vr: VR) ->
|
|
26
|
+
def parse(self, node: ElementTree.Element, vr: VR) -> list[dict]:
|
|
27
27
|
"""Searches for enumerated values in the tag description and in linked sections.
|
|
28
28
|
Returns a list of the allowed values, or an empty list if none found.
|
|
29
29
|
"""
|
|
@@ -56,7 +56,7 @@ class EnumParser:
|
|
|
56
56
|
# any other VR does not make sense here
|
|
57
57
|
return []
|
|
58
58
|
|
|
59
|
-
def parse_variable_list(self, var_list) ->
|
|
59
|
+
def parse_variable_list(self, var_list) -> dict:
|
|
60
60
|
# we assume that a variablelist contains enumerated values or defined terms
|
|
61
61
|
# we ignore defined terms, as they do not limit the possible values
|
|
62
62
|
title = var_list.find(self.docbook_ns + "title")
|
|
@@ -75,7 +75,7 @@ class EnumParser:
|
|
|
75
75
|
term = item.find(self.docbook_ns + "term")
|
|
76
76
|
if term is not None:
|
|
77
77
|
terms.append(term.text)
|
|
78
|
-
result:
|
|
78
|
+
result: dict[str, Any] = {}
|
|
79
79
|
if terms:
|
|
80
80
|
result["val"] = terms
|
|
81
81
|
if index > 0:
|
|
@@ -83,7 +83,7 @@ class EnumParser:
|
|
|
83
83
|
|
|
84
84
|
return result
|
|
85
85
|
|
|
86
|
-
def parse_linked_variablelist(self, node) ->
|
|
86
|
+
def parse_linked_variablelist(self, node) -> dict:
|
|
87
87
|
for xref in node.findall(f"{self.docbook_ns}para/{self.docbook_ns}xref"):
|
|
88
88
|
link = xref.attrib.get("linkend")
|
|
89
89
|
if link and link.startswith("sect_"):
|
|
@@ -8,7 +8,6 @@ import logging
|
|
|
8
8
|
from itertools import groupby
|
|
9
9
|
|
|
10
10
|
import sys
|
|
11
|
-
from typing import Dict
|
|
12
11
|
|
|
13
12
|
from dicom_validator.spec_reader.condition import (
|
|
14
13
|
Condition,
|
|
@@ -28,14 +27,14 @@ from dicom_validator.spec_reader.spec_reader import (
|
|
|
28
27
|
# Instead of implementing a full parser for these cases, we may define them here.
|
|
29
28
|
# CAUTION: The same tag may appear with different conditions in different contexts
|
|
30
29
|
# (different sequences), which will not be handled automatically by SPECIAL_CASES
|
|
31
|
-
SPECIAL_CASES:
|
|
30
|
+
SPECIAL_CASES: dict[str, Condition] = {}
|
|
32
31
|
|
|
33
32
|
|
|
34
33
|
class Part3Reader(SpecReader):
|
|
35
34
|
"""Reads information from PS3.3 in docbook format."""
|
|
36
35
|
|
|
37
36
|
def __init__(self, spec_dir, dict_info):
|
|
38
|
-
super(
|
|
37
|
+
super().__init__(spec_dir)
|
|
39
38
|
self.part_nr = 3
|
|
40
39
|
self._dict_info = dict_info
|
|
41
40
|
self._iod_descriptions = {}
|
|
@@ -140,7 +139,7 @@ class Part3Reader(SpecReader):
|
|
|
140
139
|
nodes_with_subnodes = []
|
|
141
140
|
for iod_node in all_iod_nodes:
|
|
142
141
|
sub_nodes = self._find_sections_with_title_endings(
|
|
143
|
-
iod_node, iod_def_endings
|
|
142
|
+
iod_node, iod_def_endings, depth=2
|
|
144
143
|
)
|
|
145
144
|
if sub_nodes:
|
|
146
145
|
nodes_with_subnodes.append(iod_node)
|
|
@@ -386,13 +385,13 @@ class Part3Reader(SpecReader):
|
|
|
386
385
|
def _get_functional_group_macros(self, iod_node):
|
|
387
386
|
macros = {}
|
|
388
387
|
group_macro_sections = self._find_sections_with_title_endings(
|
|
389
|
-
iod_node, (" Functional Group Macros",)
|
|
388
|
+
iod_node, (" Functional Group Macros",), depth=1
|
|
390
389
|
)
|
|
391
390
|
if len(group_macro_sections) == 1:
|
|
392
391
|
macros = self._collect_modules(group_macro_sections[0], check_rowspan=False)
|
|
393
392
|
return macros
|
|
394
393
|
|
|
395
|
-
def _find_sections_with_title_endings(self, node, title_endings):
|
|
394
|
+
def _find_sections_with_title_endings(self, node, title_endings, depth=0):
|
|
396
395
|
section_nodes = self._findall(node, ["section"])
|
|
397
396
|
found_nodes = []
|
|
398
397
|
for sections_node in section_nodes:
|
|
@@ -403,4 +402,10 @@ class Part3Reader(SpecReader):
|
|
|
403
402
|
[title.endswith(title_ending) for title_ending in title_endings]
|
|
404
403
|
):
|
|
405
404
|
found_nodes.append(sections_node)
|
|
405
|
+
if depth > 0:
|
|
406
|
+
found_nodes.extend(
|
|
407
|
+
self._find_sections_with_title_endings(
|
|
408
|
+
sections_node, title_endings, depth=depth - 1
|
|
409
|
+
)
|
|
410
|
+
)
|
|
406
411
|
return found_nodes
|
|
@@ -15,7 +15,7 @@ class Part4Reader(SpecReader):
|
|
|
15
15
|
"""Reads information from PS3.4 in docbook format."""
|
|
16
16
|
|
|
17
17
|
def __init__(self, spec_dir):
|
|
18
|
-
super(
|
|
18
|
+
super().__init__(spec_dir)
|
|
19
19
|
self.part_nr = 4
|
|
20
20
|
self._sop_class_uids = {} # SOP Class UID --> chapter
|
|
21
21
|
self._chapters = {} # chapter --> SOP Class UID list
|
|
@@ -11,7 +11,7 @@ class Part6Reader(SpecReader):
|
|
|
11
11
|
"""Reads information from PS3.4 in docbook format."""
|
|
12
12
|
|
|
13
13
|
def __init__(self, spec_dir):
|
|
14
|
-
super(
|
|
14
|
+
super().__init__(spec_dir)
|
|
15
15
|
self.part_nr = 6
|
|
16
16
|
self._uids = None
|
|
17
17
|
self._data_elements = None
|
{dicom_validator-0.7.0 → dicom_validator-0.7.2}/dicom_validator/tests/spec_reader/test_condition.py
RENAMED
|
@@ -91,7 +91,7 @@ class TestConditionRead:
|
|
|
91
91
|
)
|
|
92
92
|
|
|
93
93
|
condition = test_condition()
|
|
94
|
-
cond_dict = condition.
|
|
94
|
+
cond_dict = condition.result_dict()
|
|
95
95
|
test_condition()
|
|
96
96
|
assert (
|
|
97
97
|
condition.to_string(dict_info) == 'Dose Summation Type is equal to "BEAM", '
|
|
@@ -117,7 +117,7 @@ class TestConditionRead:
|
|
|
117
117
|
)
|
|
118
118
|
|
|
119
119
|
condition = test_condition()
|
|
120
|
-
cond_dict = condition.
|
|
120
|
+
cond_dict = condition.result_dict()
|
|
121
121
|
test_condition()
|
|
122
122
|
assert condition.to_string(dict_info) == "Number of Frames is greater than 1"
|
|
123
123
|
|
|
@@ -140,7 +140,7 @@ class TestConditionRead:
|
|
|
140
140
|
)
|
|
141
141
|
|
|
142
142
|
condition = test_condition()
|
|
143
|
-
cond_dict = condition.
|
|
143
|
+
cond_dict = condition.result_dict()
|
|
144
144
|
test_condition()
|
|
145
145
|
assert condition.to_string(dict_info) == "Number of Frames is less than 20"
|
|
146
146
|
|
|
@@ -163,7 +163,7 @@ class TestConditionRead:
|
|
|
163
163
|
)
|
|
164
164
|
|
|
165
165
|
condition = test_condition()
|
|
166
|
-
cond_dict = condition.
|
|
166
|
+
cond_dict = condition.result_dict()
|
|
167
167
|
test_condition()
|
|
168
168
|
assert (
|
|
169
169
|
condition.to_string(dict_info) == "Frame Increment Pointer points to "
|
|
@@ -187,7 +187,7 @@ class TestConditionRead:
|
|
|
187
187
|
)
|
|
188
188
|
|
|
189
189
|
condition = test_condition()
|
|
190
|
-
cond_dict = condition.
|
|
190
|
+
cond_dict = condition.result_dict()
|
|
191
191
|
test_condition()
|
|
192
192
|
assert condition.to_string(dict_info) == "Pixel Data exists"
|
|
193
193
|
|
|
@@ -228,7 +228,7 @@ class TestConditionRead:
|
|
|
228
228
|
return cond
|
|
229
229
|
|
|
230
230
|
condition = test_condition()
|
|
231
|
-
cond_dict = condition.
|
|
231
|
+
cond_dict = condition.result_dict()
|
|
232
232
|
test_condition()
|
|
233
233
|
assert (
|
|
234
234
|
condition.to_string(dict_info)
|
|
@@ -259,7 +259,7 @@ class TestConditionRead:
|
|
|
259
259
|
return cond
|
|
260
260
|
|
|
261
261
|
condition = test_condition()
|
|
262
|
-
cond_dict = condition.
|
|
262
|
+
cond_dict = condition.result_dict()
|
|
263
263
|
test_condition()
|
|
264
264
|
assert (
|
|
265
265
|
condition.to_string(dict_info)
|
|
@@ -297,5 +297,5 @@ class TestConditionRead:
|
|
|
297
297
|
return cond
|
|
298
298
|
|
|
299
299
|
condition = test_condition()
|
|
300
|
-
cond_dict = condition.
|
|
300
|
+
cond_dict = condition.result_dict()
|
|
301
301
|
test_condition()
|
|
@@ -392,6 +392,13 @@ class TestValueConditionParser:
|
|
|
392
392
|
assert result.operator == ConditionOperator.EqualsValue
|
|
393
393
|
assert result.values == ["CONSTANT"]
|
|
394
394
|
|
|
395
|
+
def test_value_type_is(self, parser):
|
|
396
|
+
result = parser.parse("Required if Value Type (0040,A040) is DATETIME")
|
|
397
|
+
assert result.type == ConditionType.MandatoryOrUserDefined
|
|
398
|
+
assert result.tag == "(0040,A040)"
|
|
399
|
+
assert result.operator == ConditionOperator.EqualsValue
|
|
400
|
+
assert result.values == ["DATETIME"]
|
|
401
|
+
|
|
395
402
|
def test_value_is(self, parser):
|
|
396
403
|
result = parser.parse("Required if Observer Type value is DEV")
|
|
397
404
|
assert result.type == ConditionType.MandatoryOrUserDefined
|
|
@@ -399,6 +406,25 @@ class TestValueConditionParser:
|
|
|
399
406
|
assert result.operator == ConditionOperator.EqualsValue
|
|
400
407
|
assert result.values == ["DEV"]
|
|
401
408
|
|
|
409
|
+
@staticmethod
|
|
410
|
+
def check_the_value_of_is(result):
|
|
411
|
+
assert result.type == ConditionType.MandatoryOrUserDefined
|
|
412
|
+
assert result.tag == "(0008,010B)"
|
|
413
|
+
assert result.operator == ConditionOperator.EqualsValue
|
|
414
|
+
assert result.values == ["Y"]
|
|
415
|
+
|
|
416
|
+
def test_the_value_of_is(self, parser):
|
|
417
|
+
result = parser.parse(
|
|
418
|
+
'Required if the value of Context Group Extension Flag (0008,010B) is "Y".'
|
|
419
|
+
)
|
|
420
|
+
self.check_the_value_of_is(result)
|
|
421
|
+
|
|
422
|
+
def test_the_uppercase_value_of_is(self, parser):
|
|
423
|
+
result = parser.parse(
|
|
424
|
+
'Required if the Value of Context Group Extension Flag (0008,010B) is "Y".'
|
|
425
|
+
)
|
|
426
|
+
self.check_the_value_of_is(result)
|
|
427
|
+
|
|
402
428
|
def test_present_with_value_other_than(self, parser):
|
|
403
429
|
result = parser.parse(
|
|
404
430
|
"Required if Data Path Assignment (0028,1402) is present with a value "
|
|
@@ -729,16 +755,26 @@ class TestValueConditionParser:
|
|
|
729
755
|
assert result.tag == "(006A,0007)"
|
|
730
756
|
assert result.values == ["AUTOMATIC", "SEMIAUTOMATIC"]
|
|
731
757
|
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
"Required if the third value of Image Type (0008,0008) is FLUENCE."
|
|
735
|
-
)
|
|
758
|
+
@staticmethod
|
|
759
|
+
def check_third_value(result):
|
|
736
760
|
assert result.type == ConditionType.MandatoryOrUserDefined
|
|
737
761
|
assert result.operator == ConditionOperator.EqualsValue
|
|
738
762
|
assert result.tag == "(0008,0008)"
|
|
739
763
|
assert result.values == ["FLUENCE"]
|
|
740
764
|
assert result.index == 2
|
|
741
765
|
|
|
766
|
+
def test_third_value(self, parser):
|
|
767
|
+
result = parser.parse(
|
|
768
|
+
"Required if the third value of Image Type (0008,0008) is FLUENCE."
|
|
769
|
+
)
|
|
770
|
+
self.check_third_value(result)
|
|
771
|
+
|
|
772
|
+
def test_third_value_uppercase(self, parser):
|
|
773
|
+
result = parser.parse(
|
|
774
|
+
"Required if The third Value of Image Type (0008,0008) is FLUENCE."
|
|
775
|
+
)
|
|
776
|
+
self.check_third_value(result)
|
|
777
|
+
|
|
742
778
|
def test_value_3(self, parser):
|
|
743
779
|
result = parser.parse(
|
|
744
780
|
"Required if Value 3 of Image Type (0008,0008) is SIMULATOR or PORTAL."
|
|
@@ -934,13 +970,8 @@ class TestCompositeConditionParser:
|
|
|
934
970
|
assert result2.operator == ConditionOperator.NotEqualsValue
|
|
935
971
|
assert result2.values == ["MANUAL", "PDR"]
|
|
936
972
|
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
"Required if Frame Type (0008,9007) Value 1 of this frame is ORIGINAL, "
|
|
940
|
-
"or if Image Type (0008,0008) Value 1 is ORIGINAL and "
|
|
941
|
-
"Multi-energy CT Acquisition (0018,9361) is YES. "
|
|
942
|
-
"May be present otherwise."
|
|
943
|
-
)
|
|
973
|
+
@staticmethod
|
|
974
|
+
def check_combined_or_plus_and_with_of_this_frame(result):
|
|
944
975
|
assert result.type == ConditionType.MandatoryOrUserDefined
|
|
945
976
|
assert len(result.or_conditions) == 2
|
|
946
977
|
result1 = result.or_conditions[0]
|
|
@@ -958,6 +989,24 @@ class TestCompositeConditionParser:
|
|
|
958
989
|
assert and_result2.operator == ConditionOperator.EqualsValue
|
|
959
990
|
assert and_result2.values == ["YES"]
|
|
960
991
|
|
|
992
|
+
def test_combined_or_plus_and_with_of_this_frame(self, parser):
|
|
993
|
+
result = parser.parse(
|
|
994
|
+
"Required if Frame Type (0008,9007) Value 1 of this frame is ORIGINAL, "
|
|
995
|
+
"or if Image Type (0008,0008) Value 1 is ORIGINAL and "
|
|
996
|
+
"Multi-energy CT Acquisition (0018,9361) is YES. "
|
|
997
|
+
"May be present otherwise."
|
|
998
|
+
)
|
|
999
|
+
self.check_combined_or_plus_and_with_of_this_frame(result)
|
|
1000
|
+
|
|
1001
|
+
def test_combined_or_plus_and_with_of_this_frame_uppercase(self, parser):
|
|
1002
|
+
result = parser.parse(
|
|
1003
|
+
"Required if Frame Type (0008,9007) Value 1 of this Frame is ORIGINAL, "
|
|
1004
|
+
"or if Image Type (0008,0008) Value 1 is ORIGINAL and "
|
|
1005
|
+
"Multi-energy CT Acquisition (0018,9361) is YES. "
|
|
1006
|
+
"May be present otherwise."
|
|
1007
|
+
)
|
|
1008
|
+
self.check_combined_or_plus_and_with_of_this_frame(result)
|
|
1009
|
+
|
|
961
1010
|
def test_and_with_multiple_values(self, parser):
|
|
962
1011
|
result = parser.parse(
|
|
963
1012
|
"Required if Image Type (0008,0008) Value 1 is ORIGINAL or MIXED "
|
|
@@ -1158,17 +1207,29 @@ class TestCompositeConditionParser:
|
|
|
1158
1207
|
assert result_part.values
|
|
1159
1208
|
assert result_part.values[0] == "1"
|
|
1160
1209
|
|
|
1210
|
+
@staticmethod
|
|
1211
|
+
def check_is_present_with_value(result):
|
|
1212
|
+
assert result.type == ConditionType.MandatoryOrUserDefined
|
|
1213
|
+
assert len(result.and_conditions) == 2
|
|
1214
|
+
assert result.and_conditions[0].operator == ConditionOperator.EqualsValue
|
|
1215
|
+
assert result.and_conditions[0].values[0] == "YES"
|
|
1216
|
+
assert result.and_conditions[1].operator == ConditionOperator.Absent
|
|
1217
|
+
|
|
1161
1218
|
def test_is_present_with_value(self, parser):
|
|
1162
1219
|
result = parser.parse(
|
|
1163
1220
|
"Required if Patient Identity Removed (0012,0062) is present and "
|
|
1164
1221
|
"has a value of YES and De-identification Method Code Sequence "
|
|
1165
1222
|
"(0012,0064) is not present."
|
|
1166
1223
|
)
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1224
|
+
self.check_is_present_with_value(result)
|
|
1225
|
+
|
|
1226
|
+
def test_is_present_with_uppercase_value(self, parser):
|
|
1227
|
+
result = parser.parse(
|
|
1228
|
+
"Required if Patient Identity Removed (0012,0062) is present and "
|
|
1229
|
+
"has a Value of YES and De-identification Method Code Sequence "
|
|
1230
|
+
"(0012,0064) is not present."
|
|
1231
|
+
)
|
|
1232
|
+
self.check_is_present_with_value(result)
|
|
1172
1233
|
|
|
1173
1234
|
def test_or_condition_with_space(self, parser):
|
|
1174
1235
|
result = parser.parse(
|
|
@@ -50,7 +50,7 @@ class TestReadPart3:
|
|
|
50
50
|
|
|
51
51
|
@pytest.mark.parametrize(
|
|
52
52
|
"revision,iod_name",
|
|
53
|
-
[("2015b", "Computed Tomography Image IOD"), ("
|
|
53
|
+
[("2015b", "Computed Tomography Image IOD"), ("2025c", "CT Image IOD")],
|
|
54
54
|
indirect=["revision"],
|
|
55
55
|
scope="session",
|
|
56
56
|
)
|
|
@@ -64,7 +64,7 @@ class TestReadPart3:
|
|
|
64
64
|
|
|
65
65
|
@pytest.mark.parametrize(
|
|
66
66
|
"revision,module_nr",
|
|
67
|
-
[("2015b", 27), ("
|
|
67
|
+
[("2015b", 27), ("2025c", 29)],
|
|
68
68
|
indirect=["revision"],
|
|
69
69
|
scope="session",
|
|
70
70
|
)
|
|
@@ -78,7 +78,7 @@ class TestReadPart3:
|
|
|
78
78
|
assert module["ref"] == "C.7.5.1"
|
|
79
79
|
assert module["use"] == "M"
|
|
80
80
|
|
|
81
|
-
@pytest.mark.parametrize("revision", ["2015b", "
|
|
81
|
+
@pytest.mark.parametrize("revision", ["2015b", "2025c"], indirect=True)
|
|
82
82
|
def test_optional_iod_module(self, reader):
|
|
83
83
|
description = reader.iod_description(chapter="A.38.1")
|
|
84
84
|
assert "modules" in description
|
|
@@ -90,7 +90,7 @@ class TestReadPart3:
|
|
|
90
90
|
|
|
91
91
|
@pytest.mark.parametrize(
|
|
92
92
|
"revision,desc_nr",
|
|
93
|
-
[("2015b", 110), ("
|
|
93
|
+
[("2015b", 110), ("2025c", 174)],
|
|
94
94
|
indirect=["revision"],
|
|
95
95
|
scope="session",
|
|
96
96
|
)
|
|
@@ -103,7 +103,7 @@ class TestReadPart3:
|
|
|
103
103
|
|
|
104
104
|
@pytest.mark.parametrize(
|
|
105
105
|
"revision,macro_nr",
|
|
106
|
-
[("2015b", 24), ("
|
|
106
|
+
[("2015b", 24), ("2025c", 28)],
|
|
107
107
|
indirect=["revision"],
|
|
108
108
|
scope="session",
|
|
109
109
|
)
|
|
@@ -135,9 +135,27 @@ class TestReadPart3:
|
|
|
135
135
|
assert condition.tag == "(0008,0008)"
|
|
136
136
|
assert condition.values == ["ORIGINAL", "MIXED"]
|
|
137
137
|
|
|
138
|
+
def test_nested_group_macros(self, reader):
|
|
139
|
+
descriptions = reader.iod_descriptions()
|
|
140
|
+
# the Ophthalmic Optical Coherence Tomography B-scan Volume Analysis IOD
|
|
141
|
+
# is found at a level below the usual one
|
|
142
|
+
macros = descriptions["A.84"]["group_macros"]
|
|
143
|
+
assert len(macros) == 9
|
|
144
|
+
|
|
145
|
+
# the RT Second Generation IODs are at a lower level than usual
|
|
146
|
+
assert "A.86.1.14" in descriptions
|
|
147
|
+
macros = descriptions["A.86.1.14"]["group_macros"]
|
|
148
|
+
assert not macros
|
|
149
|
+
assert "A.86.1.15" in descriptions
|
|
150
|
+
macros = descriptions["A.86.1.15"]["group_macros"]
|
|
151
|
+
assert len(macros) == 16
|
|
152
|
+
assert "A.86.1.16" in descriptions
|
|
153
|
+
macros = descriptions["A.86.1.16"]["group_macros"]
|
|
154
|
+
assert len(macros) == 16
|
|
155
|
+
|
|
138
156
|
@pytest.mark.parametrize(
|
|
139
157
|
"revision,desc_nr",
|
|
140
|
-
[("2015b", 9), ("
|
|
158
|
+
[("2015b", 9), ("2025c", 14)],
|
|
141
159
|
indirect=["revision"],
|
|
142
160
|
scope="session",
|
|
143
161
|
)
|
|
@@ -152,7 +170,7 @@ class TestReadPart3:
|
|
|
152
170
|
|
|
153
171
|
@pytest.mark.parametrize(
|
|
154
172
|
"revision,desc_nr, seq_desc_nr",
|
|
155
|
-
[("2015b", 3, 3), ("
|
|
173
|
+
[("2015b", 3, 3), ("2025c", 7, 4)],
|
|
156
174
|
indirect=["revision"],
|
|
157
175
|
scope="session",
|
|
158
176
|
)
|
|
@@ -183,7 +201,7 @@ class TestReadPart3:
|
|
|
183
201
|
|
|
184
202
|
@pytest.mark.parametrize(
|
|
185
203
|
"revision,desc_nr",
|
|
186
|
-
[("2015b",
|
|
204
|
+
[("2015b", 452), ("2025c", 667)],
|
|
187
205
|
indirect=["revision"],
|
|
188
206
|
scope="session",
|
|
189
207
|
)
|
|
@@ -193,7 +211,7 @@ class TestReadPart3:
|
|
|
193
211
|
|
|
194
212
|
@pytest.mark.parametrize(
|
|
195
213
|
"revision,include_nr",
|
|
196
|
-
[("2015b", 9), ("
|
|
214
|
+
[("2015b", 9), ("2025c", 10)],
|
|
197
215
|
indirect=["revision"],
|
|
198
216
|
scope="session",
|
|
199
217
|
)
|
|
@@ -226,7 +244,7 @@ class TestReadPart3:
|
|
|
226
244
|
assert enums == [{"val": ["FAILURE", "WARNING", "INFORMATIVE"]}]
|
|
227
245
|
|
|
228
246
|
@pytest.mark.parametrize(
|
|
229
|
-
"revision", ["2015b", "
|
|
247
|
+
"revision", ["2015b", "2025c"], indirect=True, scope="session"
|
|
230
248
|
)
|
|
231
249
|
def test_linked_enum_values(self, reader):
|
|
232
250
|
description = reader.module_description("10.24")
|
|
@@ -239,7 +257,7 @@ class TestReadPart3:
|
|
|
239
257
|
assert tag["enums"] == [{"val": ["CONTINUOUS", "TRIGGERED", "AUTOMATIC"]}]
|
|
240
258
|
|
|
241
259
|
@pytest.mark.parametrize(
|
|
242
|
-
"revision", ["2015b", "
|
|
260
|
+
"revision", ["2015b", "2025c"], indirect=True, scope="session"
|
|
243
261
|
)
|
|
244
262
|
def test_graphic_annotation_sequence(self, reader):
|
|
245
263
|
description = reader.module_description("C.10.5")
|
|
@@ -15,11 +15,11 @@ class TestPart6Reader:
|
|
|
15
15
|
|
|
16
16
|
def test_data_elements(self, dict_reader):
|
|
17
17
|
elements = dict_reader.data_elements()
|
|
18
|
-
assert len(elements) ==
|
|
18
|
+
assert len(elements) == 5250
|
|
19
19
|
|
|
20
20
|
def test_sop_class_uids(self, dict_reader):
|
|
21
21
|
sop_class_uids = dict_reader.sop_class_uids()
|
|
22
|
-
assert len(sop_class_uids) ==
|
|
22
|
+
assert len(sop_class_uids) == 311
|
|
23
23
|
assert "1.2.840.10008.1.1" in sop_class_uids
|
|
24
24
|
assert sop_class_uids["1.2.840.10008.1.1"] == "Verification SOP Class"
|
|
25
25
|
|
|
@@ -38,7 +38,7 @@ class TestPart6Reader:
|
|
|
38
38
|
assert "Transfer Syntax" in uids
|
|
39
39
|
assert "SOP Class" in uids
|
|
40
40
|
uid_nr = sum([len(uid_dict) for uid_dict in uids.values()])
|
|
41
|
-
assert uid_nr ==
|
|
41
|
+
assert uid_nr == 465
|
|
42
42
|
|
|
43
43
|
def test_sop_class_name(self, dict_reader):
|
|
44
44
|
assert (
|
|
@@ -22,7 +22,7 @@ def dicom_fixture_path(fixture_path):
|
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
@pytest.mark.order(0)
|
|
25
|
-
@pytest.mark.parametrize("revision", ["2015b", "
|
|
25
|
+
@pytest.mark.parametrize("revision", ["2015b", "2025c"])
|
|
26
26
|
def test_validate_sr(revision, caplog, standard_path, dicom_fixture_path):
|
|
27
27
|
# test also for 2015b to test an issue causing an exception
|
|
28
28
|
rtdose_path = dicom_fixture_path / "rtdose.dcm"
|
|
@@ -166,7 +166,9 @@ class TestIODValidatorFuncGroups:
|
|
|
166
166
|
def test_macro_not_allowed_in_shared_group(self, validator):
|
|
167
167
|
result = validator.validate()
|
|
168
168
|
# Frame Anatomy Sequence (present in shared groups)
|
|
169
|
-
assert has_tag_error(
|
|
169
|
+
assert has_tag_error(
|
|
170
|
+
result, "Frame Content", "(0020,9111)", "not allowed in Shared Group"
|
|
171
|
+
)
|
|
170
172
|
|
|
171
173
|
@pytest.mark.shared_macros([])
|
|
172
174
|
@pytest.mark.per_frame_macros([PIXEL_MEASURES])
|
|
@@ -224,10 +224,13 @@ class IODValidator:
|
|
|
224
224
|
is_per_frame = self._in_per_frame_group
|
|
225
225
|
|
|
226
226
|
allowed = True
|
|
227
|
+
msg_postfix = ""
|
|
227
228
|
if condition and "F" in condition["type"] and is_shared:
|
|
228
229
|
required, allowed = False, False
|
|
230
|
+
msg_postfix = " in Shared Group"
|
|
229
231
|
elif condition and "S" in condition["type"] and is_per_frame:
|
|
230
232
|
required, allowed = False, False
|
|
233
|
+
msg_postfix = " in Per-Frame Group"
|
|
231
234
|
elif usage[0] == "M":
|
|
232
235
|
required = True
|
|
233
236
|
elif usage[0] == ConditionType.UserDefined:
|
|
@@ -280,7 +283,9 @@ class IODValidator:
|
|
|
280
283
|
for tag_id_string in module_info:
|
|
281
284
|
tag_id = self._tag_id(tag_id_string)
|
|
282
285
|
if tag_id in self._dataset_stack[-1].dataset:
|
|
283
|
-
message = self._incorrect_tag_message(
|
|
286
|
+
message = self._incorrect_tag_message(
|
|
287
|
+
tag_id, "not allowed" + msg_postfix
|
|
288
|
+
)
|
|
284
289
|
errors.setdefault(message, []).append(tag_id_string)
|
|
285
290
|
return errors
|
|
286
291
|
return self._validate_attributes(module_info, False)
|
|
@@ -652,7 +657,7 @@ class IODValidator:
|
|
|
652
657
|
def _tag_context_message(self):
|
|
653
658
|
if len(self._dataset_stack) > 1:
|
|
654
659
|
m = " > ".join([item.name for item in self._dataset_stack])
|
|
655
|
-
context = f" in
|
|
660
|
+
context = f" in {m}"
|
|
656
661
|
return context
|
|
657
662
|
return ""
|
|
658
663
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dicom-validator
|
|
3
|
-
Version: 0.7.
|
|
3
|
+
Version: 0.7.2
|
|
4
4
|
Summary: Python DICOM validator using input from DICOM specs in docbook format
|
|
5
5
|
Author-email: mrbean-bremen and contributors <hansemrbean@googlemail.com>
|
|
6
6
|
License: MIT
|
|
@@ -27,12 +27,13 @@ Classifier: Topic :: Scientific/Engineering :: Medical Science Apps.
|
|
|
27
27
|
Requires-Python: >=3.9
|
|
28
28
|
Description-Content-Type: text/markdown
|
|
29
29
|
License-File: LICENSE
|
|
30
|
-
Requires-Dist: pydicom
|
|
30
|
+
Requires-Dist: pydicom>=2.3
|
|
31
31
|
Requires-Dist: lxml
|
|
32
32
|
Requires-Dist: pyparsing>=3.2
|
|
33
33
|
Provides-Extra: dev
|
|
34
34
|
Requires-Dist: pyfakefs>=5.0.0; extra == "dev"
|
|
35
35
|
Requires-Dist: pytest; extra == "dev"
|
|
36
|
+
Requires-Dist: pytest-order; extra == "dev"
|
|
36
37
|
Dynamic: license-file
|
|
37
38
|
|
|
38
39
|
# dicom-validator
|
|
@@ -26,7 +26,7 @@ classifiers = [
|
|
|
26
26
|
"Topic :: Scientific/Engineering :: Medical Science Apps.",
|
|
27
27
|
]
|
|
28
28
|
dependencies = [
|
|
29
|
-
"pydicom",
|
|
29
|
+
"pydicom>=2.3",
|
|
30
30
|
"lxml",
|
|
31
31
|
"pyparsing>=3.2"
|
|
32
32
|
]
|
|
@@ -42,6 +42,7 @@ dynamic = ["version"]
|
|
|
42
42
|
dev = [
|
|
43
43
|
"pyfakefs>=5.0.0",
|
|
44
44
|
"pytest",
|
|
45
|
+
"pytest-order"
|
|
45
46
|
]
|
|
46
47
|
|
|
47
48
|
[project.urls]
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.7.0"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{dicom_validator-0.7.0 → dicom_validator-0.7.2}/dicom_validator/spec_reader/edition_reader.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{dicom_validator-0.7.0 → dicom_validator-0.7.2}/dicom_validator/tests/spec_reader/__init__.py
RENAMED
|
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
|
{dicom_validator-0.7.0 → dicom_validator-0.7.2}/dicom_validator/validator/dicom_file_validator.py
RENAMED
|
File without changes
|
|
File without changes
|
{dicom_validator-0.7.0 → dicom_validator-0.7.2}/dicom_validator.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|