large-image-source-tifffile 1.30.7.dev10__tar.gz → 1.30.7.dev12__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (15) hide show
  1. {large_image_source_tifffile-1.30.7.dev10 → large_image_source_tifffile-1.30.7.dev12}/PKG-INFO +3 -3
  2. {large_image_source_tifffile-1.30.7.dev10 → large_image_source_tifffile-1.30.7.dev12}/large_image_source_tifffile/__init__.py +39 -0
  3. {large_image_source_tifffile-1.30.7.dev10 → large_image_source_tifffile-1.30.7.dev12}/large_image_source_tifffile.egg-info/PKG-INFO +3 -3
  4. large_image_source_tifffile-1.30.7.dev12/large_image_source_tifffile.egg-info/requires.txt +7 -0
  5. large_image_source_tifffile-1.30.7.dev10/large_image_source_tifffile.egg-info/requires.txt +0 -7
  6. {large_image_source_tifffile-1.30.7.dev10 → large_image_source_tifffile-1.30.7.dev12}/LICENSE +0 -0
  7. {large_image_source_tifffile-1.30.7.dev10 → large_image_source_tifffile-1.30.7.dev12}/README.rst +0 -0
  8. {large_image_source_tifffile-1.30.7.dev10 → large_image_source_tifffile-1.30.7.dev12}/large_image_source_tifffile/girder_source.py +0 -0
  9. {large_image_source_tifffile-1.30.7.dev10 → large_image_source_tifffile-1.30.7.dev12}/large_image_source_tifffile.egg-info/SOURCES.txt +0 -0
  10. {large_image_source_tifffile-1.30.7.dev10 → large_image_source_tifffile-1.30.7.dev12}/large_image_source_tifffile.egg-info/dependency_links.txt +0 -0
  11. {large_image_source_tifffile-1.30.7.dev10 → large_image_source_tifffile-1.30.7.dev12}/large_image_source_tifffile.egg-info/entry_points.txt +0 -0
  12. {large_image_source_tifffile-1.30.7.dev10 → large_image_source_tifffile-1.30.7.dev12}/large_image_source_tifffile.egg-info/top_level.txt +0 -0
  13. {large_image_source_tifffile-1.30.7.dev10 → large_image_source_tifffile-1.30.7.dev12}/pyproject.toml +0 -0
  14. {large_image_source_tifffile-1.30.7.dev10 → large_image_source_tifffile-1.30.7.dev12}/setup.cfg +0 -0
  15. {large_image_source_tifffile-1.30.7.dev10 → large_image_source_tifffile-1.30.7.dev12}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: large-image-source-tifffile
3
- Version: 1.30.7.dev10
3
+ Version: 1.30.7.dev12
4
4
  Summary: A tifffile tilesource for large_image.
5
5
  Home-page: https://github.com/girder/large_image
6
6
  Author: Kitware, Inc.
@@ -19,12 +19,12 @@ Classifier: Programming Language :: Python :: 3.13
19
19
  Requires-Python: >=3.8
20
20
  Description-Content-Type: text/x-rst
21
21
  License-File: LICENSE
22
- Requires-Dist: large-image>=1.30.7.dev10
22
+ Requires-Dist: large-image>=1.30.7.dev12
23
23
  Requires-Dist: dask[array]
24
24
  Requires-Dist: tifffile[all]
25
25
  Requires-Dist: zarr
26
26
  Provides-Extra: girder
27
- Requires-Dist: girder-large-image>=1.30.7.dev10; extra == "girder"
27
+ Requires-Dist: girder-large-image>=1.30.7.dev12; extra == "girder"
28
28
 
29
29
  A tifffile tilesource for large_image.
30
30
 
@@ -5,6 +5,7 @@ import os
5
5
  import threading
6
6
  from importlib.metadata import PackageNotFoundError
7
7
  from importlib.metadata import version as _importlib_version
8
+ from pathlib import Path
8
9
 
9
10
  import numpy as np
10
11
 
@@ -83,6 +84,7 @@ class TifffileFileTileSource(FileTileSource, metaclass=LruCacheMetaclass):
83
84
  'scn': SourcePriority.PREFERRED,
84
85
  'tif': SourcePriority.LOW,
85
86
  'tiff': SourcePriority.LOW,
87
+ 'ome': SourcePriority.HIGHER,
86
88
  }
87
89
  mimeTypes = {
88
90
  None: SourcePriority.FALLBACK,
@@ -120,6 +122,7 @@ class TifffileFileTileSource(FileTileSource, metaclass=LruCacheMetaclass):
120
122
  raise TileSourceFileNotFoundError(self._largeImagePath) from None
121
123
  msg = 'File cannot be opened via tifffile.'
122
124
  raise TileSourceError(msg)
125
+ self._checkForOmeBinaryonly()
123
126
  maxseries, maxsamples = self._biggestSeries()
124
127
  self.tileWidth = self.tileHeight = self._tileSize
125
128
  s = self._tf.series[maxseries]
@@ -127,6 +130,9 @@ class TifffileFileTileSource(FileTileSource, metaclass=LruCacheMetaclass):
127
130
  if len(s.levels) == 1:
128
131
  self.tileWidth = self.tileHeight = self._singleTileSize
129
132
  page = s.pages[0]
133
+ if not hasattr(page, 'tags'):
134
+ msg = 'File will not be opened via tifffile.'
135
+ raise TileSourceError(msg)
130
136
  if ('TileWidth' in page.tags and
131
137
  self._minTileSize <= page.tags['TileWidth'].value <= self._maxTileSize):
132
138
  self.tileWidth = page.tags['TileWidth'].value
@@ -137,6 +143,10 @@ class TifffileFileTileSource(FileTileSource, metaclass=LruCacheMetaclass):
137
143
  self._iccprofiles = [page.tags['InterColorProfile'].value]
138
144
  self.sizeX = s.shape[s.axes.index('X')]
139
145
  self.sizeY = s.shape[s.axes.index('Y')]
146
+ while (self.tileWidth // 2 >= self.sizeX and self.tileHeight // 2 >= self.sizeY and
147
+ min(self.tileWidth, self.tileHeight) // 2 >= self._minTileSize):
148
+ self.tileWidth //= 2
149
+ self.tileHeight //= 2
140
150
  self._mm_x = self._mm_y = None
141
151
  try:
142
152
  unit = {2: 25.4, 3: 10}[page.tags['ResolutionUnit'].value.real]
@@ -170,6 +180,35 @@ class TifffileFileTileSource(FileTileSource, metaclass=LruCacheMetaclass):
170
180
  msg = 'File cannot be opened via tifffile: axes and shape do not match access pattern.'
171
181
  raise TileSourceError(msg)
172
182
 
183
+ def _checkForOmeBinaryonly(self):
184
+ from xml.etree import ElementTree as etree
185
+
186
+ omexml = getattr(self._tf, 'ome_metadata', None)
187
+ if not omexml:
188
+ return
189
+ try:
190
+ root = etree.fromstring(omexml)
191
+ except Exception:
192
+ return
193
+ metadatafile = None
194
+ for element in root:
195
+ if element.tag.endswith('BinaryOnly'):
196
+ metadatafile = element.attrib.get('MetadataFile', '')
197
+ if not metadatafile:
198
+ return
199
+ path = Path(self._largeImagePath).parent / metadatafile
200
+ if not path.is_file():
201
+ return
202
+ try:
203
+ newxml = path.open('r').read()
204
+ except Exception:
205
+ return
206
+ try:
207
+ root = etree.fromstring(newxml)
208
+ except Exception:
209
+ return
210
+ self._tf._omexml = newxml
211
+
173
212
  def _biggestSeries(self):
174
213
  """
175
214
  Find the series with the most pixels. Use all series that have the
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: large-image-source-tifffile
3
- Version: 1.30.7.dev10
3
+ Version: 1.30.7.dev12
4
4
  Summary: A tifffile tilesource for large_image.
5
5
  Home-page: https://github.com/girder/large_image
6
6
  Author: Kitware, Inc.
@@ -19,12 +19,12 @@ Classifier: Programming Language :: Python :: 3.13
19
19
  Requires-Python: >=3.8
20
20
  Description-Content-Type: text/x-rst
21
21
  License-File: LICENSE
22
- Requires-Dist: large-image>=1.30.7.dev10
22
+ Requires-Dist: large-image>=1.30.7.dev12
23
23
  Requires-Dist: dask[array]
24
24
  Requires-Dist: tifffile[all]
25
25
  Requires-Dist: zarr
26
26
  Provides-Extra: girder
27
- Requires-Dist: girder-large-image>=1.30.7.dev10; extra == "girder"
27
+ Requires-Dist: girder-large-image>=1.30.7.dev12; extra == "girder"
28
28
 
29
29
  A tifffile tilesource for large_image.
30
30
 
@@ -0,0 +1,7 @@
1
+ large-image>=1.30.7.dev12
2
+ dask[array]
3
+ tifffile[all]
4
+ zarr
5
+
6
+ [girder]
7
+ girder-large-image>=1.30.7.dev12
@@ -1,7 +0,0 @@
1
- large-image>=1.30.7.dev10
2
- dask[array]
3
- tifffile[all]
4
- zarr
5
-
6
- [girder]
7
- girder-large-image>=1.30.7.dev10