fix a few small upload bugs
This commit is contained in:
+4
-2
@@ -70,8 +70,10 @@ def upload_dicom(request, files: List[UploadedFile] = File(...)):
|
||||
except DuplicateDicom as e:
|
||||
duplicate.append((file.name, ud.image_blake3_hash))
|
||||
|
||||
duplicate_series.add(e.duplicate.get_series().get_absolute_url())
|
||||
print(duplicate_series)
|
||||
|
||||
if type(e.duplicate) == SeriesImage:
|
||||
duplicate_series.add(e.duplicate.series.get_absolute_url())
|
||||
|
||||
pass
|
||||
except InvalidDicomError:
|
||||
failed.append(file.name)
|
||||
|
||||
+3
-2
@@ -1304,8 +1304,7 @@ class UncategorisedDicom(models.Model):
|
||||
try:
|
||||
self.series_instance_uid = ds["SeriesInstanceUID"].value
|
||||
except AttributeError:
|
||||
# ? only called with invalid dicom?
|
||||
self.series_instance_uid = ds["SeriesInstanceUID"]
|
||||
raise InvalidDicomError("Invalid dicom file")
|
||||
|
||||
# if self.check_for_duplicates():
|
||||
# return DuplicateDicom
|
||||
@@ -1333,6 +1332,8 @@ class UncategorisedDicom(models.Model):
|
||||
ds = pydicom.dcmread(self.image)
|
||||
return ds
|
||||
except pydicom.errors.InvalidDicomError:
|
||||
print("Error getting dicom dataset")
|
||||
print(self.image)
|
||||
return {"SeriesInstanceUID": "1234"}
|
||||
|
||||
def get_basic_dicom_tags(self, dataset=None):
|
||||
|
||||
+8
-1
@@ -9,6 +9,7 @@ from PIL import Image, ImageFile
|
||||
from blake3 import blake3
|
||||
|
||||
import pydicom
|
||||
from pydicom.errors import InvalidDicomError
|
||||
import sys
|
||||
import glob
|
||||
|
||||
@@ -178,7 +179,13 @@ def get_image_dicom_hash(img, dataset=None, hash_type="md5", direct_pixel_data=T
|
||||
raise NotImplemented
|
||||
|
||||
if direct_pixel_data:
|
||||
hasher.update(dataset.PixelData)
|
||||
try:
|
||||
hasher.update(dataset.PixelData)
|
||||
except AttributeError as e:
|
||||
print("Error getting pixel data hash from dataset")
|
||||
print(dataset)
|
||||
raise InvalidDicomError("Error getting pixel data hash from dataset")
|
||||
|
||||
else:
|
||||
first = True
|
||||
for i in dataset.pixel_array.astype(str).flatten():
|
||||
|
||||
Reference in New Issue
Block a user