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,159 @@
|
|
|
1
|
+
from __future__ import print_function, unicode_literals, absolute_import, division
|
|
2
|
+
from six.moves import range, zip, map, reduce, filter
|
|
3
|
+
from six import string_types
|
|
4
|
+
|
|
5
|
+
import numpy as np
|
|
6
|
+
|
|
7
|
+
from .utils import normalize
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def plot_history(history,*keys,**kwargs):
|
|
12
|
+
"""Plot (Keras) training history returned by :func:`CARE.train`."""
|
|
13
|
+
import matplotlib.pyplot as plt
|
|
14
|
+
|
|
15
|
+
logy = kwargs.pop('logy',False)
|
|
16
|
+
|
|
17
|
+
if all(( isinstance(k,string_types) for k in keys )):
|
|
18
|
+
w, keys = 1, [keys]
|
|
19
|
+
else:
|
|
20
|
+
w = len(keys)
|
|
21
|
+
|
|
22
|
+
plt.gcf()
|
|
23
|
+
for i, group in enumerate(keys):
|
|
24
|
+
plt.subplot(1,w,i+1)
|
|
25
|
+
for k in ([group] if isinstance(group,string_types) else group):
|
|
26
|
+
plt.plot(history.epoch,history.history[k],'.-',label=k,**kwargs)
|
|
27
|
+
if logy:
|
|
28
|
+
plt.gca().set_yscale('log', nonposy='clip')
|
|
29
|
+
plt.xlabel('epoch')
|
|
30
|
+
plt.legend(loc='best')
|
|
31
|
+
# plt.tight_layout()
|
|
32
|
+
plt.show()
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def plot_some(*arr, **kwargs):
|
|
36
|
+
"""Quickly plot multiple images at once.
|
|
37
|
+
|
|
38
|
+
each arr has to be a list of 2D or 3D images
|
|
39
|
+
|
|
40
|
+
Example
|
|
41
|
+
=======
|
|
42
|
+
|
|
43
|
+
x = np.ones((200,200))
|
|
44
|
+
plot_some([x],[x])
|
|
45
|
+
|
|
46
|
+
x = np.ones((5,200,200))
|
|
47
|
+
plot_some(x,x,x)
|
|
48
|
+
|
|
49
|
+
"""
|
|
50
|
+
title_list = kwargs.pop('title_list',None)
|
|
51
|
+
pmin = kwargs.pop('pmin',0)
|
|
52
|
+
pmax = kwargs.pop('pmax',100)
|
|
53
|
+
cmap = kwargs.pop('cmap','magma')
|
|
54
|
+
imshow_kwargs = kwargs
|
|
55
|
+
return _plot_some(arr=arr, title_list=title_list, pmin=pmin, pmax=pmax, cmap=cmap, **imshow_kwargs)
|
|
56
|
+
|
|
57
|
+
def _plot_some(arr, title_list=None, pmin=0, pmax=100, cmap='magma', **imshow_kwargs):
|
|
58
|
+
"""
|
|
59
|
+
plots a matrix of images
|
|
60
|
+
|
|
61
|
+
arr = [ X_1, X_2, ..., X_n]
|
|
62
|
+
|
|
63
|
+
where each X_i is a list of images
|
|
64
|
+
|
|
65
|
+
:param arr:
|
|
66
|
+
:param title_list:
|
|
67
|
+
:param pmin:
|
|
68
|
+
:param pmax:
|
|
69
|
+
:param imshow_kwargs:
|
|
70
|
+
:return:
|
|
71
|
+
|
|
72
|
+
"""
|
|
73
|
+
import matplotlib.pyplot as plt
|
|
74
|
+
imshow_kwargs['cmap'] = cmap
|
|
75
|
+
|
|
76
|
+
def make_acceptable(a):
|
|
77
|
+
return np.asarray(a)
|
|
78
|
+
def color_image(a):
|
|
79
|
+
return np.stack(tuple(map(to_color,a))) if 1 < a.shape[-1] <= 3 else a
|
|
80
|
+
def max_project(a):
|
|
81
|
+
ndim_allowed = 2 + int(1 <= a.shape[-1] <= 3)
|
|
82
|
+
proj_axis = tuple(range(1, 1 + max(0, a[0].ndim - ndim_allowed)))
|
|
83
|
+
return np.max(a, axis=proj_axis)
|
|
84
|
+
|
|
85
|
+
arr = map(make_acceptable,arr)
|
|
86
|
+
arr = map(color_image,arr)
|
|
87
|
+
arr = map(max_project,arr)
|
|
88
|
+
arr = list(arr)
|
|
89
|
+
|
|
90
|
+
h = len(arr)
|
|
91
|
+
w = len(arr[0])
|
|
92
|
+
plt.gcf()
|
|
93
|
+
for i in range(h):
|
|
94
|
+
for j in range(w):
|
|
95
|
+
plt.subplot(h, w, i * w + j + 1)
|
|
96
|
+
try:
|
|
97
|
+
plt.title(title_list[i][j], fontsize=8)
|
|
98
|
+
except:
|
|
99
|
+
pass
|
|
100
|
+
img = arr[i][j]
|
|
101
|
+
if pmin!=0 or pmax!=100:
|
|
102
|
+
img = normalize(img,pmin=pmin,pmax=pmax,clip=True)
|
|
103
|
+
plt.imshow(np.squeeze(img),**imshow_kwargs)
|
|
104
|
+
plt.axis("off")
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def to_color(arr, pmin=1, pmax=99.8, gamma=1., colors=((0, 1, 0), (1, 0, 1), (0, 1, 1))):
|
|
108
|
+
"""Converts a 2D or 3D stack to a colored image (maximal 3 channels).
|
|
109
|
+
|
|
110
|
+
Parameters
|
|
111
|
+
----------
|
|
112
|
+
arr : numpy.ndarray
|
|
113
|
+
2D or 3D input data
|
|
114
|
+
pmin : float
|
|
115
|
+
lower percentile, pass -1 if no lower normalization is required
|
|
116
|
+
pmax : float
|
|
117
|
+
upper percentile, pass -1 if no upper normalization is required
|
|
118
|
+
gamma : float
|
|
119
|
+
gamma correction
|
|
120
|
+
colors : list
|
|
121
|
+
list of colors (r,g,b) for each channel of the input
|
|
122
|
+
|
|
123
|
+
Returns
|
|
124
|
+
-------
|
|
125
|
+
numpy.ndarray
|
|
126
|
+
colored image
|
|
127
|
+
"""
|
|
128
|
+
if not arr.ndim in (2,3):
|
|
129
|
+
raise ValueError("only 2d or 3d arrays supported")
|
|
130
|
+
|
|
131
|
+
if arr.ndim ==2:
|
|
132
|
+
arr = arr[np.newaxis]
|
|
133
|
+
|
|
134
|
+
ind_min = np.argmin(arr.shape)
|
|
135
|
+
arr = np.moveaxis(arr, ind_min, 0).astype(np.float32)
|
|
136
|
+
|
|
137
|
+
out = np.zeros(arr.shape[1:] + (3,))
|
|
138
|
+
|
|
139
|
+
eps = 1.e-20
|
|
140
|
+
if pmin>=0:
|
|
141
|
+
mi = np.percentile(arr, pmin, axis=(1, 2), keepdims=True)
|
|
142
|
+
else:
|
|
143
|
+
mi = 0
|
|
144
|
+
|
|
145
|
+
if pmax>=0:
|
|
146
|
+
ma = np.percentile(arr, pmax, axis=(1, 2), keepdims=True)
|
|
147
|
+
else:
|
|
148
|
+
ma = 1.+eps
|
|
149
|
+
|
|
150
|
+
arr_norm = (1. * arr - mi) / (ma - mi + eps)
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
for i_stack, col_stack in enumerate(colors):
|
|
154
|
+
if i_stack >= len(arr):
|
|
155
|
+
break
|
|
156
|
+
for j, c in enumerate(col_stack):
|
|
157
|
+
out[..., j] += c * arr_norm[i_stack]
|
|
158
|
+
|
|
159
|
+
return np.clip(out, 0, 1)
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from __future__ import absolute_import, print_function
|
|
2
|
+
|
|
3
|
+
try:
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
Path().expanduser()
|
|
6
|
+
except (ImportError,AttributeError):
|
|
7
|
+
from pathlib2 import Path
|
|
8
|
+
|
|
9
|
+
try:
|
|
10
|
+
import tempfile
|
|
11
|
+
tempfile.TemporaryDirectory
|
|
12
|
+
except (ImportError,AttributeError):
|
|
13
|
+
from backports import tempfile
|
|
14
|
+
|
|
15
|
+
try:
|
|
16
|
+
FileNotFoundError = FileNotFoundError
|
|
17
|
+
except NameError:
|
|
18
|
+
FileNotFoundError = IOError
|