Refactor DICOM file reading to use dcmread for improved compatibility across models and helpers
This commit is contained in:
+1
-1
@@ -1470,7 +1470,7 @@ class UncategorisedDicom(models.Model):
|
|||||||
def get_basic_dicom_tags(self, dataset=None):
|
def get_basic_dicom_tags(self, dataset=None):
|
||||||
try:
|
try:
|
||||||
if dataset is None:
|
if dataset is None:
|
||||||
dataset = pydicom.read_file(self.image)
|
dataset = pydicom.dcmread(self.image)
|
||||||
to_include = (
|
to_include = (
|
||||||
"StudyDescription",
|
"StudyDescription",
|
||||||
"Modality",
|
"Modality",
|
||||||
|
|||||||
+2
-2
@@ -316,14 +316,14 @@ class SeriesImageBase(models.Model):
|
|||||||
|
|
||||||
def get_dicom_json(self):
|
def get_dicom_json(self):
|
||||||
try:
|
try:
|
||||||
json = pydicom.read_file(self.image).to_json()
|
json = pydicom.dcmread(self.image).to_json()
|
||||||
except pydicom.errors.InvalidDicomError:
|
except pydicom.errors.InvalidDicomError:
|
||||||
return {}
|
return {}
|
||||||
return json
|
return json
|
||||||
|
|
||||||
def get_dicom_info(self):
|
def get_dicom_info(self):
|
||||||
try:
|
try:
|
||||||
info = pretty_print_dicom(pydicom.read_file(self.image))
|
info = pretty_print_dicom(pydicom.dcmread(self.image))
|
||||||
except pydicom.errors.InvalidDicomError:
|
except pydicom.errors.InvalidDicomError:
|
||||||
info = "File is not a dicom."
|
info = "File is not a dicom."
|
||||||
return info
|
return info
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
Usage:
|
Usage:
|
||||||
>>> import pydicom
|
>>> import pydicom
|
||||||
>>> from pydicom.contrib.pydicom_PIL import show_PIL
|
>>> from pydicom.contrib.pydicom_PIL import show_PIL
|
||||||
>>> ds = pydicom.read_file("filename")
|
>>> ds = pydicom.dcmread("filename")
|
||||||
>>> show_PIL(ds)
|
>>> show_PIL(ds)
|
||||||
Requires Numpy:
|
Requires Numpy:
|
||||||
http://numpy.scipy.org/
|
http://numpy.scipy.org/
|
||||||
|
|||||||
Reference in New Issue
Block a user