improve suggest answers (and fix some other issues)
This commit is contained in:
@@ -37,6 +37,7 @@ from easy_thumbnails.exceptions import InvalidImageFormatError
|
||||
|
||||
|
||||
import pydicom
|
||||
import pydicom.errors
|
||||
import dicognito.anonymizer
|
||||
from django.contrib.auth.models import User
|
||||
from django.forms.models import model_to_dict
|
||||
@@ -240,6 +241,24 @@ class SeriesImageBase(models.Model):
|
||||
ordering = ["position"]
|
||||
abstract = True
|
||||
|
||||
def get_file_size(self):
|
||||
try:
|
||||
return self.image.size
|
||||
|
||||
# We catch this for when the image does not exist
|
||||
except FileNotFoundError:
|
||||
return 0
|
||||
|
||||
def get_dicom_data(self):
|
||||
try:
|
||||
with pydicom.dcmread(self.image) as d:
|
||||
return d
|
||||
except pydicom.errors.InvalidDicomError:
|
||||
return {}
|
||||
|
||||
def get_series(self):
|
||||
return self.series
|
||||
|
||||
def get_dicom_json(self):
|
||||
try:
|
||||
json = pydicom.read_file(self.image).to_json()
|
||||
|
||||
Reference in New Issue
Block a user