add basic dicom diff support
This commit is contained in:
+11
-3
@@ -126,7 +126,7 @@ def pretty_print_dicom(dataset, indent=0):
|
||||
return "".join(l)
|
||||
|
||||
|
||||
def print_dicom(dataset, indent=0, include_tag_ids=True):
|
||||
def print_dicom(dataset, indent=0, include_tag_ids=True, join=True, join_text="\n<br/>"):
|
||||
"""Go through all items in the dataset and print them with custom format
|
||||
|
||||
Modelled after Dataset._pretty_str()
|
||||
@@ -142,7 +142,12 @@ def print_dicom(dataset, indent=0, include_tag_ids=True):
|
||||
if data_element.VR == "SQ": # a sequence
|
||||
l.append(f"{data_element.tag}: {indent_string}{data_element.name}")
|
||||
for sequence_item in data_element.value:
|
||||
l.append(print_dicom(sequence_item, indent + 1))
|
||||
l_ = print_dicom(sequence_item, indent + 1, join=join, join_text=join_text)
|
||||
if join:
|
||||
l.append(l_)
|
||||
else:
|
||||
l.extend(l_)
|
||||
|
||||
l.append(next_indent_string + "---------")
|
||||
else:
|
||||
if data_element.name in dont_print:
|
||||
@@ -152,7 +157,10 @@ def print_dicom(dataset, indent=0, include_tag_ids=True):
|
||||
if len(repr_value) > 50:
|
||||
repr_value = repr_value[:50] + "..."
|
||||
l.append(f"{data_element.tag}: {indent_string:s} {data_element.name:s} = {repr_value:s}")
|
||||
return "\n<br/>".join(l)
|
||||
if not join:
|
||||
return l
|
||||
|
||||
return join_text.join(l)
|
||||
|
||||
def get_image_dicom_hash(img, dataset=None, hash_type="md5", direct_pixel_data=True) -> (str, bool):
|
||||
if dataset is None:
|
||||
|
||||
Reference in New Issue
Block a user