imi-bigpicture / wsidicom

Python package for reading DICOM WSI file sets.
Apache License 2.0
33 stars 5 forks source link

Handle files missing extended_depth_of_field_bool #145

Closed manthey closed 8 months ago

manthey commented 8 months ago

I have a dicom file (one level of a pyramid) that worked prior to 0.18, but doesn't work with the recent changes. Specifically, it fails here: https://github.com/imi-bigpicture/wsidicom/blob/main/wsidicom/metadata/schema/dicom/image.py#L217 because "extended_depth_of_field_bool" doesn't exist.

This was introduced by this change: https://github.com/imi-bigpicture/wsidicom/pull/142/files#diff-c72fba25df969c0984b417d76eefc963a1a20014e847cf68397e2f9a85ba3e83R217-R219

I think it should be guarded, so it would change to:

        extended_depth_of_field_bool = data.pop("extended_depth_of_field_bool", None)
        extended_depth_of_field = data.get("extended_depth_of_field", None)
        if (extended_depth_of_field_bool is not None) != (extended_depth_of_field is not None):
erikogabrielsson commented 8 months ago

Thank you @manthey for testing and finding this bug. The extended depth of field attribute is a required attribute in the WSI standard, but of coarse we should handle if it is not set (and then assume extended depth of field is not present). I have changed so that the default load value if the attribute is not present in the dataset is False, and changed the unit test to also test loading the Image metadata if the extended depth of field attribute is missing.

erikogabrielsson commented 8 months ago

Also, metadata errors should not prevent the normal loading of the wsi. The load has now been moved from the Pyramid__init__() to a cached property.

erikogabrielsson commented 8 months ago

Fixed in 0.18.2

manthey commented 8 months ago

Awesome. Thank you.