.
This commit is contained in:
+17
-18
@@ -940,27 +940,26 @@ class UncategorisedDicom(models.Model):
|
||||
|
||||
def get_basic_dicom_tags(self):
|
||||
try:
|
||||
ds = pydicom.read_file(self.image)
|
||||
with pydicom.read_file(self.image) as ds:
|
||||
to_include = (
|
||||
"StudyDescription",
|
||||
"Modality",
|
||||
"ProtocolName",
|
||||
"SeriesDescription",
|
||||
"SeriesInstanceUID",
|
||||
"BodyPartExamined",
|
||||
"SliceThickness",
|
||||
)
|
||||
|
||||
to_include = (
|
||||
"StudyDescription",
|
||||
"Modality",
|
||||
"ProtocolName",
|
||||
"SeriesDescription",
|
||||
"SeriesInstanceUID",
|
||||
"BodyPartExamined",
|
||||
"SliceThickness",
|
||||
)
|
||||
tags = {}
|
||||
|
||||
tags = {}
|
||||
for tag in to_include:
|
||||
if tag in ds:
|
||||
tags[tag] = ds[tag].value
|
||||
else:
|
||||
tags[tag] = ""
|
||||
|
||||
for tag in to_include:
|
||||
if tag in ds:
|
||||
tags[tag] = ds[tag].value
|
||||
else:
|
||||
tags[tag] = ""
|
||||
|
||||
return tags
|
||||
return tags
|
||||
except pydicom.errors.InvalidDicomError:
|
||||
return None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user