30 elif name ==
"PrivateCreator":
31 name +=
" '" + tag.toString() +
"' " + tag.id()
33 name +=
" " + tag.id()
38 for tag, index
in path:
39 result += f
"in {self.tagName(tag)}, position {index} "
44 return f
"<{tag.numberOfValues()} items>"
46 return f
"'{tag.toString()}'"
51 tagString = (
", tag " + self.
tagName(tag))
if tag
else ""
57 if tag1.vr() != tag2.vr():
58 self.
dicomTagError(path, f
"Different VRs ({tag1.vr()} and {tag2.vr()})", tag1)
60 elif tag1.isSequence():
61 n1 = tag1.numberOfSequenceItems()
62 n2 = tag2.numberOfSequenceItems()
64 self.
dicomTagError(path, f
"Tags have different number of sequence items ({n1} and {n2})", tag1)
68 for i
in range(tag1.numberOfSequenceItems()):
69 ok = self.
compareTrees(tag1.getSequenceItem(i), tag2.getSequenceItem(i), path + ((tag1, i),))
and ok
71 elif not tag1.isEqual(tag2):
74 self.
dicomTagError(path, f
"Different values ({s1} != {s2})", tag1)
81 if tree1
and not tree2:
84 elif tree2
and not tree1:
87 tags1 = list(tree1.getTags())
88 tags2 = list(tree2.getTags())
89 tag1 = tags1.pop(0)
if tags1
else None
90 tag2 = tags2.pop(0)
if tags2
else None
92 if not tag2
or tag1.groupId() < tag2.groupId()
or (tag1.groupId() == tag2.groupId()
and tag1.elementId() < tag2.elementId()):
95 tag1 = tags1.pop(0)
if tags1
else None
96 elif not tag1
or tag1.groupId() > tag2.groupId()
or (tag1.groupId() == tag2.groupId()
and tag1.elementId() > tag2.elementId()):
99 tag2 = tags2.pop(0)
if tags2
else None
102 tag1 = tags1.pop(0)
if tags1
else None
103 tag2 = tags2.pop(0)
if tags2
else None
120def compareDicomTrees(tree1, tree2, printDifferences=True, printOnlyFirstDifference=False, outputFunction=MLAB.logError):
122 dc.printDifferences = printDifferences
123 dc.printOnlyFirstDifference = printOnlyFirstDifference
124 dc.outputFunction = outputFunction
125 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.