Skip to content

Commit

Permalink
Handle more OME Tiff variations.
Browse files Browse the repository at this point in the history
Ultimately it would be better to refactor this to handle the
specification properly.
  • Loading branch information
manthey committed Apr 2, 2021
1 parent 5a6c88f commit 84f66ea
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions sources/ometiff/large_image_source_ometiff/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,14 @@ def _parseOMEInfo(self): # noqa
len(self._omebase['TiffData']) == 1) and
(len(self._omebase.get('Plane', [])) or
len(self._omebase.get('Channel', [])))):
if not len(self._omebase['TiffData']) or self._omebase['TiffData'][0] == {}:
self._omebase['TiffData'] = self._omebase.get(
'Plane', self._omebase.get('Channel'))
if (not len(self._omebase['TiffData']) or
self._omebase['TiffData'][0] == {} or
int(self._omebase['TiffData'][0].get('PlaneCount', 0)) == 1):
planes = copy.deepcopy(self._omebase.get(
'Plane', self._omebase.get('Channel')))
for idx, plane in enumerate(planes):
plane['IndexC'] = idx
self._omebase['TiffData'] = planes
elif (int(self._omebase['TiffData'][0].get('PlaneCount', 0)) ==
len(self._omebase.get('Plane', self._omebase.get('Channel', [])))):
planes = copy.deepcopy(self._omebase.get('Plane', self._omebase.get('Channel')))
Expand All @@ -219,7 +224,6 @@ def _parseOMEInfo(self): # noqa
raise TileSourceException(
'OME Tiff contains frames that contain multiple planes')
except (KeyError, ValueError, IndexError):
print('B')
raise TileSourceException('OME Tiff does not contain an expected record')

def getMetadata(self):
Expand All @@ -239,7 +243,8 @@ def getMetadata(self):
break
except Exception:
pass
if len(set(channels)) != len(channels):
if len(set(channels)) != len(channels) and (
len(channels) <= 1 or len(channels) > len(result['frames'])):
channels = []
# Standardize "TheX" to "IndexX" values
reftbl = OrderedDict([
Expand Down

0 comments on commit 84f66ea

Please sign in to comment.