large-image-source-tifffile 1.27.5.dev6__py3-none-any.whl → 1.28.3.dev2__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -109,6 +109,7 @@ class TifffileFileTileSource(FileTileSource, metaclass=LruCacheMetaclass):
109
109
  self._largeImagePath = str(self._getLargeImagePath())
110
110
 
111
111
  _lazyImport()
112
+ self.addKnownExtensions()
112
113
  try:
113
114
  self._tf = tifffile.TiffFile(self._largeImagePath)
114
115
  except Exception:
@@ -473,19 +474,12 @@ class TifffileFileTileSource(FileTileSource, metaclass=LruCacheMetaclass):
473
474
  sidx = frame // self._basis['P'][0]
474
475
  else:
475
476
  sidx = 0
476
- series = self._tf.series[self._series[sidx]]
477
477
  nonempty = [None] * self.levels
478
478
  nonempty[self.levels - 1] = True
479
+ series = self._tf.series[self._series[sidx]]
480
+ za, hasgbs = self._getZarrArray(series, sidx)
479
481
  xidx = series.axes.index('X')
480
482
  yidx = series.axes.index('Y')
481
- with self._zarrlock:
482
- if sidx not in self._zarrcache:
483
- if len(self._zarrcache) > 10:
484
- self._zarrcache = {}
485
- za = zarr.open(series.aszarr(), mode='r')
486
- hasgbs = hasattr(za[0], 'get_basic_selection')
487
- self._zarrcache[sidx] = (za, hasgbs)
488
- za, hasgbs = self._zarrcache[sidx]
489
483
  for ll in range(1, len(series.levels)):
490
484
  scale = round(math.log(max(za[0].shape[xidx] / za[ll].shape[xidx],
491
485
  za[0].shape[yidx] / za[ll].shape[yidx])) / math.log(2))
@@ -496,6 +490,19 @@ class TifffileFileTileSource(FileTileSource, metaclass=LruCacheMetaclass):
496
490
  self._nonempty_levels_list[frame] = nonempty
497
491
  return nonempty
498
492
 
493
+ def _getZarrArray(self, series, sidx):
494
+ with self._zarrlock:
495
+ if sidx not in self._zarrcache:
496
+ if len(self._zarrcache) > 10:
497
+ self._zarrcache = {}
498
+ za = zarr.open(series.aszarr(), mode='r')
499
+ hasgbs = hasattr(za[0], 'get_basic_selection')
500
+ if not hasgbs and math.prod(series.shape) < 256 * 1024 ** 2:
501
+ za = series.asarray()
502
+ self._zarrcache[sidx] = (za, hasgbs)
503
+ za, hasgbs = self._zarrcache[sidx]
504
+ return za, hasgbs
505
+
499
506
  @methodcache()
500
507
  def getTile(self, x, y, z, pilImageAllowed=False, numpyAllowed=False, **kwargs):
501
508
  frame = self._getFrame(**kwargs)
@@ -506,14 +513,7 @@ class TifffileFileTileSource(FileTileSource, metaclass=LruCacheMetaclass):
506
513
  else:
507
514
  sidx = 0
508
515
  series = self._tf.series[self._series[sidx]]
509
- with self._zarrlock:
510
- if sidx not in self._zarrcache:
511
- if len(self._zarrcache) > 10:
512
- self._zarrcache = {}
513
- za = zarr.open(series.aszarr(), mode='r')
514
- hasgbs = hasattr(za[0], 'get_basic_selection')
515
- self._zarrcache[sidx] = (za, hasgbs)
516
- za, hasgbs = self._zarrcache[sidx]
516
+ za, hasgbs = self._getZarrArray(series, sidx)
517
517
  xidx = series.axes.index('X')
518
518
  yidx = series.axes.index('Y')
519
519
  if hasgbs:
@@ -558,6 +558,16 @@ class TifffileFileTileSource(FileTileSource, metaclass=LruCacheMetaclass):
558
558
  return self._outputTile(tile, TILE_FORMAT_NUMPY, x, y, z,
559
559
  pilImageAllowed, numpyAllowed, **kwargs)
560
560
 
561
+ @classmethod
562
+ def addKnownExtensions(cls):
563
+ if not hasattr(cls, '_addedExtensions'):
564
+ _lazyImport()
565
+ cls._addedExtensions = True
566
+ cls.extensions = cls.extensions.copy()
567
+ for ext in tifffile.TIFF.FILE_EXTENSIONS:
568
+ if ext not in cls.extensions:
569
+ cls.extensions[ext] = SourcePriority.IMPLICIT
570
+
561
571
 
562
572
  def open(*args, **kwargs):
563
573
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: large-image-source-tifffile
3
- Version: 1.27.5.dev6
3
+ Version: 1.28.3.dev2
4
4
  Summary: A tifffile tilesource for large_image.
5
5
  Home-page: https://github.com/girder/large_image
6
6
  Author: Kitware, Inc.
@@ -17,12 +17,12 @@ Classifier: Programming Language :: Python :: 3.11
17
17
  Classifier: Programming Language :: Python :: 3.12
18
18
  Requires-Python: >=3.8
19
19
  License-File: LICENSE
20
- Requires-Dist: large-image >=1.27.5.dev6
20
+ Requires-Dist: large-image >=1.28.3.dev2
21
21
  Requires-Dist: dask[array]
22
22
  Requires-Dist: tifffile[all]
23
23
  Requires-Dist: zarr
24
24
  Provides-Extra: girder
25
- Requires-Dist: girder-large-image >=1.27.5.dev6 ; extra == 'girder'
25
+ Requires-Dist: girder-large-image >=1.28.3.dev2 ; extra == 'girder'
26
26
 
27
27
  A tifffile tilesource for large_image.
28
28
 
@@ -0,0 +1,8 @@
1
+ large_image_source_tifffile/__init__.py,sha256=7hREWGbhyYOcz94l_vxMAOTUSJKtJY37TEIZdkvamNw,25001
2
+ large_image_source_tifffile/girder_source.py,sha256=8YsxpSK_UzbAcpjn6fIMlgKye2FchkB8_HTSQV0FpRA,1064
3
+ large_image_source_tifffile-1.28.3.dev2.dist-info/LICENSE,sha256=psuoW8kuDP96RQsdhzwOqi6fyWv0ct8CR6Jr7He_P_k,10173
4
+ large_image_source_tifffile-1.28.3.dev2.dist-info/METADATA,sha256=2XRfComEY1H1fO7m6luWIfzukgRCnPmPJw6RVkiDpZw,1061
5
+ large_image_source_tifffile-1.28.3.dev2.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
6
+ large_image_source_tifffile-1.28.3.dev2.dist-info/entry_points.txt,sha256=aILCN5f7-Zj8-WRXcABxCQvqJv9VLTvqRhZ_7HEyokc,190
7
+ large_image_source_tifffile-1.28.3.dev2.dist-info/top_level.txt,sha256=feOAsix2Rzy6mjy2Ua-N0-L6tlKsgvLdRhO6Hd8_ZFs,28
8
+ large_image_source_tifffile-1.28.3.dev2.dist-info/RECORD,,
@@ -1,8 +0,0 @@
1
- large_image_source_tifffile/__init__.py,sha256=7jHLRfFXszTDfTcD6aRylJthE03lK5FCHh4rKkHtHEw,24668
2
- large_image_source_tifffile/girder_source.py,sha256=8YsxpSK_UzbAcpjn6fIMlgKye2FchkB8_HTSQV0FpRA,1064
3
- large_image_source_tifffile-1.27.5.dev6.dist-info/LICENSE,sha256=psuoW8kuDP96RQsdhzwOqi6fyWv0ct8CR6Jr7He_P_k,10173
4
- large_image_source_tifffile-1.27.5.dev6.dist-info/METADATA,sha256=8nBvBa8UIknq6Y8vtuL_hKFRzWg9ne44VyqOsfA9M2U,1061
5
- large_image_source_tifffile-1.27.5.dev6.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
6
- large_image_source_tifffile-1.27.5.dev6.dist-info/entry_points.txt,sha256=aILCN5f7-Zj8-WRXcABxCQvqJv9VLTvqRhZ_7HEyokc,190
7
- large_image_source_tifffile-1.27.5.dev6.dist-info/top_level.txt,sha256=feOAsix2Rzy6mjy2Ua-N0-L6tlKsgvLdRhO6Hd8_ZFs,28
8
- large_image_source_tifffile-1.27.5.dev6.dist-info/RECORD,,