senoquant 1.0.0b1__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.
- senoquant/__init__.py +6 -0
- senoquant/_reader.py +7 -0
- senoquant/_widget.py +33 -0
- senoquant/napari.yaml +83 -0
- senoquant/reader/__init__.py +5 -0
- senoquant/reader/core.py +369 -0
- senoquant/tabs/__init__.py +15 -0
- senoquant/tabs/batch/__init__.py +10 -0
- senoquant/tabs/batch/backend.py +641 -0
- senoquant/tabs/batch/config.py +270 -0
- senoquant/tabs/batch/frontend.py +1283 -0
- senoquant/tabs/batch/io.py +326 -0
- senoquant/tabs/batch/layers.py +86 -0
- senoquant/tabs/quantification/__init__.py +1 -0
- senoquant/tabs/quantification/backend.py +228 -0
- senoquant/tabs/quantification/features/__init__.py +80 -0
- senoquant/tabs/quantification/features/base.py +142 -0
- senoquant/tabs/quantification/features/marker/__init__.py +5 -0
- senoquant/tabs/quantification/features/marker/config.py +69 -0
- senoquant/tabs/quantification/features/marker/dialog.py +437 -0
- senoquant/tabs/quantification/features/marker/export.py +879 -0
- senoquant/tabs/quantification/features/marker/feature.py +119 -0
- senoquant/tabs/quantification/features/marker/morphology.py +285 -0
- senoquant/tabs/quantification/features/marker/rows.py +654 -0
- senoquant/tabs/quantification/features/marker/thresholding.py +46 -0
- senoquant/tabs/quantification/features/roi.py +346 -0
- senoquant/tabs/quantification/features/spots/__init__.py +5 -0
- senoquant/tabs/quantification/features/spots/config.py +62 -0
- senoquant/tabs/quantification/features/spots/dialog.py +477 -0
- senoquant/tabs/quantification/features/spots/export.py +1292 -0
- senoquant/tabs/quantification/features/spots/feature.py +112 -0
- senoquant/tabs/quantification/features/spots/morphology.py +279 -0
- senoquant/tabs/quantification/features/spots/rows.py +241 -0
- senoquant/tabs/quantification/frontend.py +815 -0
- senoquant/tabs/segmentation/__init__.py +1 -0
- senoquant/tabs/segmentation/backend.py +131 -0
- senoquant/tabs/segmentation/frontend.py +1009 -0
- senoquant/tabs/segmentation/models/__init__.py +5 -0
- senoquant/tabs/segmentation/models/base.py +146 -0
- senoquant/tabs/segmentation/models/cpsam/details.json +65 -0
- senoquant/tabs/segmentation/models/cpsam/model.py +150 -0
- senoquant/tabs/segmentation/models/default_2d/details.json +69 -0
- senoquant/tabs/segmentation/models/default_2d/model.py +664 -0
- senoquant/tabs/segmentation/models/default_3d/details.json +69 -0
- senoquant/tabs/segmentation/models/default_3d/model.py +682 -0
- senoquant/tabs/segmentation/models/hf.py +71 -0
- senoquant/tabs/segmentation/models/nuclear_dilation/__init__.py +1 -0
- senoquant/tabs/segmentation/models/nuclear_dilation/details.json +26 -0
- senoquant/tabs/segmentation/models/nuclear_dilation/model.py +96 -0
- senoquant/tabs/segmentation/models/perinuclear_rings/__init__.py +1 -0
- senoquant/tabs/segmentation/models/perinuclear_rings/details.json +34 -0
- senoquant/tabs/segmentation/models/perinuclear_rings/model.py +132 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/__init__.py +2 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/_csbdeep/csbdeep/__init__.py +3 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/_csbdeep/csbdeep/data/__init__.py +6 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/_csbdeep/csbdeep/data/generate.py +470 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/_csbdeep/csbdeep/data/prepare.py +273 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/_csbdeep/csbdeep/data/rawdata.py +112 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/_csbdeep/csbdeep/data/transform.py +384 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/_csbdeep/csbdeep/internals/__init__.py +0 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/_csbdeep/csbdeep/internals/blocks.py +184 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/_csbdeep/csbdeep/internals/losses.py +79 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/_csbdeep/csbdeep/internals/nets.py +165 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/_csbdeep/csbdeep/internals/predict.py +467 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/_csbdeep/csbdeep/internals/probability.py +67 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/_csbdeep/csbdeep/internals/train.py +148 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/_csbdeep/csbdeep/io/__init__.py +163 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/_csbdeep/csbdeep/models/__init__.py +52 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/_csbdeep/csbdeep/models/base_model.py +329 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/_csbdeep/csbdeep/models/care_isotropic.py +160 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/_csbdeep/csbdeep/models/care_projection.py +178 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/_csbdeep/csbdeep/models/care_standard.py +446 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/_csbdeep/csbdeep/models/care_upsampling.py +54 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/_csbdeep/csbdeep/models/config.py +254 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/_csbdeep/csbdeep/models/pretrained.py +119 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/_csbdeep/csbdeep/scripts/__init__.py +0 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/_csbdeep/csbdeep/scripts/care_predict.py +180 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/_csbdeep/csbdeep/utils/__init__.py +5 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/_csbdeep/csbdeep/utils/plot_utils.py +159 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/_csbdeep/csbdeep/utils/six.py +18 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/_csbdeep/csbdeep/utils/tf.py +644 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/_csbdeep/csbdeep/utils/utils.py +272 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/_csbdeep/csbdeep/version.py +1 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/_csbdeep/docs/source/conf.py +368 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/_csbdeep/setup.py +68 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/_csbdeep/tests/test_datagen.py +169 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/_csbdeep/tests/test_models.py +462 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/_csbdeep/tests/test_utils.py +166 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/_csbdeep/tools/create_zip_contents.py +34 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/_stardist/__init__.py +30 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/_stardist/big.py +624 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/_stardist/bioimageio_utils.py +494 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/_stardist/data/__init__.py +39 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/_stardist/geometry/__init__.py +10 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/_stardist/geometry/geom2d.py +215 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/_stardist/geometry/geom3d.py +349 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/_stardist/matching.py +483 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/_stardist/models/__init__.py +28 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/_stardist/models/base.py +1217 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/_stardist/models/model2d.py +594 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/_stardist/models/model3d.py +696 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/_stardist/nms.py +384 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/_stardist/plot/__init__.py +2 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/_stardist/plot/plot.py +74 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/_stardist/plot/render.py +298 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/_stardist/rays3d.py +373 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/_stardist/sample_patches.py +65 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/_stardist/scripts/__init__.py +0 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/_stardist/scripts/predict2d.py +90 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/_stardist/scripts/predict3d.py +93 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/_stardist/utils.py +408 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/_stardist/version.py +1 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/onnx_framework/__init__.py +45 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/onnx_framework/convert/__init__.py +17 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/onnx_framework/convert/cli.py +55 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/onnx_framework/convert/core.py +285 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/onnx_framework/inspect/__init__.py +15 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/onnx_framework/inspect/cli.py +36 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/onnx_framework/inspect/divisibility.py +193 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/onnx_framework/inspect/probe.py +100 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/onnx_framework/inspect/receptive_field.py +182 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/onnx_framework/inspect/rf_cli.py +48 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/onnx_framework/inspect/valid_sizes.py +278 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/onnx_framework/post/__init__.py +8 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/onnx_framework/post/core.py +157 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/onnx_framework/pre/__init__.py +17 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/onnx_framework/pre/core.py +226 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/onnx_framework/predict/__init__.py +5 -0
- senoquant/tabs/segmentation/stardist_onnx_utils/onnx_framework/predict/core.py +401 -0
- senoquant/tabs/settings/__init__.py +1 -0
- senoquant/tabs/settings/backend.py +29 -0
- senoquant/tabs/settings/frontend.py +19 -0
- senoquant/tabs/spots/__init__.py +1 -0
- senoquant/tabs/spots/backend.py +139 -0
- senoquant/tabs/spots/frontend.py +800 -0
- senoquant/tabs/spots/models/__init__.py +5 -0
- senoquant/tabs/spots/models/base.py +94 -0
- senoquant/tabs/spots/models/rmp/details.json +61 -0
- senoquant/tabs/spots/models/rmp/model.py +499 -0
- senoquant/tabs/spots/models/udwt/details.json +103 -0
- senoquant/tabs/spots/models/udwt/model.py +482 -0
- senoquant/utils.py +25 -0
- senoquant-1.0.0b1.dist-info/METADATA +193 -0
- senoquant-1.0.0b1.dist-info/RECORD +148 -0
- senoquant-1.0.0b1.dist-info/WHEEL +5 -0
- senoquant-1.0.0b1.dist-info/entry_points.txt +2 -0
- senoquant-1.0.0b1.dist-info/licenses/LICENSE +28 -0
- senoquant-1.0.0b1.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
from __future__ import print_function, unicode_literals, absolute_import, division
|
|
2
|
+
from six.moves import range, zip, map, reduce, filter
|
|
3
|
+
|
|
4
|
+
# import warnings
|
|
5
|
+
import numpy as np
|
|
6
|
+
import pytest
|
|
7
|
+
from csbdeep.data import NoNormalizer, PercentileNormalizer, NoResizer, PadAndCropResizer
|
|
8
|
+
from csbdeep.utils import normalize_minmse
|
|
9
|
+
from csbdeep.internals.predict import tile_iterator_1d, tile_iterator, total_n_tiles
|
|
10
|
+
from csbdeep.internals.train import RollingSequence
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@pytest.mark.parametrize('axes', ('ZYX', 'XY', 'TXYC'))
|
|
15
|
+
def test_resizer(axes):
|
|
16
|
+
rng = np.random.RandomState(42)
|
|
17
|
+
|
|
18
|
+
resizer = PadAndCropResizer()
|
|
19
|
+
checker = NoResizer()
|
|
20
|
+
|
|
21
|
+
for _ in range(50):
|
|
22
|
+
|
|
23
|
+
imdims = list(rng.randint(20,40,size=len(axes)))
|
|
24
|
+
div_by = list(rng.randint(1,20,size=len(axes)))
|
|
25
|
+
|
|
26
|
+
u = np.empty(imdims,np.float32)
|
|
27
|
+
if any(s%div_n!=0 for s, div_n in zip(imdims, div_by)):
|
|
28
|
+
with pytest.raises(ValueError):
|
|
29
|
+
checker.before(u, axes, div_by)
|
|
30
|
+
|
|
31
|
+
v = resizer.before(u, axes, div_by)
|
|
32
|
+
assert all (
|
|
33
|
+
s_v >= s_u and s_v%div_n==0
|
|
34
|
+
for s_u, s_v, div_n in zip(u.shape, v.shape, div_by)
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
w = resizer.after(v, axes)
|
|
38
|
+
assert u.shape == w.shape
|
|
39
|
+
|
|
40
|
+
d = rng.choice(len(axes))
|
|
41
|
+
_axes = axes.replace(axes[d],'')
|
|
42
|
+
_u = np.take(u,0,axis=d)
|
|
43
|
+
_v = np.take(v,0,axis=d)
|
|
44
|
+
_w = resizer.after(_v, _axes)
|
|
45
|
+
assert _u.shape == _w.shape
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
@pytest.mark.parametrize('axes', ('CZYX', 'ZYX', 'XY', 'XCY', 'TXYC'))
|
|
50
|
+
def test_normalizer(axes):
|
|
51
|
+
rng = np.random.RandomState(42)
|
|
52
|
+
|
|
53
|
+
no_normalizer = NoNormalizer(do_after=False)
|
|
54
|
+
paxis = tuple(d for d,a in enumerate(axes) if a != 'C')
|
|
55
|
+
def _percentile(x,p):
|
|
56
|
+
return np.percentile(x,p,axis=paxis,keepdims=True)
|
|
57
|
+
|
|
58
|
+
for _ in range(50):
|
|
59
|
+
pmin = rng.uniform(0,50)
|
|
60
|
+
pmax = rng.uniform(pmin+1,100)
|
|
61
|
+
normalizer = PercentileNormalizer(pmin, pmax, do_after=True)
|
|
62
|
+
|
|
63
|
+
imdims = list(rng.randint(10,20,size=len(axes)))
|
|
64
|
+
u = rng.uniform(0,10000,size=imdims).astype(np.float32,copy=False)
|
|
65
|
+
u_pmin, u_pmax = _percentile(u,pmin), _percentile(u,pmax)
|
|
66
|
+
|
|
67
|
+
assert np.allclose(u, no_normalizer.before(u, axes))
|
|
68
|
+
with pytest.raises(ValueError):
|
|
69
|
+
no_normalizer.after(u, u, axes)
|
|
70
|
+
|
|
71
|
+
v = normalizer.before(u, axes)
|
|
72
|
+
v_pmin, v_pmax = _percentile(v,pmin), _percentile(v,pmax)
|
|
73
|
+
assert np.mean(np.abs(v_pmin-0)) < 1e-5 and np.mean(np.abs(v_pmax-1)) < 1e-5
|
|
74
|
+
|
|
75
|
+
w = normalizer.after(v, None, axes)[0]
|
|
76
|
+
w_pmin, w_pmax = _percentile(w,pmin), _percentile(w,pmax)
|
|
77
|
+
assert np.allclose(u_pmin,w_pmin) and np.allclose(u_pmax,w_pmax)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def test_normalize_minmse():
|
|
82
|
+
rng = np.random.RandomState(42)
|
|
83
|
+
for _ in range(50):
|
|
84
|
+
target = rng.uniform(-100,100,size=(32,32,32))
|
|
85
|
+
x = rng.uniform(-500,500)*target + rng.uniform(-500,500)
|
|
86
|
+
assert np.allclose(normalize_minmse(x,target),target)
|
|
87
|
+
x, target = x.astype(np.float32), target.astype(np.float32)
|
|
88
|
+
assert np.max(np.abs(normalize_minmse(x,target)-target)) < 1e-3
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
@pytest.mark.parametrize('guarantee', ('size', 'n_tiles'))
|
|
93
|
+
def test_tile_iterator_1d(guarantee):
|
|
94
|
+
rng = np.random.RandomState(42)
|
|
95
|
+
for _ in range(50):
|
|
96
|
+
n = rng.randint(low=10,high=500)
|
|
97
|
+
block_size = rng.randint(low=1,high=(n-n//3))
|
|
98
|
+
n = block_size * (n // block_size)
|
|
99
|
+
n_blocks = n // block_size
|
|
100
|
+
n_block_overlap = rng.randint(low=0,high=n_blocks+1)
|
|
101
|
+
n_tiles = rng.randint(low=1,high=n_blocks+1)
|
|
102
|
+
|
|
103
|
+
x = rng.uniform(size=n)
|
|
104
|
+
y = np.empty_like(x)
|
|
105
|
+
c = 0
|
|
106
|
+
tile_shape = None
|
|
107
|
+
actual_n_tiles = total_n_tiles(x,[n_tiles],[block_size],[n_block_overlap],guarantee=guarantee)
|
|
108
|
+
for tile,s_src,s_dst in tile_iterator_1d(x,0,n_tiles=n_tiles,block_size=block_size,n_block_overlap=n_block_overlap,guarantee=guarantee):
|
|
109
|
+
y[s_dst] = tile[s_src]
|
|
110
|
+
assert tile.shape[0] % block_size == 0
|
|
111
|
+
assert tile[s_src].shape[0] % block_size == 0
|
|
112
|
+
if guarantee == 'size':
|
|
113
|
+
if tile_shape is None: tile_shape = tile.shape
|
|
114
|
+
assert tile_shape == tile.shape
|
|
115
|
+
# TODO: good way to test overlap size?
|
|
116
|
+
c += 1
|
|
117
|
+
|
|
118
|
+
assert c == actual_n_tiles
|
|
119
|
+
assert np.allclose(x,y)
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
@pytest.mark.parametrize('n_dims', (1,2,3))
|
|
124
|
+
@pytest.mark.parametrize('guarantee', ('size', 'n_tiles'))
|
|
125
|
+
def test_tile_iterator(guarantee, n_dims):
|
|
126
|
+
rng = np.random.RandomState(42)
|
|
127
|
+
for _ in range(10):
|
|
128
|
+
n = rng.randint(low=10,high=300,size=n_dims)
|
|
129
|
+
n_blocks = list(rng.randint(low=1,high=10,size=n_dims))
|
|
130
|
+
block_size = [_n // _n_blocks for _n_blocks,_n in zip(n_blocks,n)]
|
|
131
|
+
n = [_block_size * (_n // _block_size) for _block_size,_n in zip(block_size,n)]
|
|
132
|
+
n_block_overlap = [rng.randint(low=0,high=_n_blocks+1) for _n_blocks in n_blocks]
|
|
133
|
+
n_tiles = [rng.randint(low=1,high=_n_blocks+1) for _n_blocks in n_blocks]
|
|
134
|
+
|
|
135
|
+
x = rng.uniform(size=n)
|
|
136
|
+
y = np.empty_like(x)
|
|
137
|
+
c = 0
|
|
138
|
+
actual_n_tiles = total_n_tiles(x,n_tiles,block_size,n_block_overlap,guarantee=guarantee)
|
|
139
|
+
for tile,s_src,s_dst in tile_iterator(x,n_tiles,block_size,n_block_overlap,guarantee):
|
|
140
|
+
y[s_dst] = tile[s_src]
|
|
141
|
+
c += 1
|
|
142
|
+
|
|
143
|
+
assert c == actual_n_tiles
|
|
144
|
+
assert np.allclose(x,y)
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
def test_rolling_sequence():
|
|
149
|
+
rng = np.random.RandomState(42)
|
|
150
|
+
for shuffle in (False,True):
|
|
151
|
+
for data_size in (5,60,123):
|
|
152
|
+
for batch_size in (3,7,32):
|
|
153
|
+
seq = RollingSequence(data_size, batch_size, shuffle=shuffle, rng=rng)
|
|
154
|
+
|
|
155
|
+
n_batches = 3 * int(np.ceil(data_size/float(batch_size)))
|
|
156
|
+
perm = np.random.permutation(n_batches)
|
|
157
|
+
batches_perm = [seq[i] for i in perm]
|
|
158
|
+
batches_linear = [seq[i] for i in np.arange(n_batches)]
|
|
159
|
+
assert all(np.all(batches_perm[i]==batches_linear[j]) for i,j in enumerate(perm))
|
|
160
|
+
|
|
161
|
+
res = np.concatenate(batches_linear)
|
|
162
|
+
ref = np.concatenate([seq.index_map[i] for i in sorted(seq.index_map.keys())])
|
|
163
|
+
assert np.all(ref[:len(res)] == res)
|
|
164
|
+
|
|
165
|
+
counts = np.unique(ref, return_counts=True)[1]
|
|
166
|
+
assert all(counts[0] == c for c in counts)
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
from zipfile import ZipFile
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
suffix_out = '.contents'
|
|
8
|
+
|
|
9
|
+
def create_contents(f):
|
|
10
|
+
file_zip = Path(f)
|
|
11
|
+
# remove suffix_out if present
|
|
12
|
+
if len(file_zip.suffixes) > 0 and file_zip.suffixes[-1] == suffix_out:
|
|
13
|
+
file_zip = Path(file_zip.stem)
|
|
14
|
+
file_out = file_zip.with_suffix(''.join(file_zip.suffixes+[suffix_out]))
|
|
15
|
+
assert file_zip.exists() and file_zip.is_file()
|
|
16
|
+
|
|
17
|
+
with ZipFile(file_zip) as zfile:
|
|
18
|
+
with file_out.open('w') as ofile:
|
|
19
|
+
for entry in zfile.infolist():
|
|
20
|
+
print("%10d\t%s" % (entry.file_size, entry.filename), file=ofile)
|
|
21
|
+
|
|
22
|
+
print(f"written: {file_out.resolve()}")
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
if __name__ == '__main__':
|
|
26
|
+
'__file__' in locals() or '__file__' in globals() or sys.exit(0)
|
|
27
|
+
if len(sys.argv) == 1:
|
|
28
|
+
print(f"usage: {sys.argv[0]} [zip files...]")
|
|
29
|
+
sys.exit(0)
|
|
30
|
+
|
|
31
|
+
for f in sys.argv[1:]:
|
|
32
|
+
f = Path(f)
|
|
33
|
+
if f.exists() and f.is_file() and '.zip' in f.suffixes:
|
|
34
|
+
create_contents(f)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
from __future__ import absolute_import, print_function
|
|
2
|
+
|
|
3
|
+
import warnings
|
|
4
|
+
def format_warning(message, category, filename, lineno, line=''):
|
|
5
|
+
import pathlib
|
|
6
|
+
return f"{pathlib.Path(filename).name} ({lineno}): {message}\n"
|
|
7
|
+
warnings.formatwarning = format_warning
|
|
8
|
+
del warnings
|
|
9
|
+
|
|
10
|
+
from .version import __version__
|
|
11
|
+
|
|
12
|
+
# TODO: which functions to expose here? all?
|
|
13
|
+
from .nms import non_maximum_suppression, non_maximum_suppression_3d, non_maximum_suppression_3d_sparse
|
|
14
|
+
from .utils import edt_prob, fill_label_holes, sample_points, calculate_extents, export_imagej_rois, gputools_available
|
|
15
|
+
from .geometry import star_dist, polygons_to_label, relabel_image_stardist, ray_angles, dist_to_coord
|
|
16
|
+
from .geometry import star_dist3D, polyhedron_to_label, relabel_image_stardist3D
|
|
17
|
+
from .plot.plot import random_label_cmap, draw_polygons, _draw_polygons
|
|
18
|
+
from .plot.render import render_label, render_label_pred
|
|
19
|
+
from .rays3d import rays_from_json, Rays_Cartesian, Rays_SubDivide, Rays_Tetra, Rays_Octo, Rays_GoldenSpiral, Rays_Explicit
|
|
20
|
+
from .sample_patches import sample_patches
|
|
21
|
+
from .bioimageio_utils import export_bioimageio, import_bioimageio
|
|
22
|
+
|
|
23
|
+
def _py_deprecation(ver_python=(3,6), ver_stardist=None):
|
|
24
|
+
import sys
|
|
25
|
+
from packaging.version import Version
|
|
26
|
+
if sys.version_info[:2] == ver_python and (ver_stardist is None or Version(__version__) < Version(ver_stardist)):
|
|
27
|
+
print(f"You are using Python {ver_python[0]}.{ver_python[1]}, which is deprecated and will no longer be supported in {'future versions of StarDist' if ver_stardist is None else f'StarDist {ver_stardist}'}.\n"
|
|
28
|
+
f"→ Please upgrade to Python {ver_python[0]}.{ver_python[1]+1} or later.", file=sys.stderr, flush=True)
|
|
29
|
+
_py_deprecation()
|
|
30
|
+
del _py_deprecation
|