large-image-source-openslide 1.27.5.dev6__py3-none-any.whl → 1.30.7.dev10__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -47,6 +47,8 @@ class OpenslideFileTileSource(FileTileSource, metaclass=LruCacheMetaclass):
47
47
  extensions = {
48
48
  None: SourcePriority.MEDIUM,
49
49
  'bif': SourcePriority.LOW, # Ventana
50
+ 'dcm': SourcePriority.LOW, # DICOM
51
+ 'ini': SourcePriority.LOW, # Part of mrxs
50
52
  'mrxs': SourcePriority.PREFERRED, # MIRAX
51
53
  'ndpi': SourcePriority.PREFERRED, # Hamamatsu
52
54
  'scn': SourcePriority.LOW, # Leica
@@ -92,6 +94,13 @@ class OpenslideFileTileSource(FileTileSource, metaclass=LruCacheMetaclass):
92
94
  tifftools.Tag.ICCProfile.value]['data']]
93
95
  except Exception:
94
96
  pass
97
+ if hasattr(self, '_tiffinfo'):
98
+ for ifd in self._tiffinfo['ifds']:
99
+ if (tifftools.Tag.NDPI_FOCAL_PLANE.value in ifd['tags'] and
100
+ ifd['tags'][tifftools.Tag.NDPI_FOCAL_PLANE.value]['data'][0] != 0):
101
+ msg = ('File will not be opened via OpenSlide; '
102
+ 'non-zero focal planes would be missed.')
103
+ raise TileSourceError(msg)
95
104
 
96
105
  svsAvailableLevels = self._getAvailableLevels(self._largeImagePath)
97
106
  if not len(svsAvailableLevels):
@@ -153,6 +162,30 @@ class OpenslideFileTileSource(FileTileSource, metaclass=LruCacheMetaclass):
153
162
  'svslevel': bestlevel,
154
163
  'scale': scale,
155
164
  })
165
+ self._bounds = None
166
+ try:
167
+ bounds = {
168
+ 'x': int(self._openslide.properties[openslide.PROPERTY_NAME_BOUNDS_X]),
169
+ 'y': int(self._openslide.properties[openslide.PROPERTY_NAME_BOUNDS_Y]),
170
+ 'width': int(self._openslide.properties[openslide.PROPERTY_NAME_BOUNDS_WIDTH]),
171
+ 'height': int(self._openslide.properties[openslide.PROPERTY_NAME_BOUNDS_HEIGHT]),
172
+ }
173
+ if (
174
+ bounds['x'] >= 0 and bounds['width'] > 0 and
175
+ bounds['x'] + bounds['width'] <= self.sizeX and
176
+ bounds['y'] >= 0 and bounds['height'] > 0 and
177
+ bounds['y'] + bounds['height'] <= self.sizeY and
178
+ (bounds['width'] < self.sizeX or bounds['height'] < self.sizeY)
179
+ ):
180
+ self._bounds = bounds
181
+ self.sizeX, self.sizeY = bounds['width'], bounds['height']
182
+ prevlevels = self.levels
183
+ self.levels = int(math.ceil(max(
184
+ math.log(float(self.sizeX) / self.tileWidth),
185
+ math.log(float(self.sizeY) / self.tileHeight)) / math.log(2))) + 1
186
+ self._svslevels = self._svslevels[prevlevels - self.levels:]
187
+ except Exception:
188
+ pass
156
189
  self._populatedLevels = len({l['svslevel'] for l in self._svslevels})
157
190
 
158
191
  def _getTileSize(self):
@@ -291,11 +324,14 @@ class OpenslideFileTileSource(FileTileSource, metaclass=LruCacheMetaclass):
291
324
  scale = 2 ** (self.levels - 1 - z)
292
325
  offsetx = x * self.tileWidth * scale
293
326
  offsety = y * self.tileHeight * scale
327
+ if self._bounds is not None:
328
+ offsetx += self._bounds['x'] // svslevel['scale']
329
+ offsety += self._bounds['y'] // svslevel['scale']
294
330
  # We ask to read an area that will cover the tile at the z level. The
295
331
  # scale we computed in the __init__ process for this svs level tells
296
332
  # how much larger a region we need to read.
297
333
  if svslevel['scale'] > 2 ** self._maxSkippedLevels:
298
- tile = self._getTileFromEmptyLevel(x, y, z, **kwargs)
334
+ tile, format = self._getTileFromEmptyLevel(x, y, z, **kwargs)
299
335
  else:
300
336
  retries = 3
301
337
  while retries > 0:
@@ -304,6 +340,7 @@ class OpenslideFileTileSource(FileTileSource, metaclass=LruCacheMetaclass):
304
340
  (offsetx, offsety), svslevel['svslevel'],
305
341
  (self.tileWidth * svslevel['scale'],
306
342
  self.tileHeight * svslevel['scale']))
343
+ format = TILE_FORMAT_PIL
307
344
  break
308
345
  except openslide.lowlevel.OpenSlideError as exc:
309
346
  self._largeImagePath = str(self._getLargeImagePath())
@@ -323,7 +360,7 @@ class OpenslideFileTileSource(FileTileSource, metaclass=LruCacheMetaclass):
323
360
  if svslevel['scale'] != 1:
324
361
  tile = tile.resize((self.tileWidth, self.tileHeight),
325
362
  getattr(PIL.Image, 'Resampling', PIL.Image).LANCZOS)
326
- return self._outputTile(tile, TILE_FORMAT_PIL, x, y, z, pilImageAllowed,
363
+ return self._outputTile(tile, format, x, y, z, pilImageAllowed,
327
364
  numpyAllowed, **kwargs)
328
365
 
329
366
  def getPreferredLevel(self, level):
@@ -0,0 +1,47 @@
1
+ Metadata-Version: 2.2
2
+ Name: large-image-source-openslide
3
+ Version: 1.30.7.dev10
4
+ Summary: An Openslide tilesource for large_image.
5
+ Home-page: https://github.com/girder/large_image
6
+ Author: Kitware, Inc.
7
+ Author-email: kitware@kitware.com
8
+ License: Apache Software License 2.0
9
+ Keywords: large_image,tile source
10
+ Classifier: Development Status :: 5 - Production/Stable
11
+ Classifier: License :: OSI Approved :: Apache Software License
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.8
14
+ Classifier: Programming Language :: Python :: 3.9
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Requires-Python: >=3.8
20
+ Description-Content-Type: text/x-rst
21
+ License-File: LICENSE
22
+ Requires-Dist: large-image>=1.30.7.dev10
23
+ Requires-Dist: openslide-python>=1.4.1
24
+ Requires-Dist: openslide-bin; platform_system == "Linux" and platform_machine == "x86_64"
25
+ Requires-Dist: openslide-bin; platform_system == "Linux" and platform_machine == "aarch64"
26
+ Requires-Dist: openslide-bin; platform_system == "Windows" and platform_machine == "AMD64"
27
+ Requires-Dist: openslide-bin; platform_system == "Darwin" and platform_machine == "arm64"
28
+ Requires-Dist: openslide-bin; platform_system == "Darwin" and platform_machine == "x86_64"
29
+ Requires-Dist: tifftools>=1.2.0
30
+ Provides-Extra: girder
31
+ Requires-Dist: girder-large-image>=1.30.7.dev10; extra == "girder"
32
+ Dynamic: author
33
+ Dynamic: author-email
34
+ Dynamic: classifier
35
+ Dynamic: description
36
+ Dynamic: description-content-type
37
+ Dynamic: home-page
38
+ Dynamic: keywords
39
+ Dynamic: license
40
+ Dynamic: provides-extra
41
+ Dynamic: requires-dist
42
+ Dynamic: requires-python
43
+ Dynamic: summary
44
+
45
+ An Openslide tilesource for large_image.
46
+
47
+ See the large-image package for more details.
@@ -0,0 +1,8 @@
1
+ large_image_source_openslide/__init__.py,sha256=O1-E-D7ZdY6Ta_ngId_HV0uqqxAbuY_J9fKTNVOFulE,20495
2
+ large_image_source_openslide/girder_source.py,sha256=ntLgOinO7xcO85wFbjx6XEBmTgEtx5cuPZ_K6wXZzqA,1199
3
+ large_image_source_openslide-1.30.7.dev10.dist-info/LICENSE,sha256=psuoW8kuDP96RQsdhzwOqi6fyWv0ct8CR6Jr7He_P_k,10173
4
+ large_image_source_openslide-1.30.7.dev10.dist-info/METADATA,sha256=cyvU_lZazei0R457AvXB-Kt8Zh2deJVZZ-CITnyHIAY,1858
5
+ large_image_source_openslide-1.30.7.dev10.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
6
+ large_image_source_openslide-1.30.7.dev10.dist-info/entry_points.txt,sha256=4Z5cf63yeesvHxiR9W1dY3rfz5_V4Ck2xYhPUp4A1qA,196
7
+ large_image_source_openslide-1.30.7.dev10.dist-info/top_level.txt,sha256=wqaQQDWQl9a_l9s6n07tTxfjeEXePtHBhz1np6aUwQE,29
8
+ large_image_source_openslide-1.30.7.dev10.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.43.0)
2
+ Generator: setuptools (75.8.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,28 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: large-image-source-openslide
3
- Version: 1.27.5.dev6
4
- Summary: An Openslide tilesource for large_image.
5
- Home-page: https://github.com/girder/large_image
6
- Author: Kitware, Inc.
7
- Author-email: kitware@kitware.com
8
- License: Apache Software License 2.0
9
- Keywords: large_image,tile source
10
- Classifier: Development Status :: 5 - Production/Stable
11
- Classifier: License :: OSI Approved :: Apache Software License
12
- Classifier: Programming Language :: Python :: 3
13
- Classifier: Programming Language :: Python :: 3.8
14
- Classifier: Programming Language :: Python :: 3.9
15
- Classifier: Programming Language :: Python :: 3.10
16
- Classifier: Programming Language :: Python :: 3.11
17
- Classifier: Programming Language :: Python :: 3.12
18
- Requires-Python: >=3.8
19
- License-File: LICENSE
20
- Requires-Dist: large-image >=1.27.5.dev6
21
- Requires-Dist: openslide-python >=1.1.0
22
- Requires-Dist: tifftools >=1.2.0
23
- Provides-Extra: girder
24
- Requires-Dist: girder-large-image >=1.27.5.dev6 ; extra == 'girder'
25
-
26
- An Openslide tilesource for large_image.
27
-
28
- See the large-image package for more details.
@@ -1,8 +0,0 @@
1
- large_image_source_openslide/__init__.py,sha256=vzEx04RTBTptXUwbEMtcMMqXC2zq8lVtbenxFcdSfI8,18468
2
- large_image_source_openslide/girder_source.py,sha256=ntLgOinO7xcO85wFbjx6XEBmTgEtx5cuPZ_K6wXZzqA,1199
3
- large_image_source_openslide-1.27.5.dev6.dist-info/LICENSE,sha256=psuoW8kuDP96RQsdhzwOqi6fyWv0ct8CR6Jr7He_P_k,10173
4
- large_image_source_openslide-1.27.5.dev6.dist-info/METADATA,sha256=9S19vFS5irr4-PaOdzAlg4kDwU8VMaqnx34tGU-DSsA,1063
5
- large_image_source_openslide-1.27.5.dev6.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
6
- large_image_source_openslide-1.27.5.dev6.dist-info/entry_points.txt,sha256=4Z5cf63yeesvHxiR9W1dY3rfz5_V4Ck2xYhPUp4A1qA,196
7
- large_image_source_openslide-1.27.5.dev6.dist-info/top_level.txt,sha256=wqaQQDWQl9a_l9s6n07tTxfjeEXePtHBhz1np6aUwQE,29
8
- large_image_source_openslide-1.27.5.dev6.dist-info/RECORD,,