From 6be4bcc8adffd13d878914bd4762acfbe7411b85 Mon Sep 17 00:00:00 2001 From: Erik O Gabrielsson Date: Mon, 12 Feb 2024 18:18:27 +0100 Subject: [PATCH] Handle failing to parse image coordinate system by attribute error --- wsidicom/metadata/schema/dicom/image.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/wsidicom/metadata/schema/dicom/image.py b/wsidicom/metadata/schema/dicom/image.py index 5c6938aa..f463d28d 100644 --- a/wsidicom/metadata/schema/dicom/image.py +++ b/wsidicom/metadata/schema/dicom/image.py @@ -82,7 +82,7 @@ def load_type(self) -> Type[ImageCoordinateSystem]: def load(self, dataset: Dataset, **kwargs) -> Optional[ImageCoordinateSystem]: try: return super().load(dataset, **kwargs) - except TypeError: + except (TypeError, AttributeError): return None @@ -209,9 +209,9 @@ def pre_dump(self, image: Image, **kwargs): focal_plane_spacing=image.focal_plane_spacing, depth_of_field=image.depth_of_field, ), - "lossy_compressions": image.lossy_compressions - if image.lossy_compressions - else [], + "lossy_compressions": ( + image.lossy_compressions if image.lossy_compressions else [] + ), } @post_load