From cf1c961e654e7d411d255bef74fccab7a2d8c4f3 Mon Sep 17 00:00:00 2001 From: David Manthey Date: Thu, 23 Sep 2021 09:39:27 -0400 Subject: [PATCH] Guard against an OME tiff exception. Some files raise a TypeError in the current parsing; the parsing should be improved, but this at least allows graceful failure until that is done. --- sources/ometiff/large_image_source_ometiff/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sources/ometiff/large_image_source_ometiff/__init__.py b/sources/ometiff/large_image_source_ometiff/__init__.py index f65add8c5..f7900ae91 100644 --- a/sources/ometiff/large_image_source_ometiff/__init__.py +++ b/sources/ometiff/large_image_source_ometiff/__init__.py @@ -206,6 +206,9 @@ def _parseOMEInfo(self): # noqa int(self._omebase['TiffData'][0].get('PlaneCount', 0)) == 1): planes = copy.deepcopy(self._omebase.get( 'Plane', self._omebase.get('Channel'))) + if isinstance(planes, dict): + planes = [planes] + self._omebase['SizeC'] = 1 for idx, plane in enumerate(planes): plane['IndexC'] = idx self._omebase['TiffData'] = planes @@ -227,7 +230,7 @@ def _parseOMEInfo(self): # noqa self._omebase.get('Plane', self._omebase['TiffData']))): raise TileSourceError( 'OME Tiff contains frames that contain multiple planes') - except (KeyError, ValueError, IndexError): + except (KeyError, ValueError, IndexError, TypeError): raise TileSourceError('OME Tiff does not contain an expected record') def getMetadata(self):