dicom-validator 0.7.2__tar.gz → 0.7.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.
Files changed (48) hide show
  1. {dicom_validator-0.7.2 → dicom_validator-0.7.3}/PKG-INFO +1 -1
  2. dicom_validator-0.7.3/dicom_validator/__init__.py +1 -0
  3. {dicom_validator-0.7.2 → dicom_validator-0.7.3}/dicom_validator/spec_reader/part3_reader.py +9 -9
  4. {dicom_validator-0.7.2 → dicom_validator-0.7.3}/dicom_validator/tests/spec_reader/conftest.py +1 -1
  5. {dicom_validator-0.7.2 → dicom_validator-0.7.3}/dicom_validator/tests/spec_reader/test_part3_reader.py +11 -11
  6. {dicom_validator-0.7.2 → dicom_validator-0.7.3}/dicom_validator/tests/spec_reader/test_part6_reader.py +1 -1
  7. {dicom_validator-0.7.2 → dicom_validator-0.7.3}/dicom_validator/tests/test_cmdline_tools.py +1 -1
  8. {dicom_validator-0.7.2 → dicom_validator-0.7.3}/dicom_validator/tests/validator/conftest.py +1 -1
  9. {dicom_validator-0.7.2 → dicom_validator-0.7.3}/dicom_validator/tests/validator/test_iod_validator.py +42 -4
  10. {dicom_validator-0.7.2 → dicom_validator-0.7.3}/dicom_validator/tests/validator/test_iod_validator_func_groups.py +12 -1
  11. {dicom_validator-0.7.2 → dicom_validator-0.7.3}/dicom_validator/validator/iod_validator.py +21 -4
  12. {dicom_validator-0.7.2 → dicom_validator-0.7.3}/dicom_validator.egg-info/PKG-INFO +1 -1
  13. dicom_validator-0.7.2/dicom_validator/__init__.py +0 -1
  14. {dicom_validator-0.7.2 → dicom_validator-0.7.3}/LICENSE +0 -0
  15. {dicom_validator-0.7.2 → dicom_validator-0.7.3}/README.md +0 -0
  16. {dicom_validator-0.7.2 → dicom_validator-0.7.3}/dicom_validator/dump_dcm_info.py +0 -0
  17. {dicom_validator-0.7.2 → dicom_validator-0.7.3}/dicom_validator/spec_reader/__init__.py +0 -0
  18. {dicom_validator-0.7.2 → dicom_validator-0.7.3}/dicom_validator/spec_reader/condition.py +0 -0
  19. {dicom_validator-0.7.2 → dicom_validator-0.7.3}/dicom_validator/spec_reader/condition_grammar.py +0 -0
  20. {dicom_validator-0.7.2 → dicom_validator-0.7.3}/dicom_validator/spec_reader/condition_parser.py +0 -0
  21. {dicom_validator-0.7.2 → dicom_validator-0.7.3}/dicom_validator/spec_reader/edition_reader.py +0 -0
  22. {dicom_validator-0.7.2 → dicom_validator-0.7.3}/dicom_validator/spec_reader/enum_parser.py +0 -0
  23. {dicom_validator-0.7.2 → dicom_validator-0.7.3}/dicom_validator/spec_reader/part4_reader.py +0 -0
  24. {dicom_validator-0.7.2 → dicom_validator-0.7.3}/dicom_validator/spec_reader/part6_reader.py +0 -0
  25. {dicom_validator-0.7.2 → dicom_validator-0.7.3}/dicom_validator/spec_reader/serializer.py +0 -0
  26. {dicom_validator-0.7.2 → dicom_validator-0.7.3}/dicom_validator/spec_reader/spec_reader.py +0 -0
  27. {dicom_validator-0.7.2 → dicom_validator-0.7.3}/dicom_validator/tag_tools.py +0 -0
  28. {dicom_validator-0.7.2 → dicom_validator-0.7.3}/dicom_validator/tests/__init__.py +0 -0
  29. {dicom_validator-0.7.2 → dicom_validator-0.7.3}/dicom_validator/tests/spec_reader/__init__.py +0 -0
  30. {dicom_validator-0.7.2 → dicom_validator-0.7.3}/dicom_validator/tests/spec_reader/test_condition.py +0 -0
  31. {dicom_validator-0.7.2 → dicom_validator-0.7.3}/dicom_validator/tests/spec_reader/test_condition_parser.py +0 -0
  32. {dicom_validator-0.7.2 → dicom_validator-0.7.3}/dicom_validator/tests/spec_reader/test_edition_reader.py +0 -0
  33. {dicom_validator-0.7.2 → dicom_validator-0.7.3}/dicom_validator/tests/spec_reader/test_enum_parser.py +0 -0
  34. {dicom_validator-0.7.2 → dicom_validator-0.7.3}/dicom_validator/tests/spec_reader/test_part4_reader.py +0 -0
  35. {dicom_validator-0.7.2 → dicom_validator-0.7.3}/dicom_validator/tests/spec_reader/test_spec_reader.py +0 -0
  36. {dicom_validator-0.7.2 → dicom_validator-0.7.3}/dicom_validator/tests/utils.py +0 -0
  37. {dicom_validator-0.7.2 → dicom_validator-0.7.3}/dicom_validator/tests/validator/__init__.py +0 -0
  38. {dicom_validator-0.7.2 → dicom_validator-0.7.3}/dicom_validator/tests/validator/test_dicom_file_validator.py +0 -0
  39. {dicom_validator-0.7.2 → dicom_validator-0.7.3}/dicom_validator/validate_iods.py +0 -0
  40. {dicom_validator-0.7.2 → dicom_validator-0.7.3}/dicom_validator/validator/__init__.py +0 -0
  41. {dicom_validator-0.7.2 → dicom_validator-0.7.3}/dicom_validator/validator/dicom_file_validator.py +0 -0
  42. {dicom_validator-0.7.2 → dicom_validator-0.7.3}/dicom_validator.egg-info/SOURCES.txt +0 -0
  43. {dicom_validator-0.7.2 → dicom_validator-0.7.3}/dicom_validator.egg-info/dependency_links.txt +0 -0
  44. {dicom_validator-0.7.2 → dicom_validator-0.7.3}/dicom_validator.egg-info/entry_points.txt +0 -0
  45. {dicom_validator-0.7.2 → dicom_validator-0.7.3}/dicom_validator.egg-info/requires.txt +0 -0
  46. {dicom_validator-0.7.2 → dicom_validator-0.7.3}/dicom_validator.egg-info/top_level.txt +0 -0
  47. {dicom_validator-0.7.2 → dicom_validator-0.7.3}/pyproject.toml +0 -0
  48. {dicom_validator-0.7.2 → dicom_validator-0.7.3}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dicom-validator
3
- Version: 0.7.2
3
+ Version: 0.7.3
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
@@ -0,0 +1 @@
1
+ __version__ = "0.7.3"
@@ -212,9 +212,9 @@ class Part3Reader(SpecReader):
212
212
  include_node = self._find(columns[0], ["para", "emphasis", "xref"])
213
213
  if include_node is None:
214
214
  description = self._find_text(columns[0])
215
- is_func_group = (
216
- description
217
- and "Include one or more Functional Group Macros" in description
215
+ is_func_group = description and (
216
+ "Include one or more Functional Group Macros" in description
217
+ or "Include zero or more Functional Group Macros" in description
218
218
  )
219
219
  if is_func_group:
220
220
  # add a placeholder - has to be evaluated at validation time
@@ -223,9 +223,7 @@ class Part3Reader(SpecReader):
223
223
  )
224
224
  return
225
225
  include_ref = include_node.attrib["linkend"]
226
- if self._current_refs and include_ref == self._current_refs[-1]:
227
- self.logger.debug("Self reference in %s - ignoring.", include_ref)
228
- return
226
+ recursive = bool(self._current_refs) and (include_ref == self._current_refs[-1])
229
227
  self._current_refs.append(include_ref)
230
228
  element, label = self._get_ref_element_and_label(include_ref)
231
229
  if label not in self._module_descriptions:
@@ -234,9 +232,11 @@ class Part3Reader(SpecReader):
234
232
  raise SpecReaderLookupError(
235
233
  "Failed to lookup include reference " + include_ref
236
234
  )
237
- # it is allowed to have no attributes (example: Raw Data)
238
- ref_description = self._parse_module_description(ref_node) or {}
239
- self._module_descriptions[label] = ref_description
235
+ # recursive reference - prevent recursion
236
+ if not recursive:
237
+ # it is allowed to have no attributes (example: Raw Data)
238
+ ref_description = self._parse_module_description(ref_node) or {}
239
+ self._module_descriptions[label] = ref_description
240
240
  include_attr = {"ref": label}
241
241
  # this is currently the only occurring condition for includes
242
242
  cond_prefix = "if and only if "
@@ -3,7 +3,7 @@ from pathlib import Path
3
3
 
4
4
  import pytest
5
5
 
6
- CURRENT_REVISION = "2025c"
6
+ CURRENT_REVISION = "2025d"
7
7
 
8
8
 
9
9
  def pytest_configure(config):
@@ -50,7 +50,7 @@ class TestReadPart3:
50
50
 
51
51
  @pytest.mark.parametrize(
52
52
  "revision,iod_name",
53
- [("2015b", "Computed Tomography Image IOD"), ("2025c", "CT Image IOD")],
53
+ [("2015b", "Computed Tomography Image IOD"), ("2025d", "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), ("2025c", 29)],
67
+ [("2015b", 27), ("2025d", 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", "2025c"], indirect=True)
81
+ @pytest.mark.parametrize("revision", ["2015b", "2025d"], 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), ("2025c", 174)],
93
+ [("2015b", 110), ("2025d", 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), ("2025c", 28)],
106
+ [("2015b", 24), ("2025d", 28)],
107
107
  indirect=["revision"],
108
108
  scope="session",
109
109
  )
@@ -155,7 +155,7 @@ class TestReadPart3:
155
155
 
156
156
  @pytest.mark.parametrize(
157
157
  "revision,desc_nr",
158
- [("2015b", 9), ("2025c", 14)],
158
+ [("2015b", 9), ("2025d", 14)],
159
159
  indirect=["revision"],
160
160
  scope="session",
161
161
  )
@@ -170,7 +170,7 @@ class TestReadPart3:
170
170
 
171
171
  @pytest.mark.parametrize(
172
172
  "revision,desc_nr, seq_desc_nr",
173
- [("2015b", 3, 3), ("2025c", 7, 4)],
173
+ [("2015b", 3, 3), ("2025d", 7, 4)],
174
174
  indirect=["revision"],
175
175
  scope="session",
176
176
  )
@@ -201,7 +201,7 @@ class TestReadPart3:
201
201
 
202
202
  @pytest.mark.parametrize(
203
203
  "revision,desc_nr",
204
- [("2015b", 452), ("2025c", 667)],
204
+ [("2015b", 452), ("2025d", 671)],
205
205
  indirect=["revision"],
206
206
  scope="session",
207
207
  )
@@ -211,7 +211,7 @@ class TestReadPart3:
211
211
 
212
212
  @pytest.mark.parametrize(
213
213
  "revision,include_nr",
214
- [("2015b", 9), ("2025c", 10)],
214
+ [("2015b", 9), ("2025d", 10)],
215
215
  indirect=["revision"],
216
216
  scope="session",
217
217
  )
@@ -244,7 +244,7 @@ class TestReadPart3:
244
244
  assert enums == [{"val": ["FAILURE", "WARNING", "INFORMATIVE"]}]
245
245
 
246
246
  @pytest.mark.parametrize(
247
- "revision", ["2015b", "2025c"], indirect=True, scope="session"
247
+ "revision", ["2015b", "2025d"], indirect=True, scope="session"
248
248
  )
249
249
  def test_linked_enum_values(self, reader):
250
250
  description = reader.module_description("10.24")
@@ -257,7 +257,7 @@ class TestReadPart3:
257
257
  assert tag["enums"] == [{"val": ["CONTINUOUS", "TRIGGERED", "AUTOMATIC"]}]
258
258
 
259
259
  @pytest.mark.parametrize(
260
- "revision", ["2015b", "2025c"], indirect=True, scope="session"
260
+ "revision", ["2015b", "2025d"], indirect=True, scope="session"
261
261
  )
262
262
  def test_graphic_annotation_sequence(self, reader):
263
263
  description = reader.module_description("C.10.5")
@@ -15,7 +15,7 @@ class TestPart6Reader:
15
15
 
16
16
  def test_data_elements(self, dict_reader):
17
17
  elements = dict_reader.data_elements()
18
- assert len(elements) == 5250
18
+ assert len(elements) == 5257
19
19
 
20
20
  def test_sop_class_uids(self, dict_reader):
21
21
  sop_class_uids = dict_reader.sop_class_uids()
@@ -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", "2025c"])
25
+ @pytest.mark.parametrize("revision", ["2015b", "2025d"])
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"
@@ -7,7 +7,7 @@ import pytest
7
7
  from dicom_validator.spec_reader.edition_reader import EditionReader
8
8
  from dicom_validator.validator.iod_validator import DicomInfo
9
9
 
10
- CURRENT_REVISION = "2025c"
10
+ CURRENT_REVISION = "2025d"
11
11
 
12
12
 
13
13
  def pytest_configure(config):
@@ -1,5 +1,4 @@
1
1
  import logging
2
- from typing import Optional
3
2
 
4
3
  import pydicom
5
4
  import pytest
@@ -15,10 +14,10 @@ from dicom_validator.validator.iod_validator import IODValidator
15
14
  pytestmark = pytest.mark.usefixtures("disable_logging")
16
15
 
17
16
 
18
- def new_data_set(tags, ds: Optional[Dataset] = None):
17
+ def new_data_set(tags, *, top_level: bool = True):
19
18
  """Create a DICOM data set with the given attributes"""
20
19
  tags = tags or {}
21
- data_set = ds or Dataset()
20
+ data_set = Dataset()
22
21
  if not tags:
23
22
  return data_set
24
23
  for tag, value in tags.items():
@@ -30,9 +29,13 @@ def new_data_set(tags, ds: Optional[Dataset] = None):
30
29
  if vr == "SQ":
31
30
  items = []
32
31
  for item_tags in value:
33
- items.append(new_data_set(item_tags, data_set))
32
+ items.append(new_data_set(item_tags, top_level=False))
34
33
  value = Sequence(items)
35
34
  data_set[tag] = DataElement(tag, vr, value)
35
+ if not top_level:
36
+ # this is a sequence item
37
+ return data_set
38
+
36
39
  # write the dataset into a file and read it back to ensure the real behavior
37
40
  if "SOPInstanceUID" not in data_set:
38
41
  data_set.SOPInstanceUID = "1.2.3"
@@ -692,3 +695,38 @@ class TestIODValidator:
692
695
  "values": ["closed"],
693
696
  }
694
697
  assert validator.validate()
698
+
699
+ @pytest.mark.tag_set(
700
+ {
701
+ "SOPClassUID": uid.ComprehensiveSRStorage,
702
+ "ValueType": "CONTAINER",
703
+ "ContinuityOfContent": "SEPARATE",
704
+ "ContentSequence": [
705
+ {
706
+ "RelationshipType": "CONTAINS",
707
+ "ValueType": "CONTAINER",
708
+ "ContinuityOfContent": "SEPARATE",
709
+ "ContentSequence": [
710
+ {
711
+ "RelationshipType": "HAS OBS CONTEXT",
712
+ "ValueType": "UIDREF",
713
+ }
714
+ ],
715
+ }
716
+ ],
717
+ }
718
+ )
719
+ def test_recursive_reference(self, validator):
720
+ # regression test for #206
721
+ # Content Sequence (0040,A730) is defined recursively in SR Document Content
722
+ # and is allowed inside another Content Sequence item
723
+ result = validator.validate()
724
+ assert not has_tag_error(
725
+ result, "SR Document Content", "(0040,A730)", "unexpected"
726
+ )
727
+ # Continuity Of Content (0040,A050) is present with ValueType "CONTAINER",
728
+ # but not with ValueType "UIDREF";
729
+ # this is correct, so no error shall be shown for Continuity Of Content
730
+ assert not has_tag_error(
731
+ result, "SR Document Content", "(0040,A050)", "missing"
732
+ )
@@ -21,6 +21,12 @@ def new_data_set(shared_macros, per_frame_macros):
21
21
  data_set.ContentDate = "20000101"
22
22
  data_set.ContentTime = "120000"
23
23
  data_set.NumberOfFrames = "3"
24
+ mask_subtraction_seq = Sequence()
25
+ item = Dataset()
26
+ item.MaskOperation = "AVG_SUB"
27
+ mask_subtraction_seq.append(item)
28
+ data_set.MaskSubtractionSequence = mask_subtraction_seq
29
+
24
30
  shared_groups = Sequence()
25
31
  if shared_macros:
26
32
  item = Dataset()
@@ -149,6 +155,11 @@ class TestIODValidatorFuncGroups:
149
155
  # Referenced Image Sequence (not mandatory)
150
156
  assert not has_tag_error(result, "Referenced Image", "(0008,1140)", "missing")
151
157
 
158
+ # Subtraction Item ID, required because of the SOP Class UID value (in dataset root)
159
+ assert has_tag_error(result, "Mask", "(0028,9416)", "missing")
160
+ # Mask Frame Numbers, required because Mask Operation (inside the sequence item) is AVG_SUB
161
+ assert has_tag_error(result, "Mask", "(0028,6110)", "missing")
162
+
152
163
  @pytest.mark.shared_macros([FRAME_ANATOMY])
153
164
  @pytest.mark.per_frame_macros([FRAME_ANATOMY])
154
165
  def test_sequence_in_shared_and_per_frame(self, validator):
@@ -162,7 +173,7 @@ class TestIODValidatorFuncGroups:
162
173
  )
163
174
 
164
175
  @pytest.mark.shared_macros([FRAME_CONTENT])
165
- @pytest.mark.per_frame_macros([FRAME_ANATOMY])
176
+ @pytest.mark.per_frame_macros([FRAME_CONTENT])
166
177
  def test_macro_not_allowed_in_shared_group(self, validator):
167
178
  result = validator.validate()
168
179
  # Frame Anatomy Sequence (present in shared groups)
@@ -313,7 +313,6 @@ class IODValidator:
313
313
  The dictionary of found errors.
314
314
  """
315
315
  errors = {}
316
-
317
316
  for tag_id_string, attribute in attributes.items():
318
317
  if tag_id_string == "modules":
319
318
  self._validate_func_group_modules(attribute)
@@ -336,9 +335,21 @@ class IODValidator:
336
335
  self._dataset_stack.append(
337
336
  DatasetStackItem(sq_item_dataset, tag_id_string)
338
337
  )
339
- errors.update(
340
- self._validate_attributes(attribute["items"], True)
338
+ # the item attributes are only created at this point,
339
+ # where we have descended into the related sequence item level
340
+ item_attribute = attribute["items"]
341
+ if "group_macros" in item_attribute:
342
+ group_macros = item_attribute["group_macros"]
343
+ items = item_attribute["items"]
344
+ else:
345
+ group_macros = None
346
+ items = item_attribute
347
+ item_attributes = self._expanded_module_info(
348
+ items,
349
+ group_macros,
350
+ expand_items=True,
341
351
  )
352
+ errors.update(self._validate_attributes(item_attributes, True))
342
353
  self._dataset_stack.pop()
343
354
 
344
355
  if report_unexpected_tags:
@@ -617,7 +628,7 @@ class IODValidator:
617
628
  self._dicom_info.modules[module_ref], group_macros
618
629
  )
619
630
 
620
- def _expanded_module_info(self, module_info, group_macros):
631
+ def _expanded_module_info(self, module_info, group_macros, expand_items=False):
621
632
  expanded_mod_info = {}
622
633
  for k, v in module_info.items():
623
634
  if k == "include":
@@ -634,6 +645,12 @@ class IODValidator:
634
645
  expanded_mod_info.update(
635
646
  self._get_module_info(ref, group_macros)
636
647
  )
648
+ elif not expand_items and k == "items":
649
+ # we shall not create the item attributes at this point, because
650
+ # they may have conditions that refer to item inside the sequence,
651
+ # and we are currently at a higher dataset level
652
+ # instead, we save the information needed to create them lazily
653
+ expanded_mod_info[k] = {"items": v, "group_macros": group_macros}
637
654
  elif isinstance(v, dict):
638
655
  expanded_mod_info[k] = self._expanded_module_info(v, group_macros)
639
656
  else:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dicom-validator
3
- Version: 0.7.2
3
+ Version: 0.7.3
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
@@ -1 +0,0 @@
1
- __version__ = "0.7.2"
File without changes