From 7c926ba7b31913eb970d0642a7fae33e259719a3 Mon Sep 17 00:00:00 2001 From: Ross Date: Wed, 6 Apr 2022 17:41:18 +0100 Subject: [PATCH] . --- atlas/forms.py | 2 +- atlas/models.py | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/atlas/forms.py b/atlas/forms.py index 8f1c0670..a90ad2b1 100755 --- a/atlas/forms.py +++ b/atlas/forms.py @@ -204,7 +204,7 @@ class SeriesForm(ModelForm): instance.save() self.save_m2m() - instance.anonymise_dicom() + instance.anonymise_images() return instance diff --git a/atlas/models.py b/atlas/models.py index 1d7b90d2..311a061c 100644 --- a/atlas/models.py +++ b/atlas/models.py @@ -583,9 +583,12 @@ class Series(models.Model): for series_image in self.images.all(): file_path = os.path.join(settings.MEDIA_ROOT, series_image.image.name) - with pydicom.dcmread(file_path) as dataset: - anonymizer.anonymize(dataset) - dataset.save_as(file_path) + try: + with pydicom.dcmread(file_path) as dataset: + anonymizer.anonymize(dataset) + dataset.save_as(file_path) + except pydicom.errors.InvalidDicomError: + pass