diff --git a/CHANGELOG.md b/CHANGELOG.md index 03674703f..ddf27115a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ### Improvements - Frame selection presets have configurable defaults ([#1301](../../pull/1301)) +- Improved DICOM metadata extraction ([#1305](../../pull/1305)) ## 1.24.0 diff --git a/sources/dicom/large_image_source_dicom/__init__.py b/sources/dicom/large_image_source_dicom/__init__.py index 92953cae1..5c3f2448e 100644 --- a/sources/dicom/large_image_source_dicom/__init__.py +++ b/sources/dicom/large_image_source_dicom/__init__.py @@ -62,16 +62,19 @@ def dicom_to_dict(ds, base=None): key = pydicom.datadict.keyword_for_tag(k) except Exception: pass - if v.get('vr') in {None, 'OB'}: - continue - if not len(v.get('Value', [])): - continue - if isinstance(v['Value'][0], dict): - val = [dicom_to_dict(ds, entry) for entry in v['Value']] - elif len(v['Value']) == 1: - val = v['Value'][0] + if isinstance(v, str): + val = v else: - val = v['Value'] + if v.get('vr') in {None, 'OB'}: + continue + if not len(v.get('Value', [])): + continue + if isinstance(v['Value'][0], dict): + val = [dicom_to_dict(ds, entry) for entry in v['Value']] + elif len(v['Value']) == 1: + val = v['Value'][0] + else: + val = v['Value'] info[key] = val return info