Skip to content

Commit

Permalink
Guard against an OME tiff exception.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
manthey committed Sep 23, 2021
1 parent 44f46e2 commit cf1c961
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion sources/ometiff/large_image_source_ometiff/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down

0 comments on commit cf1c961

Please sign in to comment.