Skip to content

Commit

Permalink
Read more OME Tiff files.
Browse files Browse the repository at this point in the history
  • Loading branch information
manthey committed Jul 30, 2020
1 parent 31bfb29 commit c8b84c1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
14 changes: 9 additions & 5 deletions sources/ometiff/large_image_source_ometiff/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def __init__(self, path, **kwargs):
self._omeLevels = [omebylevel.get(key) for key in range(max(omebylevel.keys()) + 1)]
if base._tiffInfo.get('istiled'):
self._tiffDirectories = [
TiledTiffDirectory(largeImagePath, int(entry['TiffData'][0]['IFD']))
TiledTiffDirectory(largeImagePath, int(entry['TiffData'][0].get('IFD', 0)))
if entry else None
for entry in self._omeLevels]
else:
Expand Down Expand Up @@ -190,16 +190,20 @@ def _parseOMEInfo(self):
img['Pixels']['TiffData'] = [img['Pixels']['TiffData']]
if isinstance(img['Pixels'].get('Plane'), dict):
img['Pixels']['Plane'] = [img['Pixels']['Plane']]
if isinstance(img['Pixels'].get('Channels'), dict):
img['Pixels']['Channels'] = [img['Pixels']['Channels']]
try:
self._omebase = self._omeinfo['Image'][0]['Pixels']
if ((not len(self._omebase['TiffData']) or
len(self._omebase['TiffData']) == 1) and
len(self._omebase['Plane'])):
(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['Plane']
self._omebase['TiffData'] = self._omebase.get(
'Plane', self._omebase.get('Channel'))
elif (int(self._omebase['TiffData'][0].get('PlaneCount', 0)) ==
len(self._omebase['Plane'])):
planes = copy.deepcopy(self._omebase['Plane'])
len(self._omebase.get('Plane', self._omebase.get('Channel', [])))):
planes = copy.deepcopy(self._omebase.get('Plane', self._omebase.get('Channel')))
for idx, plane in enumerate(planes):
plane['IFD'] = plane.get(
'IFD', int(self._omebase['TiffData'][0].get('IFD', 0)) + idx)
Expand Down
3 changes: 2 additions & 1 deletion sources/tiff/large_image_source_tiff/tiff_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ def __init__(self, filePath, directoryNum, mustBeTiled=True, subDirectoryNum=0,
self._open(filePath, directoryNum, subDirectoryNum)
self._loadMetadata()
config.getConfig('logger').debug(
'TiffDirectory %d:%d Information %r', directoryNum, subDirectoryNum, self._tiffInfo)
'TiffDirectory %d:%d Information %r',
directoryNum, subDirectoryNum or 0, self._tiffInfo)
try:
if validate:
self._validate()
Expand Down

0 comments on commit c8b84c1

Please sign in to comment.