31 elif name ==
"PrivateCreator":
32 name +=
" '" + tag.toString() +
"' " + tag.id()
34 name +=
" " + tag.id()
39 for tag, index
in path:
40 result += f
"in {self.tagName(tag)}, position {index} "
45 return f
"<{tag.numberOfValues()} items>"
47 return f
"'{tag.toString()}'"
52 tagString = (
", tag " + self.
tagName(tag))
if tag
else ""
58 if tag1.vr() != tag2.vr():
59 self.
dicomTagError(path, f
"Different VRs ({tag1.vr()} and {tag2.vr()})", tag1)
61 elif tag1.isSequence():
62 n1 = tag1.numberOfSequenceItems()
63 n2 = tag2.numberOfSequenceItems()
65 self.
dicomTagError(path, f
"Tags have different number of sequence items ({n1} and {n2})", tag1)
69 for i
in range(tag1.numberOfSequenceItems()):
70 ok = self.
compareTrees(tag1.getSequenceItem(i), tag2.getSequenceItem(i), path + ((tag1, i),))
and ok
72 elif not tag1.isEqual(tag2):
75 self.
dicomTagError(path, f
"Different values ({s1} != {s2})", tag1)
82 if tree1
and not tree2:
85 elif tree2
and not tree1:
88 tags1 = list(tree1.getTags())
89 tags2 = list(tree2.getTags())
90 tag1 = tags1.pop(0)
if tags1
else None
91 tag2 = tags2.pop(0)
if tags2
else None
95 or tag1.groupId() < tag2.groupId()
96 or (tag1.groupId() == tag2.groupId()
and tag1.elementId() < tag2.elementId())
100 tag1 = tags1.pop(0)
if tags1
else None
103 or tag1.groupId() > tag2.groupId()
104 or (tag1.groupId() == tag2.groupId()
and tag1.elementId() > tag2.elementId())
108 tag2 = tags2.pop(0)
if tags2
else None
111 tag1 = tags1.pop(0)
if tags1
else None
112 tag2 = tags2.pop(0)
if tags2
else None
133 tree1, tree2, printDifferences=True, printOnlyFirstDifference=False, outputFunction=MLAB.logError
136 dc.printDifferences = printDifferences
137 dc.printOnlyFirstDifference = printOnlyFirstDifference
138 dc.outputFunction = outputFunction
139 return dc.compareTrees(tree1, tree2)
Helper class, please use compareDicomTrees()
dicomPathToString(self, path)
tagValueToString(self, tag)
compareTags(self, tag1, tag2, path)
dicomTagError(self, path, message, tag=None)
compareTrees(self, tree1, tree2, path=())
compareDicomTrees(tree1, tree2, printDifferences=True, printOnlyFirstDifference=False, outputFunction=MLAB.logError)
Compare the two given DICOM trees (of type MLABDicomTree) for equality.