dcnum 0.24.0__py3-none-any.whl → 0.25.0__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/feat_background/bg_sparse_median.py +2 -2
- dcnum/meta/ppid.py +3 -2
- dcnum/read/__init__.py +1 -0
- dcnum/read/cache.py +4 -3
- dcnum/read/detect_flicker.py +44 -0
- {dcnum-0.24.0.dist-info → dcnum-0.25.0.dist-info}/METADATA +1 -1
- {dcnum-0.24.0.dist-info → dcnum-0.25.0.dist-info}/RECORD +11 -10
- {dcnum-0.24.0.dist-info → dcnum-0.25.0.dist-info}/WHEEL +1 -1
- {dcnum-0.24.0.dist-info → dcnum-0.25.0.dist-info}/LICENSE +0 -0
- {dcnum-0.24.0.dist-info → dcnum-0.25.0.dist-info}/top_level.txt +0 -0
dcnum/_version.py
CHANGED
|
@@ -59,7 +59,7 @@ class BackgroundSparseMed(Background):
|
|
|
59
59
|
offset_correction: bool
|
|
60
60
|
The sparse median background correction produces one median
|
|
61
61
|
image for multiple input frames (BTW this also leads to very
|
|
62
|
-
efficient data storage with HDF5
|
|
62
|
+
efficient data storage with internal HDF5 basins). In
|
|
63
63
|
case the input frames are subject to frame-by-frame brightness
|
|
64
64
|
variations (e.g. flickering of the illumination source), it
|
|
65
65
|
is useful to have an offset value per frame that can then be
|
|
@@ -226,7 +226,7 @@ class BackgroundSparseMed(Background):
|
|
|
226
226
|
offset_correction: bool
|
|
227
227
|
The sparse median background correction produces one median
|
|
228
228
|
image for multiple input frames (BTW this also leads to very
|
|
229
|
-
efficient data storage with HDF5
|
|
229
|
+
efficient data storage with internal HDF5 basins). In
|
|
230
230
|
case the input frames are subject to frame-by-frame brightness
|
|
231
231
|
variations (e.g. flickering of the illumination source), it
|
|
232
232
|
is useful to have an offset value per frame that can then be
|
dcnum/meta/ppid.py
CHANGED
|
@@ -7,6 +7,7 @@ import pathlib
|
|
|
7
7
|
from typing import Dict, List, Protocol
|
|
8
8
|
import warnings
|
|
9
9
|
|
|
10
|
+
import numpy as np
|
|
10
11
|
|
|
11
12
|
#: Increment this string if there are breaking changes that make
|
|
12
13
|
#: previous pipelines unreproducible.
|
|
@@ -140,9 +141,9 @@ def kwargs_to_ppid(cls: ClassWithPPIDCapabilities,
|
|
|
140
141
|
path = pathlib.Path(val)
|
|
141
142
|
if path.exists():
|
|
142
143
|
val = path.name
|
|
143
|
-
if isinstance(val, bool):
|
|
144
|
+
if isinstance(val, (bool, np.bool_)):
|
|
144
145
|
val = int(val) # do not print e.g. "True"
|
|
145
|
-
elif isinstance(val, float):
|
|
146
|
+
elif isinstance(val, (float, np.floating)):
|
|
146
147
|
if val == int(val):
|
|
147
148
|
val = int(val) # omit the ".0" at the end
|
|
148
149
|
concat_strings.append(f"{abr}={val}")
|
dcnum/read/__init__.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# flake8: noqa: F401
|
|
2
2
|
from .cache import md5sum
|
|
3
3
|
from .const import PROTECTED_FEATURES
|
|
4
|
+
from .detect_flicker import detect_flickering
|
|
4
5
|
from .hdf5_data import HDF5Data, HDF5ImageCache, concatenated_hdf5_data
|
|
5
6
|
from .mapped import get_mapping_indices, get_mapped_object
|
dcnum/read/cache.py
CHANGED
|
@@ -36,9 +36,10 @@ class BaseImageChunkCache(abc.ABC):
|
|
|
36
36
|
def __getitem__(self, index):
|
|
37
37
|
if isinstance(index, (slice, list, np.ndarray)):
|
|
38
38
|
if isinstance(index, slice):
|
|
39
|
-
indices = np.arange(
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
indices = np.arange(
|
|
40
|
+
index.start or 0,
|
|
41
|
+
min(index.stop, len(self)) if index.stop else len(self),
|
|
42
|
+
index.step)
|
|
42
43
|
else:
|
|
43
44
|
indices = index
|
|
44
45
|
array_out = np.empty((len(indices),) + self.image_shape,
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
|
|
3
|
+
from .hdf5_data import HDF5Data
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def detect_flickering(image_data: np.ndarray | HDF5Data,
|
|
7
|
+
roi_height: int = 10,
|
|
8
|
+
brightness_threshold: float = 2.5,
|
|
9
|
+
count_threshold: int = 5,
|
|
10
|
+
max_frames: int = 1000):
|
|
11
|
+
"""Determine whether an image series experiences flickering
|
|
12
|
+
|
|
13
|
+
Flickering is an unwelcome phenomenon due to a faulty data
|
|
14
|
+
acquisition device. For instance, if there is random voltage noise in
|
|
15
|
+
the electronics managing the LED power, then the brightness of the
|
|
16
|
+
LED will vary randomly when the noise signal overlaps with the flash
|
|
17
|
+
triggering signal.
|
|
18
|
+
|
|
19
|
+
If flickering is detected, you should use the "sparsemed" background
|
|
20
|
+
computation with `offset_correction` set to True.
|
|
21
|
+
|
|
22
|
+
Parameters
|
|
23
|
+
----------
|
|
24
|
+
image_data:
|
|
25
|
+
sliceable object (e.g. numpy array or HDF5Data) containing
|
|
26
|
+
image data.
|
|
27
|
+
roi_height: int
|
|
28
|
+
height of the ROI in pixels for which to search for flickering;
|
|
29
|
+
the entire width of the image is used
|
|
30
|
+
brightness_threshold: float
|
|
31
|
+
brightness difference between individual ROIs median and median
|
|
32
|
+
of all ROI medians leading to a positive flickering event
|
|
33
|
+
count_threshold: int
|
|
34
|
+
minimum number of flickering events that would lead to a positive
|
|
35
|
+
flickering decision
|
|
36
|
+
max_frames: int
|
|
37
|
+
maximum number of frames to include in the flickering analysis
|
|
38
|
+
"""
|
|
39
|
+
# slice event axis first in case we have and HDF5Data instance
|
|
40
|
+
roi_data = image_data[:max_frames][:, :roi_height, :]
|
|
41
|
+
roi_median = np.median(roi_data, axis=(1, 2))
|
|
42
|
+
roi_offset = roi_median - np.median(roi_median)
|
|
43
|
+
flickering_events = np.sum(np.abs(roi_offset) >= abs(brightness_threshold))
|
|
44
|
+
return flickering_events >= count_threshold
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
dcnum/__init__.py,sha256=hcawIKS7utYiOyVhOAX9t7K3xYzP1b9862VV0b6qSrQ,74
|
|
2
|
-
dcnum/_version.py,sha256=
|
|
2
|
+
dcnum/_version.py,sha256=nhq2LDshqyJE9A3DLIz_6mBkgGLKSQrYmHfzZ_jVCbc,413
|
|
3
3
|
dcnum/feat/__init__.py,sha256=jUJYWTD3VIoDNKrmryXbjHb1rGwYtK4b7VPWihYgUoo,325
|
|
4
4
|
dcnum/feat/event_extractor_manager_thread.py,sha256=FAxSyRfaNAuBWNplxHngp5h-44s0qIP24XX_oETdfMk,7836
|
|
5
5
|
dcnum/feat/gate.py,sha256=Yhxq80JoRMmQzBxl35C8NT91c9QcmQa-EIKLuxK6WvE,7221
|
|
@@ -8,7 +8,7 @@ dcnum/feat/feat_background/__init__.py,sha256=OTmMuazHNaSrZb2XW4cnJ6PlgJLbKrPbai
|
|
|
8
8
|
dcnum/feat/feat_background/base.py,sha256=bQBPvztrku-8YSVk8YBUUNh7MaYcnztgyD2-dQHxpzw,8674
|
|
9
9
|
dcnum/feat/feat_background/bg_copy.py,sha256=PK8x4_Uph-_A6uszZC5uhe1gD1dSRdHnDMEsN0HSGHA,1034
|
|
10
10
|
dcnum/feat/feat_background/bg_roll_median.py,sha256=EyjstMDXFBYuJB1lN6g4Uw7tPm434X3hXQxKSqvcoJ4,13175
|
|
11
|
-
dcnum/feat/feat_background/bg_sparse_median.py,sha256=
|
|
11
|
+
dcnum/feat/feat_background/bg_sparse_median.py,sha256=wt7lvPSiZkdaerRErgezd_YDVxHA2kAqO1LMX9PuHJk,22053
|
|
12
12
|
dcnum/feat/feat_brightness/__init__.py,sha256=o6AebVlmydwNgVF5kW6ITqJyFreoKrU3Ki_3EC8If-s,155
|
|
13
13
|
dcnum/feat/feat_brightness/bright_all.py,sha256=vf8xaYBdKD24hHUXdkI0_S7nbr7m49KW6gvuWvbHDVg,4545
|
|
14
14
|
dcnum/feat/feat_brightness/common.py,sha256=JX49EszYDmnvoOKXFVV1CalEIWRmOuY5EryNbqGbdac,156
|
|
@@ -25,10 +25,11 @@ dcnum/logic/job.py,sha256=9BN2WjYqjjJuLnfNZAtQ2Nn47Glo2jVrivDodGJoqlQ,7713
|
|
|
25
25
|
dcnum/logic/json_encoder.py,sha256=cxMnqisbKEVf-rVcw6rK2BBAb6iz_hKFaGl81kK36lQ,571
|
|
26
26
|
dcnum/meta/__init__.py,sha256=AVqRgyKXO1orKnE305h88IBvoZ1oz6X11HN1WP5nGvg,60
|
|
27
27
|
dcnum/meta/paths.py,sha256=J_ikeHzd7gEeRgAKjuayz3x6q4h1fOiDadM-ZxhAGm4,1053
|
|
28
|
-
dcnum/meta/ppid.py,sha256=
|
|
29
|
-
dcnum/read/__init__.py,sha256=
|
|
30
|
-
dcnum/read/cache.py,sha256=
|
|
28
|
+
dcnum/meta/ppid.py,sha256=RnDkJSdV1kDznAsOhQN5WI7uC9UwSMCjyADP7yWNvkM,8478
|
|
29
|
+
dcnum/read/__init__.py,sha256=LYHyZHgiNTpjV5oEcty-7Kh5topLpHT_cFlNl-QX8gg,262
|
|
30
|
+
dcnum/read/cache.py,sha256=LNA5nnDyrw8Nj07E7XfG2GcHEoWm6vA6Qo_8N-n-sGw,6492
|
|
31
31
|
dcnum/read/const.py,sha256=GG9iyXDtEldvJYOBnhZjlimzIeBMAt4bSr2-xn2gzzc,464
|
|
32
|
+
dcnum/read/detect_flicker.py,sha256=CeUyxI6LaX_lCNvBPm_yzsiWmiNcZYqbNZCtvKPdkcU,1827
|
|
32
33
|
dcnum/read/hdf5_data.py,sha256=JVk9YWw1rPgTPxaMZsw2ehk4FJq9UqhmB1SW7yhPw50,25867
|
|
33
34
|
dcnum/read/mapped.py,sha256=zU2fYdZfLNHn0rKHxDzBhNFMu4--WWa8nSeE2likyZA,3637
|
|
34
35
|
dcnum/segm/__init__.py,sha256=9cLEAd3JWE8IGqDHV-eSDIYOGBfOepd8OcebtNs8Omk,309
|
|
@@ -48,8 +49,8 @@ dcnum/write/__init__.py,sha256=sK79IlvCFIqf2oFABVeyYedMnHOsEIQpxAauEeNO-Tw,273
|
|
|
48
49
|
dcnum/write/deque_writer_thread.py,sha256=ao7F1yrVKyufgC4rC0Y2_Vt7snuT6KpI7W2qVxcjdhk,1994
|
|
49
50
|
dcnum/write/queue_collector_thread.py,sha256=d_WfdsZdFnFsiAY0zVMwUlA4juIMeiWYmE_-rezBQCE,11734
|
|
50
51
|
dcnum/write/writer.py,sha256=sFt4O9O4uUabxmBZu776b5pBf_DPDpsz-jLpSsswQ1g,20531
|
|
51
|
-
dcnum-0.
|
|
52
|
-
dcnum-0.
|
|
53
|
-
dcnum-0.
|
|
54
|
-
dcnum-0.
|
|
55
|
-
dcnum-0.
|
|
52
|
+
dcnum-0.25.0.dist-info/LICENSE,sha256=YRChA1C8A2E-amJbudwMcbTCZy_HzmeY0hMIvduh1MM,1089
|
|
53
|
+
dcnum-0.25.0.dist-info/METADATA,sha256=CNZS4i26iGkFnwde0p0I8xzD80cRqKrDRQssMXnqkSo,2280
|
|
54
|
+
dcnum-0.25.0.dist-info/WHEEL,sha256=Wyh-_nZ0DJYolHNn1_hMa4lM7uDedD_RGVwbmTjyItk,91
|
|
55
|
+
dcnum-0.25.0.dist-info/top_level.txt,sha256=Hmh38rgG_MFTVDpUDGuO2HWTSq80P585Het4COQzFTg,6
|
|
56
|
+
dcnum-0.25.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|