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