large-image-source-tifffile 1.20.7.dev30__tar.gz → 1.21.1.dev6__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (13) hide show
  1. {large-image-source-tifffile-1.20.7.dev30 → large-image-source-tifffile-1.21.1.dev6}/PKG-INFO +1 -1
  2. {large-image-source-tifffile-1.20.7.dev30 → large-image-source-tifffile-1.21.1.dev6}/large_image_source_tifffile/__init__.py +27 -4
  3. {large-image-source-tifffile-1.20.7.dev30 → large-image-source-tifffile-1.21.1.dev6}/large_image_source_tifffile.egg-info/PKG-INFO +1 -1
  4. {large-image-source-tifffile-1.20.7.dev30 → large-image-source-tifffile-1.21.1.dev6}/large_image_source_tifffile.egg-info/requires.txt +2 -2
  5. {large-image-source-tifffile-1.20.7.dev30 → large-image-source-tifffile-1.21.1.dev6}/LICENSE +0 -0
  6. {large-image-source-tifffile-1.20.7.dev30 → large-image-source-tifffile-1.21.1.dev6}/README.rst +0 -0
  7. {large-image-source-tifffile-1.20.7.dev30 → large-image-source-tifffile-1.21.1.dev6}/large_image_source_tifffile/girder_source.py +0 -0
  8. {large-image-source-tifffile-1.20.7.dev30 → large-image-source-tifffile-1.21.1.dev6}/large_image_source_tifffile.egg-info/SOURCES.txt +0 -0
  9. {large-image-source-tifffile-1.20.7.dev30 → large-image-source-tifffile-1.21.1.dev6}/large_image_source_tifffile.egg-info/dependency_links.txt +0 -0
  10. {large-image-source-tifffile-1.20.7.dev30 → large-image-source-tifffile-1.21.1.dev6}/large_image_source_tifffile.egg-info/entry_points.txt +0 -0
  11. {large-image-source-tifffile-1.20.7.dev30 → large-image-source-tifffile-1.21.1.dev6}/large_image_source_tifffile.egg-info/top_level.txt +0 -0
  12. {large-image-source-tifffile-1.20.7.dev30 → large-image-source-tifffile-1.21.1.dev6}/setup.cfg +0 -0
  13. {large-image-source-tifffile-1.20.7.dev30 → large-image-source-tifffile-1.21.1.dev6}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: large-image-source-tifffile
3
- Version: 1.20.7.dev30
3
+ Version: 1.21.1.dev6
4
4
  Summary: A tifffile tilesource for large_image.
5
5
  Home-page: https://github.com/girder/large_image
6
6
  Author: Kitware, Inc.
@@ -1,3 +1,4 @@
1
+ import json
1
2
  import logging
2
3
  import math
3
4
  import os
@@ -76,6 +77,7 @@ class TifffileFileTileSource(FileTileSource, metaclass=LruCacheMetaclass):
76
77
  _tileSize = 512
77
78
  _minImageSize = 128
78
79
  _minTileSize = 128
80
+ _singleTileSize = 1024
79
81
  _maxTileSize = 2048
80
82
  _minAssociatedImageSize = 64
81
83
  _maxAssociatedImageSize = 8192
@@ -102,6 +104,8 @@ class TifffileFileTileSource(FileTileSource, metaclass=LruCacheMetaclass):
102
104
  self.tileWidth = self.tileHeight = self._tileSize
103
105
  s = self._tf.series[maxseries]
104
106
  self._baseSeries = s
107
+ if len(s.levels) == 1:
108
+ self.tileWidth = self.tileHeight = self._singleTileSize
105
109
  page = s.pages[0]
106
110
  if ('TileWidth' in page.tags and
107
111
  self._minTileSize <= page.tags['TileWidth'].value <= self._maxTileSize):
@@ -243,6 +247,15 @@ class TifffileFileTileSource(FileTileSource, metaclass=LruCacheMetaclass):
243
247
  max(entry['width'], entry['height']) >= self._minAssociatedImageSize):
244
248
  self._associatedImages[id] = entry
245
249
 
250
+ def _handle_imagej(self):
251
+ try:
252
+ ijm = self._tf.pages[0].tags['IJMetadata'].value
253
+ if (ijm['Labels'] and len(ijm['Labels']) == self._framecount and
254
+ not getattr(self, '_channels', None)):
255
+ self._channels = ijm['Labels']
256
+ except Exception:
257
+ pass
258
+
246
259
  def _handle_scn(self): # noqa
247
260
  """
248
261
  For SCN files, parse the xml and possibly adjust how associated images
@@ -359,7 +372,8 @@ class TifffileFileTileSource(FileTileSource, metaclass=LruCacheMetaclass):
359
372
  pages.extend([page for page in self._tf.pages if page not in pagesInSeries])
360
373
  for page in pages:
361
374
  for tag in getattr(page, 'tags', []):
362
- if tag.dtype_name == 'ASCII' and tag.value:
375
+ if (tag.dtype_name == 'ASCII' or (
376
+ tag.dtype_name == 'BYTE' and isinstance(tag.value, dict))) and tag.value:
363
377
  key = basekey = tag.name
364
378
  suffix = 0
365
379
  while key in result:
@@ -368,6 +382,13 @@ class TifffileFileTileSource(FileTileSource, metaclass=LruCacheMetaclass):
368
382
  suffix += 1
369
383
  key = '%s_%d' % (basekey, suffix)
370
384
  result[key] = tag.value
385
+ if isinstance(result[key], dict):
386
+ result[key] = result[key].copy()
387
+ for subkey in list(result[key]):
388
+ try:
389
+ json.dumps(result[key][subkey])
390
+ except Exception:
391
+ del result[key][subkey]
371
392
  if hasattr(self, '_xml') and 'xml' not in result:
372
393
  result.pop('ImageDescription', None)
373
394
  result['xml'] = self._xml
@@ -420,11 +441,13 @@ class TifffileFileTileSource(FileTileSource, metaclass=LruCacheMetaclass):
420
441
  if sidx not in self._zarrcache:
421
442
  if len(self._zarrcache) > 10:
422
443
  self._zarrcache = {}
423
- self._zarrcache[sidx] = zarr.open(series.aszarr(), mode='r')
424
- za = self._zarrcache[sidx]
444
+ za = zarr.open(series.aszarr(), mode='r')
445
+ hasgbs = hasattr(za[0], 'get_basic_selection')
446
+ self._zarrcache[sidx] = (za, hasgbs)
447
+ za, hasgbs = self._zarrcache[sidx]
425
448
  xidx = series.axes.index('X')
426
449
  yidx = series.axes.index('Y')
427
- if hasattr(za[0], 'get_basic_selection'):
450
+ if hasgbs:
428
451
  bza = za[0]
429
452
  # we could cache this
430
453
  for ll in range(len(series.levels) - 1, 0, -1):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: large-image-source-tifffile
3
- Version: 1.20.7.dev30
3
+ Version: 1.21.1.dev6
4
4
  Summary: A tifffile tilesource for large_image.
5
5
  Home-page: https://github.com/girder/large_image
6
6
  Author: Kitware, Inc.
@@ -1,4 +1,4 @@
1
- large-image>=1.20.7.dev30
1
+ large-image>=1.21.1.dev6
2
2
  dask[array]
3
3
  tifffile[all]
4
4
 
@@ -10,4 +10,4 @@ importlib-metadata<5
10
10
  zarr
11
11
 
12
12
  [girder]
13
- girder-large-image>=1.20.7.dev30
13
+ girder-large-image>=1.21.1.dev6