dcnum 0.17.0__py3-none-any.whl → 0.23.2__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.
Potentially problematic release.
This version of dcnum might be problematic. Click here for more details.
- dcnum/_version.py +2 -2
- dcnum/feat/__init__.py +1 -1
- dcnum/feat/event_extractor_manager_thread.py +34 -25
- dcnum/feat/feat_background/base.py +22 -26
- dcnum/feat/feat_background/bg_copy.py +18 -12
- dcnum/feat/feat_background/bg_roll_median.py +20 -10
- dcnum/feat/feat_background/bg_sparse_median.py +55 -7
- dcnum/feat/feat_brightness/bright_all.py +41 -6
- dcnum/feat/feat_contour/__init__.py +4 -0
- dcnum/feat/{feat_moments/mt_legacy.py → feat_contour/moments.py} +32 -8
- dcnum/feat/feat_contour/volume.py +174 -0
- dcnum/feat/feat_texture/tex_all.py +28 -1
- dcnum/feat/gate.py +2 -2
- dcnum/feat/queue_event_extractor.py +30 -9
- dcnum/logic/ctrl.py +222 -48
- dcnum/logic/job.py +85 -2
- dcnum/logic/json_encoder.py +2 -0
- dcnum/meta/ppid.py +17 -3
- dcnum/read/__init__.py +1 -0
- dcnum/read/cache.py +100 -78
- dcnum/read/const.py +6 -4
- dcnum/read/hdf5_data.py +146 -23
- dcnum/read/mapped.py +87 -0
- dcnum/segm/__init__.py +6 -3
- dcnum/segm/segm_thresh.py +6 -18
- dcnum/segm/segm_torch/__init__.py +23 -0
- dcnum/segm/segm_torch/segm_torch_base.py +125 -0
- dcnum/segm/segm_torch/segm_torch_mpo.py +71 -0
- dcnum/segm/segm_torch/segm_torch_sto.py +88 -0
- dcnum/segm/segm_torch/torch_model.py +95 -0
- dcnum/segm/segm_torch/torch_postproc.py +93 -0
- dcnum/segm/segm_torch/torch_preproc.py +114 -0
- dcnum/segm/segmenter.py +181 -80
- dcnum/segm/segmenter_manager_thread.py +38 -30
- dcnum/segm/{segmenter_cpu.py → segmenter_mpo.py} +116 -44
- dcnum/segm/segmenter_sto.py +110 -0
- dcnum/write/__init__.py +2 -1
- dcnum/write/deque_writer_thread.py +9 -1
- dcnum/write/queue_collector_thread.py +8 -14
- dcnum/write/writer.py +128 -5
- {dcnum-0.17.0.dist-info → dcnum-0.23.2.dist-info}/METADATA +4 -2
- dcnum-0.23.2.dist-info/RECORD +55 -0
- {dcnum-0.17.0.dist-info → dcnum-0.23.2.dist-info}/WHEEL +1 -1
- dcnum/feat/feat_moments/__init__.py +0 -4
- dcnum/segm/segmenter_gpu.py +0 -64
- dcnum-0.17.0.dist-info/RECORD +0 -46
- /dcnum/feat/{feat_moments/ct_opencv.py → feat_contour/contour.py} +0 -0
- {dcnum-0.17.0.dist-info → dcnum-0.23.2.dist-info}/LICENSE +0 -0
- {dcnum-0.17.0.dist-info → dcnum-0.23.2.dist-info}/top_level.txt +0 -0
dcnum/write/writer.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import hashlib
|
|
2
2
|
import json
|
|
3
3
|
import pathlib
|
|
4
|
-
from typing import List
|
|
4
|
+
from typing import Dict, List
|
|
5
5
|
import warnings
|
|
6
6
|
|
|
7
7
|
import h5py
|
|
@@ -17,9 +17,39 @@ class CreatingFileWithoutBasinWarning(UserWarning):
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
class HDF5Writer:
|
|
20
|
-
def __init__(self,
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
def __init__(self,
|
|
21
|
+
# TODO: make this a mandatory argument when `path` is
|
|
22
|
+
# properly removed
|
|
23
|
+
obj: h5py.File | pathlib.Path | str = None,
|
|
24
|
+
mode: str = "a",
|
|
25
|
+
ds_kwds: Dict = None,
|
|
26
|
+
path: pathlib.Path | str = None,
|
|
27
|
+
):
|
|
28
|
+
"""Write deformability cytometry HDF5 data
|
|
29
|
+
|
|
30
|
+
Parameters
|
|
31
|
+
----------
|
|
32
|
+
obj: h5py.File | pathlib.Path | str
|
|
33
|
+
object to instantiate the writer from; If this is already
|
|
34
|
+
a :class:`h5py.File` object, then it is used, otherwise the
|
|
35
|
+
argument is passed to :class:`h5py.File`
|
|
36
|
+
mode: str
|
|
37
|
+
opening mode when using :class:`h5py.File`
|
|
38
|
+
ds_kwds: Dict
|
|
39
|
+
keyword arguments with which to initialize new Datasets
|
|
40
|
+
(e.g. compression)
|
|
41
|
+
"""
|
|
42
|
+
if path is not None:
|
|
43
|
+
obj = path
|
|
44
|
+
warnings.warn("The `path` keyword argument is deprecated, use "
|
|
45
|
+
"`obj` instead",
|
|
46
|
+
DeprecationWarning)
|
|
47
|
+
if isinstance(obj, h5py.File):
|
|
48
|
+
self.h5 = obj
|
|
49
|
+
self.h5_owned = False
|
|
50
|
+
else:
|
|
51
|
+
self.h5 = h5py.File(obj, mode=mode, libver="latest")
|
|
52
|
+
self.h5_owned = True
|
|
23
53
|
self.events = self.h5.require_group("events")
|
|
24
54
|
ds_kwds = set_default_filter_kwargs(ds_kwds)
|
|
25
55
|
self.ds_kwds = ds_kwds
|
|
@@ -31,7 +61,9 @@ class HDF5Writer:
|
|
|
31
61
|
self.close()
|
|
32
62
|
|
|
33
63
|
def close(self):
|
|
34
|
-
self.h5.
|
|
64
|
+
self.h5.flush()
|
|
65
|
+
if self.h5_owned:
|
|
66
|
+
self.h5.close()
|
|
35
67
|
|
|
36
68
|
@staticmethod
|
|
37
69
|
def get_best_nd_chunks(item_shape, feat_dtype=np.float64):
|
|
@@ -83,6 +115,7 @@ class HDF5Writer:
|
|
|
83
115
|
paths: List[str | pathlib.Path],
|
|
84
116
|
features: List[str] = None,
|
|
85
117
|
description: str | None = None,
|
|
118
|
+
mapping: np.ndarray = None
|
|
86
119
|
):
|
|
87
120
|
"""Write an HDF5-based file basin
|
|
88
121
|
|
|
@@ -96,6 +129,9 @@ class HDF5Writer:
|
|
|
96
129
|
list of features provided by `paths`
|
|
97
130
|
description: str
|
|
98
131
|
optional string describing the basin
|
|
132
|
+
mapping: 1D array
|
|
133
|
+
integer array with indices that map the basin dataset
|
|
134
|
+
to this dataset
|
|
99
135
|
"""
|
|
100
136
|
bdat = {
|
|
101
137
|
"description": description,
|
|
@@ -104,8 +140,38 @@ class HDF5Writer:
|
|
|
104
140
|
"paths": [str(pp) for pp in paths],
|
|
105
141
|
"type": "file",
|
|
106
142
|
}
|
|
143
|
+
# Explicit features stored in basin file
|
|
107
144
|
if features is not None and len(features):
|
|
108
145
|
bdat["features"] = features
|
|
146
|
+
# Mapped basin information
|
|
147
|
+
if mapping is not None:
|
|
148
|
+
events = self.h5.require_group("events")
|
|
149
|
+
# Reserve a mapping feature for this dataset
|
|
150
|
+
for ii in range(10): # basinmap0 to basinmap9
|
|
151
|
+
bm_cand = f"basinmap{ii}"
|
|
152
|
+
if bm_cand in events:
|
|
153
|
+
# There is a basin mapping defined in the file. Check
|
|
154
|
+
# whether it is identical to ours.
|
|
155
|
+
if np.all(events[bm_cand] == mapping):
|
|
156
|
+
# Great, we are done here.
|
|
157
|
+
feat_basinmap = bm_cand
|
|
158
|
+
break
|
|
159
|
+
else:
|
|
160
|
+
# This mapping belongs to a different basin,
|
|
161
|
+
# try the next mapping.
|
|
162
|
+
continue
|
|
163
|
+
else:
|
|
164
|
+
# The mapping is not defined in the dataset, and we may
|
|
165
|
+
# write it to a new feature.
|
|
166
|
+
feat_basinmap = bm_cand
|
|
167
|
+
self.store_feature_chunk(feat=feat_basinmap, data=mapping)
|
|
168
|
+
break
|
|
169
|
+
else:
|
|
170
|
+
raise ValueError(
|
|
171
|
+
"You have exhausted the usage of mapped basins for "
|
|
172
|
+
"the current dataset. Please revise your analysis "
|
|
173
|
+
"pipeline.")
|
|
174
|
+
bdat["mapping"] = feat_basinmap
|
|
109
175
|
bstring = json.dumps(bdat, indent=2)
|
|
110
176
|
# basin key is its hash
|
|
111
177
|
key = hashlib.md5(bstring.encode("utf-8",
|
|
@@ -234,6 +300,63 @@ def create_with_basins(
|
|
|
234
300
|
)
|
|
235
301
|
|
|
236
302
|
|
|
303
|
+
def copy_features(h5_src: h5py.File,
|
|
304
|
+
h5_dst: h5py.File,
|
|
305
|
+
features: List[str],
|
|
306
|
+
mapping: np.ndarray = None,
|
|
307
|
+
):
|
|
308
|
+
"""Copy feature data from one HDF5 file to another
|
|
309
|
+
|
|
310
|
+
The feature must not exist in the destination file.
|
|
311
|
+
|
|
312
|
+
Parameters
|
|
313
|
+
----------
|
|
314
|
+
h5_src: h5py.File
|
|
315
|
+
Input HDF5File containing `features` in the "events" group
|
|
316
|
+
h5_dst: h5py.File
|
|
317
|
+
Output HDF5File opened in write mode not containing `features`
|
|
318
|
+
features: List[str]
|
|
319
|
+
List of features to copy from source to destination
|
|
320
|
+
mapping: 1D array
|
|
321
|
+
If given, contains indices in the input file that should be
|
|
322
|
+
written to the output file. If set to None, all features are written.
|
|
323
|
+
"""
|
|
324
|
+
ei = h5_src["events"]
|
|
325
|
+
eo = h5_dst.require_group("events")
|
|
326
|
+
# This is the size of the output dataset
|
|
327
|
+
size = h5_dst.attrs["experiment:event count"]
|
|
328
|
+
hw = HDF5Writer(h5_dst)
|
|
329
|
+
for feat in features:
|
|
330
|
+
if feat in eo:
|
|
331
|
+
raise ValueError(f"Output file {h5_dst.filename} already contains "
|
|
332
|
+
f"the feature {feat}.")
|
|
333
|
+
if not isinstance(ei[feat], h5py.Dataset):
|
|
334
|
+
raise NotImplementedError(
|
|
335
|
+
f"Only dataset-based features are supported here, not {feat}")
|
|
336
|
+
if mapping is None:
|
|
337
|
+
# Just copy the data as-is.
|
|
338
|
+
h5py.h5o.copy(src_loc=ei.id,
|
|
339
|
+
src_name=feat.encode(),
|
|
340
|
+
dst_loc=eo.id,
|
|
341
|
+
dst_name=feat.encode(),
|
|
342
|
+
)
|
|
343
|
+
else:
|
|
344
|
+
# Perform mapping and store the features in chunks to keep
|
|
345
|
+
# memory usage down.
|
|
346
|
+
dsi = ei[feat]
|
|
347
|
+
chunk_size = hw.get_best_nd_chunks(dsi[0].shape, dsi.dtype)[0]
|
|
348
|
+
start = 0
|
|
349
|
+
while start < size:
|
|
350
|
+
chunk_idx = mapping[start:start + chunk_size]
|
|
351
|
+
# h5py only supports indexing in increasing order
|
|
352
|
+
chunk_unique, order = np.unique(chunk_idx, return_inverse=True)
|
|
353
|
+
data_unique = dsi[chunk_unique]
|
|
354
|
+
data = data_unique[order]
|
|
355
|
+
hw.store_feature_chunk(feat, data)
|
|
356
|
+
# increment start
|
|
357
|
+
start += chunk_size
|
|
358
|
+
|
|
359
|
+
|
|
237
360
|
def copy_metadata(h5_src: h5py.File,
|
|
238
361
|
h5_dst: h5py.File,
|
|
239
362
|
copy_basins=True):
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: dcnum
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.23.2
|
|
4
4
|
Summary: numerics toolbox for imaging deformability cytometry
|
|
5
|
-
Author: Maximilian Schlögel, Paul Müller
|
|
5
|
+
Author: Maximilian Schlögel, Paul Müller, Raghava Alajangi
|
|
6
6
|
Maintainer-email: Paul Müller <dev@craban.de>
|
|
7
7
|
License: MIT
|
|
8
8
|
Project-URL: source, https://github.com/DC-Analysis/dcnum
|
|
@@ -25,6 +25,8 @@ Requires-Dist: numpy >=1.21
|
|
|
25
25
|
Requires-Dist: opencv-python-headless
|
|
26
26
|
Requires-Dist: scikit-image
|
|
27
27
|
Requires-Dist: scipy >=1.8.0
|
|
28
|
+
Provides-Extra: torch
|
|
29
|
+
Requires-Dist: torch >=2.2 ; extra == 'torch'
|
|
28
30
|
|
|
29
31
|
|dcnum|
|
|
30
32
|
=======
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
dcnum/__init__.py,sha256=hcawIKS7utYiOyVhOAX9t7K3xYzP1b9862VV0b6qSrQ,74
|
|
2
|
+
dcnum/_version.py,sha256=GmxD5FOokmDsV6mmMcLj8aWXLveU0OeVRPLBT4HJfDk,413
|
|
3
|
+
dcnum/feat/__init__.py,sha256=jUJYWTD3VIoDNKrmryXbjHb1rGwYtK4b7VPWihYgUoo,325
|
|
4
|
+
dcnum/feat/event_extractor_manager_thread.py,sha256=5HdCQCywyQ5QC56AMjSqCroqif9oOFyiSFWCe07JojM,7820
|
|
5
|
+
dcnum/feat/gate.py,sha256=Yhxq80JoRMmQzBxl35C8NT91c9QcmQa-EIKLuxK6WvE,7221
|
|
6
|
+
dcnum/feat/queue_event_extractor.py,sha256=0ncTQleT1sfc98zYkFuZWxU-akecfTrW6-OOU3z-d8o,15698
|
|
7
|
+
dcnum/feat/feat_background/__init__.py,sha256=OTmMuazHNaSrZb2XW4cnJ6PlgJLbKrPbaidpEixYa0A,341
|
|
8
|
+
dcnum/feat/feat_background/base.py,sha256=A-K3qlJ0ABFBGm5eMKYcNCC7ktFAInSm0eR3N3DHQZY,7963
|
|
9
|
+
dcnum/feat/feat_background/bg_copy.py,sha256=PK8x4_Uph-_A6uszZC5uhe1gD1dSRdHnDMEsN0HSGHA,1034
|
|
10
|
+
dcnum/feat/feat_background/bg_roll_median.py,sha256=EyjstMDXFBYuJB1lN6g4Uw7tPm434X3hXQxKSqvcoJ4,13175
|
|
11
|
+
dcnum/feat/feat_background/bg_sparse_median.py,sha256=ab7Boj7cmr6PBdTbyWTj_yNNJSfuowr7u-iSGW989WI,20709
|
|
12
|
+
dcnum/feat/feat_brightness/__init__.py,sha256=o6AebVlmydwNgVF5kW6ITqJyFreoKrU3Ki_3EC8If-s,155
|
|
13
|
+
dcnum/feat/feat_brightness/bright_all.py,sha256=vf8xaYBdKD24hHUXdkI0_S7nbr7m49KW6gvuWvbHDVg,4545
|
|
14
|
+
dcnum/feat/feat_brightness/common.py,sha256=JX49EszYDmnvoOKXFVV1CalEIWRmOuY5EryNbqGbdac,156
|
|
15
|
+
dcnum/feat/feat_contour/__init__.py,sha256=Td4Hs47kUgJj0VXm3q5ofXhaUWr9QTfVgbwh5EELA-I,163
|
|
16
|
+
dcnum/feat/feat_contour/contour.py,sha256=_qyHCGvylVxruMWafvVbVOzhWGXLoFi10LReNxGcWhY,463
|
|
17
|
+
dcnum/feat/feat_contour/moments.py,sha256=W8sD2X7JqIBq-9nL82hf4Hm2uJkfca8EvAl_hqI_IDg,5109
|
|
18
|
+
dcnum/feat/feat_contour/volume.py,sha256=xVHWtv6USUHJZ5dM1Ur7fI7OwoPT5N2Ps0gKVWylfl8,6639
|
|
19
|
+
dcnum/feat/feat_texture/__init__.py,sha256=6StM9S540UVtdFFR3bHa7nfCTomeVdoo7Uy9CjuTgH0,137
|
|
20
|
+
dcnum/feat/feat_texture/common.py,sha256=COXHpXS-7DMouGu3WF83I76L02Sr7P9re4lxajh6g0E,439
|
|
21
|
+
dcnum/feat/feat_texture/tex_all.py,sha256=_5H3sXYRN0Uq2eUHn3XUyEHkU_tncEqbqJTC-HZcnGY,5198
|
|
22
|
+
dcnum/logic/__init__.py,sha256=7J3GrwJInNQbrLk61HRIV7X7p69TAIbMYpR34hh6u14,177
|
|
23
|
+
dcnum/logic/ctrl.py,sha256=9QFNudpaZfL3hKYskOgMiscOOQPU2xbupVzI23aNWiE,36193
|
|
24
|
+
dcnum/logic/job.py,sha256=9BN2WjYqjjJuLnfNZAtQ2Nn47Glo2jVrivDodGJoqlQ,7713
|
|
25
|
+
dcnum/logic/json_encoder.py,sha256=cxMnqisbKEVf-rVcw6rK2BBAb6iz_hKFaGl81kK36lQ,571
|
|
26
|
+
dcnum/meta/__init__.py,sha256=AVqRgyKXO1orKnE305h88IBvoZ1oz6X11HN1WP5nGvg,60
|
|
27
|
+
dcnum/meta/paths.py,sha256=J_ikeHzd7gEeRgAKjuayz3x6q4h1fOiDadM-ZxhAGm4,1053
|
|
28
|
+
dcnum/meta/ppid.py,sha256=OD79NrZ8waC3julwdH8NjneUuXqSRSHsUDpKzT5pdyU,8432
|
|
29
|
+
dcnum/read/__init__.py,sha256=ksLdV8EkOU3EPje8teCOSehcUeGAZfg9TQ5ltuEUgls,216
|
|
30
|
+
dcnum/read/cache.py,sha256=lisrGG7AyvVitf0h92wh5FvYCsxa0pWyGcAyYwGP-LQ,6471
|
|
31
|
+
dcnum/read/const.py,sha256=GG9iyXDtEldvJYOBnhZjlimzIeBMAt4bSr2-xn2gzzc,464
|
|
32
|
+
dcnum/read/hdf5_data.py,sha256=Yyq02UTILc5ZgIQXpR9Y0wuX2WT8s0g23PraI7KxmJY,23489
|
|
33
|
+
dcnum/read/mapped.py,sha256=UryArlrIsHxjOyimBL2Nooi3r73zuGtnGdqdxa6PK_g,3076
|
|
34
|
+
dcnum/segm/__init__.py,sha256=9cLEAd3JWE8IGqDHV-eSDIYOGBfOepd8OcebtNs8Omk,309
|
|
35
|
+
dcnum/segm/segm_thresh.py,sha256=iVhvIhzO0Gw0t3rXOgH71rOI0CNjJJQq4Gg6BulUhK8,948
|
|
36
|
+
dcnum/segm/segmenter.py,sha256=FWLFDBR-x_85ku2rObA2F-QBrM4IUaUL-YHChLagVvM,14902
|
|
37
|
+
dcnum/segm/segmenter_manager_thread.py,sha256=frM0sMxC7f7TQiFjmpRxuwG2kUBFpW1inV8dtpADHiI,5924
|
|
38
|
+
dcnum/segm/segmenter_mpo.py,sha256=o6mQlITHgEWvQt9v6oCWwAcZUvxE7MOeLE9DFManzpY,13757
|
|
39
|
+
dcnum/segm/segmenter_sto.py,sha256=e6MtN_RWusA0wTExV-FLGpDXNJs1CbSyXcSdWUPBMvM,3959
|
|
40
|
+
dcnum/segm/segm_torch/__init__.py,sha256=DtUqJTbj7ybrTbXlwHq1Y4SCzi22rMW9Cus6wX-iU-A,822
|
|
41
|
+
dcnum/segm/segm_torch/segm_torch_base.py,sha256=G9AhVyD6LkAmk0tkbYnJUSpvcj3_HYf0uqfILZQsyus,4479
|
|
42
|
+
dcnum/segm/segm_torch/segm_torch_mpo.py,sha256=N01dVXai_4eIGfHJrPjg5C2Bkyq1TOeXeJhw3YbGidw,2504
|
|
43
|
+
dcnum/segm/segm_torch/segm_torch_sto.py,sha256=PTOJrP_FkaxZZul8lM4VA2HL3KyxrheDDWWdJbmJdiw,3393
|
|
44
|
+
dcnum/segm/segm_torch/torch_model.py,sha256=5aL6SwSvg1N2gATEGBhP3aA4WTHlvGzQVYuizmh0LrU,3187
|
|
45
|
+
dcnum/segm/segm_torch/torch_postproc.py,sha256=ctirQTmsZnuZGIxkwFWN9arRneHRYJUxaJ_ZyCgjByM,3311
|
|
46
|
+
dcnum/segm/segm_torch/torch_preproc.py,sha256=kjabu76paw23kO7RP7Ik6IY60Kk1VBAHKBAedflA0aQ,4002
|
|
47
|
+
dcnum/write/__init__.py,sha256=QvWHeZmjHI18i-YlGYuzN3i7dVWY9UCReKchrJ-gif0,260
|
|
48
|
+
dcnum/write/deque_writer_thread.py,sha256=ao7F1yrVKyufgC4rC0Y2_Vt7snuT6KpI7W2qVxcjdhk,1994
|
|
49
|
+
dcnum/write/queue_collector_thread.py,sha256=d_WfdsZdFnFsiAY0zVMwUlA4juIMeiWYmE_-rezBQCE,11734
|
|
50
|
+
dcnum/write/writer.py,sha256=e6J8YVqhS7kzkpPIMoDMokJpqSy1WWNdOrwaJof1oVc,15601
|
|
51
|
+
dcnum-0.23.2.dist-info/LICENSE,sha256=YRChA1C8A2E-amJbudwMcbTCZy_HzmeY0hMIvduh1MM,1089
|
|
52
|
+
dcnum-0.23.2.dist-info/METADATA,sha256=HLyOwJN79qpOR5yXjWtt5XjkT3nRQujPlxuvQZSYLbI,2280
|
|
53
|
+
dcnum-0.23.2.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
54
|
+
dcnum-0.23.2.dist-info/top_level.txt,sha256=Hmh38rgG_MFTVDpUDGuO2HWTSq80P585Het4COQzFTg,6
|
|
55
|
+
dcnum-0.23.2.dist-info/RECORD,,
|
dcnum/segm/segmenter_gpu.py
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import abc
|
|
2
|
-
from typing import Dict
|
|
3
|
-
|
|
4
|
-
import numpy as np
|
|
5
|
-
import scipy.ndimage as ndi
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
from .segmenter import Segmenter
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
class GPUSegmenter(Segmenter, abc.ABC):
|
|
12
|
-
hardware_processor = "gpu"
|
|
13
|
-
mask_postprocessing = False
|
|
14
|
-
|
|
15
|
-
def __init__(self,
|
|
16
|
-
*,
|
|
17
|
-
num_workers: int = None,
|
|
18
|
-
kwargs_mask: Dict = None,
|
|
19
|
-
debug: bool = False,
|
|
20
|
-
**kwargs
|
|
21
|
-
):
|
|
22
|
-
"""GPU base segmenter
|
|
23
|
-
|
|
24
|
-
Parameters
|
|
25
|
-
----------
|
|
26
|
-
kwargs_mask: dict
|
|
27
|
-
Keyword arguments for mask post-processing (see `process_mask`)
|
|
28
|
-
debug: bool
|
|
29
|
-
Debugging parameters
|
|
30
|
-
kwargs:
|
|
31
|
-
Additional, optional keyword arguments for `segment_approach`
|
|
32
|
-
defined in the subclass.
|
|
33
|
-
"""
|
|
34
|
-
if num_workers not in [None, 1]:
|
|
35
|
-
raise ValueError(f"Number of workers must not be larger than 1 "
|
|
36
|
-
f"for GPU segmenter, got '{num_workers}'!")
|
|
37
|
-
super(GPUSegmenter, self).__init__(kwargs_mask=kwargs_mask,
|
|
38
|
-
debug=debug,
|
|
39
|
-
**kwargs)
|
|
40
|
-
|
|
41
|
-
def segment_batch(self,
|
|
42
|
-
image_data: np.ndarray,
|
|
43
|
-
start: int = None,
|
|
44
|
-
stop: int = None):
|
|
45
|
-
if stop is None or start is None:
|
|
46
|
-
start = 0
|
|
47
|
-
stop = len(image_data)
|
|
48
|
-
|
|
49
|
-
image_slice = image_data[start:stop]
|
|
50
|
-
segm = self.segment_frame_wrapper()
|
|
51
|
-
|
|
52
|
-
labels = segm(image_slice)
|
|
53
|
-
|
|
54
|
-
# Make sure we have integer labels
|
|
55
|
-
if labels.dtype == bool:
|
|
56
|
-
new_labels = np.zeros_like(labels, dtype=np.uint16)
|
|
57
|
-
for ii in range(len(labels)):
|
|
58
|
-
ndi.label(
|
|
59
|
-
input=labels[ii],
|
|
60
|
-
output=new_labels[ii],
|
|
61
|
-
structure=ndi.generate_binary_structure(2, 2))
|
|
62
|
-
labels = new_labels
|
|
63
|
-
|
|
64
|
-
return labels
|
dcnum-0.17.0.dist-info/RECORD
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
dcnum/__init__.py,sha256=hcawIKS7utYiOyVhOAX9t7K3xYzP1b9862VV0b6qSrQ,74
|
|
2
|
-
dcnum/_version.py,sha256=kBQrirg2HABnJUda1U0a6ZmIqeCqRLaPZOws884sTW8,413
|
|
3
|
-
dcnum/feat/__init__.py,sha256=JqlgzOgDJhoTk8WVYcIiKTWq9EAM16_jGivzOtN6JGo,325
|
|
4
|
-
dcnum/feat/event_extractor_manager_thread.py,sha256=Ocid_t1awH6pOmurCmKYkC51XsXB0-DoN3fzjFDgE4c,7129
|
|
5
|
-
dcnum/feat/gate.py,sha256=svbObmqpYdqPawpfrsEjTiUPJXf24GrNi8PXTKT-z44,7225
|
|
6
|
-
dcnum/feat/queue_event_extractor.py,sha256=3CIjZOwOD8JZZTgbE9_jC81B8lbNtVElSV371Q9zoSc,15005
|
|
7
|
-
dcnum/feat/feat_background/__init__.py,sha256=OTmMuazHNaSrZb2XW4cnJ6PlgJLbKrPbaidpEixYa0A,341
|
|
8
|
-
dcnum/feat/feat_background/base.py,sha256=DKcNSQOSi0cuo4zFbqtgDJnRiYDwoKkw2GQxpnK14fA,8119
|
|
9
|
-
dcnum/feat/feat_background/bg_copy.py,sha256=EbeIy28gyPJr01Xens881IC1BtaTS5q-BkXPd3b6cLk,726
|
|
10
|
-
dcnum/feat/feat_background/bg_roll_median.py,sha256=HgiGoyfLkygIlCoo8cBbf3gQt5uvM2S6_ez_V1hhCb4,12834
|
|
11
|
-
dcnum/feat/feat_background/bg_sparse_median.py,sha256=LbWbDxAruGagidHt9wybyqkXp9OKi3eWXceujirpsqY,17608
|
|
12
|
-
dcnum/feat/feat_brightness/__init__.py,sha256=o6AebVlmydwNgVF5kW6ITqJyFreoKrU3Ki_3EC8If-s,155
|
|
13
|
-
dcnum/feat/feat_brightness/bright_all.py,sha256=Z5b-xkw7g7ejMpbGmdUqrxGRymqFhAQsZ938gaGXk9Y,3102
|
|
14
|
-
dcnum/feat/feat_brightness/common.py,sha256=JX49EszYDmnvoOKXFVV1CalEIWRmOuY5EryNbqGbdac,156
|
|
15
|
-
dcnum/feat/feat_moments/__init__.py,sha256=9eKmhBZGAZTLRnfCNHDiYM0a7qErrJCFLEgy3OlF9no,125
|
|
16
|
-
dcnum/feat/feat_moments/ct_opencv.py,sha256=_qyHCGvylVxruMWafvVbVOzhWGXLoFi10LReNxGcWhY,463
|
|
17
|
-
dcnum/feat/feat_moments/mt_legacy.py,sha256=tp85oeQ1GwVNdo6nXWhtbUGjMaXR8C6NMMWhobzThq0,4490
|
|
18
|
-
dcnum/feat/feat_texture/__init__.py,sha256=6StM9S540UVtdFFR3bHa7nfCTomeVdoo7Uy9CjuTgH0,137
|
|
19
|
-
dcnum/feat/feat_texture/common.py,sha256=COXHpXS-7DMouGu3WF83I76L02Sr7P9re4lxajh6g0E,439
|
|
20
|
-
dcnum/feat/feat_texture/tex_all.py,sha256=eGjjNfPpfZw7FA_VNFCIMiU38KD0qcGbxLciYy-tCiA,4097
|
|
21
|
-
dcnum/logic/__init__.py,sha256=7J3GrwJInNQbrLk61HRIV7X7p69TAIbMYpR34hh6u14,177
|
|
22
|
-
dcnum/logic/ctrl.py,sha256=7m1HL_kO62d8Kt_o4gX3bhxbI4pwOhv3HWHRmbCaMp0,27022
|
|
23
|
-
dcnum/logic/job.py,sha256=M0Q-Rfcm-zkTXTQc79W6YSNUjUlgmRPG0Ikbdn1aOpY,4608
|
|
24
|
-
dcnum/logic/json_encoder.py,sha256=dy44ArmdnxpUfxxONmKdIv-fde3aTXPjZDN0HPATaxs,467
|
|
25
|
-
dcnum/meta/__init__.py,sha256=AVqRgyKXO1orKnE305h88IBvoZ1oz6X11HN1WP5nGvg,60
|
|
26
|
-
dcnum/meta/paths.py,sha256=J_ikeHzd7gEeRgAKjuayz3x6q4h1fOiDadM-ZxhAGm4,1053
|
|
27
|
-
dcnum/meta/ppid.py,sha256=f3xT6k9EMhrmk2T_e-2LHE9qdXeGMZJcNOIIpr-_eb4,7706
|
|
28
|
-
dcnum/read/__init__.py,sha256=iV2wrBMdwJgpXaphNiiAVybndDzTTv0CAGRNXyvxcLY,157
|
|
29
|
-
dcnum/read/cache.py,sha256=HXbRFyTNT08_imv2460hMKVrfRrU6WnbJoO71HR1j8E,5800
|
|
30
|
-
dcnum/read/const.py,sha256=SVlvEJiRIHyTyUlWG24_ogcnT5nTxCi0CRslNuNP56I,282
|
|
31
|
-
dcnum/read/hdf5_data.py,sha256=dO2VZKBA7bOOku37sdv5SJgZ8vbAGHd1k5cmcylEonQ,18169
|
|
32
|
-
dcnum/segm/__init__.py,sha256=iiq_1A9DU5wMUcKnsZ53E7NyzCkbZCJeUDimzunE-OM,247
|
|
33
|
-
dcnum/segm/segm_thresh.py,sha256=Z6buG3ia8uFJKTLE6BICM3n7Yw8IN-9f6_umIlx0xUk,1395
|
|
34
|
-
dcnum/segm/segmenter.py,sha256=Y535ro4BTyE5Uj5lYIZ0xMbpKg2TIs5wCpv1Gg-yvTU,10625
|
|
35
|
-
dcnum/segm/segmenter_cpu.py,sha256=tCY105rVr9_0RIq2618qnF1ueHRj7UtuK_nUBoAg-nY,10743
|
|
36
|
-
dcnum/segm/segmenter_gpu.py,sha256=Au1MQdAalVsmJ-cmb3OcCmEMBfXSDuJjdXJTGqEIcG8,1962
|
|
37
|
-
dcnum/segm/segmenter_manager_thread.py,sha256=2znDaKedSueomcU1pbHtFmVcGoHzp--sf494VgJF_Tk,5342
|
|
38
|
-
dcnum/write/__init__.py,sha256=Cpn3LqL18hh8OScUnGp_AnNfpWPpKW-oAJZH6ot7aRA,241
|
|
39
|
-
dcnum/write/deque_writer_thread.py,sha256=KpJ6po8JPlM696MITN-bhNnWQcy9E-qlhg9g-uzoPZg,1710
|
|
40
|
-
dcnum/write/queue_collector_thread.py,sha256=YQ6pvKNmCDf1C6HVx6gOA-q-FBoI6nkhOo-tAVYnyag,11906
|
|
41
|
-
dcnum/write/writer.py,sha256=QGYNda102f2_12YWXu5WEBEQaTXhNnuQ20g-Dej-cek,10535
|
|
42
|
-
dcnum-0.17.0.dist-info/LICENSE,sha256=YRChA1C8A2E-amJbudwMcbTCZy_HzmeY0hMIvduh1MM,1089
|
|
43
|
-
dcnum-0.17.0.dist-info/METADATA,sha256=Fr1HpUDle8_FLpOYttDhIJR8VE-S_E-_nvLjuKiPpIU,2194
|
|
44
|
-
dcnum-0.17.0.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
45
|
-
dcnum-0.17.0.dist-info/top_level.txt,sha256=Hmh38rgG_MFTVDpUDGuO2HWTSq80P585Het4COQzFTg,6
|
|
46
|
-
dcnum-0.17.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|