large-image-source-zarr 1.29.3.dev22__tar.gz → 1.29.3.dev33__tar.gz
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.
- {large-image-source-zarr-1.29.3.dev22 → large-image-source-zarr-1.29.3.dev33}/PKG-INFO +3 -3
- {large-image-source-zarr-1.29.3.dev22 → large-image-source-zarr-1.29.3.dev33}/large_image_source_zarr/__init__.py +38 -17
- {large-image-source-zarr-1.29.3.dev22 → large-image-source-zarr-1.29.3.dev33}/large_image_source_zarr.egg-info/PKG-INFO +3 -3
- {large-image-source-zarr-1.29.3.dev22 → large-image-source-zarr-1.29.3.dev33}/large_image_source_zarr.egg-info/requires.txt +2 -2
- {large-image-source-zarr-1.29.3.dev22 → large-image-source-zarr-1.29.3.dev33}/LICENSE +0 -0
- {large-image-source-zarr-1.29.3.dev22 → large-image-source-zarr-1.29.3.dev33}/README.rst +0 -0
- {large-image-source-zarr-1.29.3.dev22 → large-image-source-zarr-1.29.3.dev33}/large_image_source_zarr/girder_source.py +0 -0
- {large-image-source-zarr-1.29.3.dev22 → large-image-source-zarr-1.29.3.dev33}/large_image_source_zarr.egg-info/SOURCES.txt +0 -0
- {large-image-source-zarr-1.29.3.dev22 → large-image-source-zarr-1.29.3.dev33}/large_image_source_zarr.egg-info/dependency_links.txt +0 -0
- {large-image-source-zarr-1.29.3.dev22 → large-image-source-zarr-1.29.3.dev33}/large_image_source_zarr.egg-info/entry_points.txt +0 -0
- {large-image-source-zarr-1.29.3.dev22 → large-image-source-zarr-1.29.3.dev33}/large_image_source_zarr.egg-info/top_level.txt +0 -0
- {large-image-source-zarr-1.29.3.dev22 → large-image-source-zarr-1.29.3.dev33}/pyproject.toml +0 -0
- {large-image-source-zarr-1.29.3.dev22 → large-image-source-zarr-1.29.3.dev33}/setup.cfg +0 -0
- {large-image-source-zarr-1.29.3.dev22 → large-image-source-zarr-1.29.3.dev33}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: large-image-source-zarr
|
|
3
|
-
Version: 1.29.3.
|
|
3
|
+
Version: 1.29.3.dev33
|
|
4
4
|
Summary: A OME Zarr tilesource for large_image.
|
|
5
5
|
Home-page: https://github.com/girder/large_image
|
|
6
6
|
Author: Kitware, Inc.
|
|
@@ -17,11 +17,11 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
17
17
|
Classifier: Programming Language :: Python :: 3.12
|
|
18
18
|
Requires-Python: >=3.6
|
|
19
19
|
License-File: LICENSE
|
|
20
|
-
Requires-Dist: large-image>=1.29.3.
|
|
20
|
+
Requires-Dist: large-image>=1.29.3.dev33
|
|
21
21
|
Requires-Dist: zarr
|
|
22
22
|
Requires-Dist: imagecodecs-numcodecs
|
|
23
23
|
Provides-Extra: girder
|
|
24
|
-
Requires-Dist: girder-large-image>=1.29.3.
|
|
24
|
+
Requires-Dist: girder-large-image>=1.29.3.dev33; extra == "girder"
|
|
25
25
|
Provides-Extra: all
|
|
26
26
|
Requires-Dist: large-image-converter; extra == "all"
|
|
27
27
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import math
|
|
2
|
+
import multiprocessing
|
|
2
3
|
import os
|
|
3
4
|
import shutil
|
|
4
5
|
import tempfile
|
|
@@ -11,7 +12,6 @@ from pathlib import Path
|
|
|
11
12
|
|
|
12
13
|
import numpy as np
|
|
13
14
|
import packaging.version
|
|
14
|
-
import zarr
|
|
15
15
|
|
|
16
16
|
import large_image
|
|
17
17
|
from large_image.cache_util import LruCacheMetaclass, methodcache
|
|
@@ -30,6 +30,23 @@ except PackageNotFoundError:
|
|
|
30
30
|
|
|
31
31
|
warnings.filterwarnings('ignore', category=FutureWarning, module='zarr')
|
|
32
32
|
|
|
33
|
+
zarr = None
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def _lazyImport():
|
|
37
|
+
"""
|
|
38
|
+
Import the zarr module. This is done when needed rather than in the module
|
|
39
|
+
initialization because it is slow.
|
|
40
|
+
"""
|
|
41
|
+
global zarr
|
|
42
|
+
|
|
43
|
+
if zarr is None:
|
|
44
|
+
try:
|
|
45
|
+
import zarr
|
|
46
|
+
except ImportError:
|
|
47
|
+
msg = 'zarr module not found.'
|
|
48
|
+
raise TileSourceError(msg)
|
|
49
|
+
|
|
33
50
|
|
|
34
51
|
class ZarrFileTileSource(FileTileSource, metaclass=LruCacheMetaclass):
|
|
35
52
|
"""
|
|
@@ -70,6 +87,7 @@ class ZarrFileTileSource(FileTileSource, metaclass=LruCacheMetaclass):
|
|
|
70
87
|
"""
|
|
71
88
|
super().__init__(path, **kwargs)
|
|
72
89
|
|
|
90
|
+
_lazyImport()
|
|
73
91
|
if str(path).startswith(NEW_IMAGE_PATH_FLAG):
|
|
74
92
|
self._initNew(path, **kwargs)
|
|
75
93
|
else:
|
|
@@ -110,11 +128,12 @@ class ZarrFileTileSource(FileTileSource, metaclass=LruCacheMetaclass):
|
|
|
110
128
|
"""
|
|
111
129
|
Initialize the tile class for creating a new image.
|
|
112
130
|
"""
|
|
113
|
-
self._tempdir = tempfile.
|
|
114
|
-
self.
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
self.
|
|
131
|
+
self._tempdir = Path(tempfile.gettempdir(), path)
|
|
132
|
+
self._created = False
|
|
133
|
+
if not self._tempdir.exists():
|
|
134
|
+
self._created = True
|
|
135
|
+
self._zarr_store = zarr.DirectoryStore(str(self._tempdir))
|
|
136
|
+
self._zarr = zarr.open(self._zarr_store, mode='a')
|
|
118
137
|
self._largeImagePath = None
|
|
119
138
|
self._dims = {}
|
|
120
139
|
self.sizeX = self.sizeY = self.levels = 0
|
|
@@ -123,7 +142,8 @@ class ZarrFileTileSource(FileTileSource, metaclass=LruCacheMetaclass):
|
|
|
123
142
|
self._output = None
|
|
124
143
|
self._editable = True
|
|
125
144
|
self._bandRanges = None
|
|
126
|
-
self.
|
|
145
|
+
self._threadLock = threading.RLock()
|
|
146
|
+
self._processLock = multiprocessing.Lock()
|
|
127
147
|
self._framecount = 0
|
|
128
148
|
self._mm_x = 0
|
|
129
149
|
self._mm_y = 0
|
|
@@ -140,7 +160,8 @@ class ZarrFileTileSource(FileTileSource, metaclass=LruCacheMetaclass):
|
|
|
140
160
|
except Exception:
|
|
141
161
|
pass
|
|
142
162
|
try:
|
|
143
|
-
self.
|
|
163
|
+
if self._created:
|
|
164
|
+
shutil.rmtree(self._tempdir)
|
|
144
165
|
except Exception:
|
|
145
166
|
pass
|
|
146
167
|
|
|
@@ -317,7 +338,7 @@ class ZarrFileTileSource(FileTileSource, metaclass=LruCacheMetaclass):
|
|
|
317
338
|
Validate that we can read tiles from the zarr parent group in
|
|
318
339
|
self._zarr. Set up the appropriate class variables.
|
|
319
340
|
"""
|
|
320
|
-
if self._editable:
|
|
341
|
+
if self._editable and hasattr(self, '_axes'):
|
|
321
342
|
self._writeInternalMetadata()
|
|
322
343
|
found = self._scanZarrGroup(self._zarr)
|
|
323
344
|
if found['best'] is None:
|
|
@@ -579,7 +600,7 @@ class ZarrFileTileSource(FileTileSource, metaclass=LruCacheMetaclass):
|
|
|
579
600
|
}
|
|
580
601
|
tile, mask, placement, axes = self._validateNewTile(tile, mask, placement, axes)
|
|
581
602
|
|
|
582
|
-
with self.
|
|
603
|
+
with self._threadLock and self._processLock:
|
|
583
604
|
self._axes = {k: i for i, k in enumerate(axes)}
|
|
584
605
|
new_dims = {
|
|
585
606
|
a: max(
|
|
@@ -656,7 +677,7 @@ class ZarrFileTileSource(FileTileSource, metaclass=LruCacheMetaclass):
|
|
|
656
677
|
with an image. The numpy array can have 2 or 3 dimensions.
|
|
657
678
|
"""
|
|
658
679
|
data, _ = _imageToNumpy(image)
|
|
659
|
-
with self.
|
|
680
|
+
with self._threadLock and self._processLock:
|
|
660
681
|
if imageKey is None:
|
|
661
682
|
# Each associated image should be in its own group
|
|
662
683
|
num_existing = len(self.getAssociatedImagesList())
|
|
@@ -671,7 +692,7 @@ class ZarrFileTileSource(FileTileSource, metaclass=LruCacheMetaclass):
|
|
|
671
692
|
|
|
672
693
|
def _writeInternalMetadata(self):
|
|
673
694
|
self._checkEditable()
|
|
674
|
-
with self.
|
|
695
|
+
with self._threadLock and self._processLock:
|
|
675
696
|
name = str(self._tempdir.name).split('/')[-1]
|
|
676
697
|
arrays = dict(self._zarr.arrays())
|
|
677
698
|
channel_axis = self._axes.get('c', self._axes.get('s'))
|
|
@@ -683,8 +704,8 @@ class ZarrFileTileSource(FileTileSource, metaclass=LruCacheMetaclass):
|
|
|
683
704
|
for arr_name in arrays:
|
|
684
705
|
level = int(arr_name)
|
|
685
706
|
scale = [1.0 for a in sorted_axes]
|
|
686
|
-
scale[self._axes.get('x')] = self._mm_x * (2 ** level)
|
|
687
|
-
scale[self._axes.get('y')] = self._mm_y * (2 ** level)
|
|
707
|
+
scale[self._axes.get('x')] = (self._mm_x or 0) * (2 ** level)
|
|
708
|
+
scale[self._axes.get('y')] = (self._mm_y or 0) * (2 ** level)
|
|
688
709
|
dataset_metadata = {
|
|
689
710
|
'path': arr_name,
|
|
690
711
|
'coordinateTransformations': [{
|
|
@@ -957,7 +978,7 @@ class ZarrFileTileSource(FileTileSource, metaclass=LruCacheMetaclass):
|
|
|
957
978
|
**frame_position,
|
|
958
979
|
)
|
|
959
980
|
|
|
960
|
-
source.
|
|
981
|
+
source._validateZarr()
|
|
961
982
|
|
|
962
983
|
if suffix in ['.zarr', '.db', '.sqlite', '.zip']:
|
|
963
984
|
if resample is None:
|
|
@@ -970,7 +991,7 @@ class ZarrFileTileSource(FileTileSource, metaclass=LruCacheMetaclass):
|
|
|
970
991
|
source._writeInternalMetadata() # rewrite with new level datasets
|
|
971
992
|
|
|
972
993
|
if suffix == '.zarr':
|
|
973
|
-
shutil.copytree(source._tempdir
|
|
994
|
+
shutil.copytree(str(source._tempdir), path)
|
|
974
995
|
elif suffix in ['.db', '.sqlite']:
|
|
975
996
|
sqlite_store = zarr.SQLiteStore(path)
|
|
976
997
|
zarr.copy_store(source._zarr_store, sqlite_store, if_exists='replace')
|
|
@@ -983,7 +1004,7 @@ class ZarrFileTileSource(FileTileSource, metaclass=LruCacheMetaclass):
|
|
|
983
1004
|
else:
|
|
984
1005
|
from large_image_converter import convert
|
|
985
1006
|
|
|
986
|
-
attrs_path =
|
|
1007
|
+
attrs_path = source._tempdir / '.zattrs'
|
|
987
1008
|
params = {}
|
|
988
1009
|
if lossy and self.dtype == np.uint8:
|
|
989
1010
|
params['compression'] = 'jpeg'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: large-image-source-zarr
|
|
3
|
-
Version: 1.29.3.
|
|
3
|
+
Version: 1.29.3.dev33
|
|
4
4
|
Summary: A OME Zarr tilesource for large_image.
|
|
5
5
|
Home-page: https://github.com/girder/large_image
|
|
6
6
|
Author: Kitware, Inc.
|
|
@@ -17,11 +17,11 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
17
17
|
Classifier: Programming Language :: Python :: 3.12
|
|
18
18
|
Requires-Python: >=3.6
|
|
19
19
|
License-File: LICENSE
|
|
20
|
-
Requires-Dist: large-image>=1.29.3.
|
|
20
|
+
Requires-Dist: large-image>=1.29.3.dev33
|
|
21
21
|
Requires-Dist: zarr
|
|
22
22
|
Requires-Dist: imagecodecs-numcodecs
|
|
23
23
|
Provides-Extra: girder
|
|
24
|
-
Requires-Dist: girder-large-image>=1.29.3.
|
|
24
|
+
Requires-Dist: girder-large-image>=1.29.3.dev33; extra == "girder"
|
|
25
25
|
Provides-Extra: all
|
|
26
26
|
Requires-Dist: large-image-converter; extra == "all"
|
|
27
27
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{large-image-source-zarr-1.29.3.dev22 → large-image-source-zarr-1.29.3.dev33}/pyproject.toml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|