Skip to content

Commit

Permalink
Merge pull request #585 from girder/more-ome-tiff-variations
Browse files Browse the repository at this point in the history
Handle more OME Tiff variations.
  • Loading branch information
manthey authored Apr 2, 2021
2 parents ec3fb2a + 84f66ea commit 6e829ae
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 6e829ae

Please sign in to comment.