dcnum 0.24.0__tar.gz → 0.25.0__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.

Potentially problematic release.


This version of dcnum might be problematic. Click here for more details.

Files changed (120) hide show
  1. {dcnum-0.24.0 → dcnum-0.25.0}/CHANGELOG +4 -0
  2. {dcnum-0.24.0 → dcnum-0.25.0}/PKG-INFO +1 -1
  3. {dcnum-0.24.0 → dcnum-0.25.0}/src/dcnum/_version.py +2 -2
  4. {dcnum-0.24.0 → dcnum-0.25.0}/src/dcnum/feat/feat_background/bg_sparse_median.py +2 -2
  5. {dcnum-0.24.0 → dcnum-0.25.0}/src/dcnum/meta/ppid.py +3 -2
  6. {dcnum-0.24.0 → dcnum-0.25.0}/src/dcnum/read/__init__.py +1 -0
  7. {dcnum-0.24.0 → dcnum-0.25.0}/src/dcnum/read/cache.py +4 -3
  8. dcnum-0.25.0/src/dcnum/read/detect_flicker.py +44 -0
  9. {dcnum-0.24.0 → dcnum-0.25.0}/src/dcnum.egg-info/PKG-INFO +1 -1
  10. {dcnum-0.24.0 → dcnum-0.25.0}/src/dcnum.egg-info/SOURCES.txt +2 -0
  11. {dcnum-0.24.0 → dcnum-0.25.0}/tests/test_meta_ppid_base.py +8 -0
  12. dcnum-0.25.0/tests/test_read_detect_flicker.py +87 -0
  13. {dcnum-0.24.0 → dcnum-0.25.0}/tests/test_read_hdf5.py +13 -0
  14. {dcnum-0.24.0 → dcnum-0.25.0}/.github/workflows/check.yml +0 -0
  15. {dcnum-0.24.0 → dcnum-0.25.0}/.github/workflows/deploy_pypi.yml +0 -0
  16. {dcnum-0.24.0 → dcnum-0.25.0}/.gitignore +0 -0
  17. {dcnum-0.24.0 → dcnum-0.25.0}/.readthedocs.yml +0 -0
  18. {dcnum-0.24.0 → dcnum-0.25.0}/LICENSE +0 -0
  19. {dcnum-0.24.0 → dcnum-0.25.0}/README.rst +0 -0
  20. {dcnum-0.24.0 → dcnum-0.25.0}/docs/conf.py +0 -0
  21. {dcnum-0.24.0 → dcnum-0.25.0}/docs/extensions/github_changelog.py +0 -0
  22. {dcnum-0.24.0 → dcnum-0.25.0}/docs/index.rst +0 -0
  23. {dcnum-0.24.0 → dcnum-0.25.0}/docs/requirements.txt +0 -0
  24. {dcnum-0.24.0 → dcnum-0.25.0}/pyproject.toml +0 -0
  25. {dcnum-0.24.0 → dcnum-0.25.0}/setup.cfg +0 -0
  26. {dcnum-0.24.0 → dcnum-0.25.0}/src/dcnum/__init__.py +0 -0
  27. {dcnum-0.24.0 → dcnum-0.25.0}/src/dcnum/feat/__init__.py +0 -0
  28. {dcnum-0.24.0 → dcnum-0.25.0}/src/dcnum/feat/event_extractor_manager_thread.py +0 -0
  29. {dcnum-0.24.0 → dcnum-0.25.0}/src/dcnum/feat/feat_background/__init__.py +0 -0
  30. {dcnum-0.24.0 → dcnum-0.25.0}/src/dcnum/feat/feat_background/base.py +0 -0
  31. {dcnum-0.24.0 → dcnum-0.25.0}/src/dcnum/feat/feat_background/bg_copy.py +0 -0
  32. {dcnum-0.24.0 → dcnum-0.25.0}/src/dcnum/feat/feat_background/bg_roll_median.py +0 -0
  33. {dcnum-0.24.0 → dcnum-0.25.0}/src/dcnum/feat/feat_brightness/__init__.py +0 -0
  34. {dcnum-0.24.0 → dcnum-0.25.0}/src/dcnum/feat/feat_brightness/bright_all.py +0 -0
  35. {dcnum-0.24.0 → dcnum-0.25.0}/src/dcnum/feat/feat_brightness/common.py +0 -0
  36. {dcnum-0.24.0 → dcnum-0.25.0}/src/dcnum/feat/feat_contour/__init__.py +0 -0
  37. {dcnum-0.24.0 → dcnum-0.25.0}/src/dcnum/feat/feat_contour/contour.py +0 -0
  38. {dcnum-0.24.0 → dcnum-0.25.0}/src/dcnum/feat/feat_contour/moments.py +0 -0
  39. {dcnum-0.24.0 → dcnum-0.25.0}/src/dcnum/feat/feat_contour/volume.py +0 -0
  40. {dcnum-0.24.0 → dcnum-0.25.0}/src/dcnum/feat/feat_texture/__init__.py +0 -0
  41. {dcnum-0.24.0 → dcnum-0.25.0}/src/dcnum/feat/feat_texture/common.py +0 -0
  42. {dcnum-0.24.0 → dcnum-0.25.0}/src/dcnum/feat/feat_texture/tex_all.py +0 -0
  43. {dcnum-0.24.0 → dcnum-0.25.0}/src/dcnum/feat/gate.py +0 -0
  44. {dcnum-0.24.0 → dcnum-0.25.0}/src/dcnum/feat/queue_event_extractor.py +0 -0
  45. {dcnum-0.24.0 → dcnum-0.25.0}/src/dcnum/logic/__init__.py +0 -0
  46. {dcnum-0.24.0 → dcnum-0.25.0}/src/dcnum/logic/ctrl.py +0 -0
  47. {dcnum-0.24.0 → dcnum-0.25.0}/src/dcnum/logic/job.py +0 -0
  48. {dcnum-0.24.0 → dcnum-0.25.0}/src/dcnum/logic/json_encoder.py +0 -0
  49. {dcnum-0.24.0 → dcnum-0.25.0}/src/dcnum/meta/__init__.py +0 -0
  50. {dcnum-0.24.0 → dcnum-0.25.0}/src/dcnum/meta/paths.py +0 -0
  51. {dcnum-0.24.0 → dcnum-0.25.0}/src/dcnum/read/const.py +0 -0
  52. {dcnum-0.24.0 → dcnum-0.25.0}/src/dcnum/read/hdf5_data.py +0 -0
  53. {dcnum-0.24.0 → dcnum-0.25.0}/src/dcnum/read/mapped.py +0 -0
  54. {dcnum-0.24.0 → dcnum-0.25.0}/src/dcnum/segm/__init__.py +0 -0
  55. {dcnum-0.24.0 → dcnum-0.25.0}/src/dcnum/segm/segm_thresh.py +0 -0
  56. {dcnum-0.24.0 → dcnum-0.25.0}/src/dcnum/segm/segm_torch/__init__.py +0 -0
  57. {dcnum-0.24.0 → dcnum-0.25.0}/src/dcnum/segm/segm_torch/segm_torch_base.py +0 -0
  58. {dcnum-0.24.0 → dcnum-0.25.0}/src/dcnum/segm/segm_torch/segm_torch_mpo.py +0 -0
  59. {dcnum-0.24.0 → dcnum-0.25.0}/src/dcnum/segm/segm_torch/segm_torch_sto.py +0 -0
  60. {dcnum-0.24.0 → dcnum-0.25.0}/src/dcnum/segm/segm_torch/torch_model.py +0 -0
  61. {dcnum-0.24.0 → dcnum-0.25.0}/src/dcnum/segm/segm_torch/torch_postproc.py +0 -0
  62. {dcnum-0.24.0 → dcnum-0.25.0}/src/dcnum/segm/segm_torch/torch_preproc.py +0 -0
  63. {dcnum-0.24.0 → dcnum-0.25.0}/src/dcnum/segm/segmenter.py +0 -0
  64. {dcnum-0.24.0 → dcnum-0.25.0}/src/dcnum/segm/segmenter_manager_thread.py +0 -0
  65. {dcnum-0.24.0 → dcnum-0.25.0}/src/dcnum/segm/segmenter_mpo.py +0 -0
  66. {dcnum-0.24.0 → dcnum-0.25.0}/src/dcnum/segm/segmenter_sto.py +0 -0
  67. {dcnum-0.24.0 → dcnum-0.25.0}/src/dcnum/write/__init__.py +0 -0
  68. {dcnum-0.24.0 → dcnum-0.25.0}/src/dcnum/write/deque_writer_thread.py +0 -0
  69. {dcnum-0.24.0 → dcnum-0.25.0}/src/dcnum/write/queue_collector_thread.py +0 -0
  70. {dcnum-0.24.0 → dcnum-0.25.0}/src/dcnum/write/writer.py +0 -0
  71. {dcnum-0.24.0 → dcnum-0.25.0}/src/dcnum.egg-info/dependency_links.txt +0 -0
  72. {dcnum-0.24.0 → dcnum-0.25.0}/src/dcnum.egg-info/requires.txt +0 -0
  73. {dcnum-0.24.0 → dcnum-0.25.0}/src/dcnum.egg-info/top_level.txt +0 -0
  74. {dcnum-0.24.0 → dcnum-0.25.0}/tests/conftest.py +0 -0
  75. {dcnum-0.24.0 → dcnum-0.25.0}/tests/data/fmt-hdf5_cytoshot_extended-moments-features.zip +0 -0
  76. {dcnum-0.24.0 → dcnum-0.25.0}/tests/data/fmt-hdf5_cytoshot_full-features_2023.zip +0 -0
  77. {dcnum-0.24.0 → dcnum-0.25.0}/tests/data/fmt-hdf5_cytoshot_full-features_2024.zip +0 -0
  78. {dcnum-0.24.0 → dcnum-0.25.0}/tests/data/fmt-hdf5_cytoshot_full-features_legacy_allev_2023.zip +0 -0
  79. {dcnum-0.24.0 → dcnum-0.25.0}/tests/data/fmt-hdf5_shapein_empty.zip +0 -0
  80. {dcnum-0.24.0 → dcnum-0.25.0}/tests/data/fmt-hdf5_shapein_raw-with-variable-length-logs.zip +0 -0
  81. {dcnum-0.24.0 → dcnum-0.25.0}/tests/data/segm-torch-model_unet-dcnum-test_g1_910c2.zip +0 -0
  82. {dcnum-0.24.0 → dcnum-0.25.0}/tests/data/segm-torch-test-data_unet-dcnum-test_g1_910c2.zip +0 -0
  83. {dcnum-0.24.0 → dcnum-0.25.0}/tests/helper_methods.py +0 -0
  84. {dcnum-0.24.0 → dcnum-0.25.0}/tests/requirements.txt +0 -0
  85. {dcnum-0.24.0 → dcnum-0.25.0}/tests/test_feat_background_base.py +0 -0
  86. {dcnum-0.24.0 → dcnum-0.25.0}/tests/test_feat_background_bg_copy.py +0 -0
  87. {dcnum-0.24.0 → dcnum-0.25.0}/tests/test_feat_background_bg_roll_median.py +0 -0
  88. {dcnum-0.24.0 → dcnum-0.25.0}/tests/test_feat_background_bg_sparsemed.py +0 -0
  89. {dcnum-0.24.0 → dcnum-0.25.0}/tests/test_feat_brightness.py +0 -0
  90. {dcnum-0.24.0 → dcnum-0.25.0}/tests/test_feat_event_extractor_manager.py +0 -0
  91. {dcnum-0.24.0 → dcnum-0.25.0}/tests/test_feat_gate.py +0 -0
  92. {dcnum-0.24.0 → dcnum-0.25.0}/tests/test_feat_haralick.py +0 -0
  93. {dcnum-0.24.0 → dcnum-0.25.0}/tests/test_feat_moments_based.py +0 -0
  94. {dcnum-0.24.0 → dcnum-0.25.0}/tests/test_feat_moments_based_extended.py +0 -0
  95. {dcnum-0.24.0 → dcnum-0.25.0}/tests/test_feat_volume.py +0 -0
  96. {dcnum-0.24.0 → dcnum-0.25.0}/tests/test_init.py +0 -0
  97. {dcnum-0.24.0 → dcnum-0.25.0}/tests/test_logic_job.py +0 -0
  98. {dcnum-0.24.0 → dcnum-0.25.0}/tests/test_logic_join.py +0 -0
  99. {dcnum-0.24.0 → dcnum-0.25.0}/tests/test_logic_json.py +0 -0
  100. {dcnum-0.24.0 → dcnum-0.25.0}/tests/test_logic_pipeline.py +0 -0
  101. {dcnum-0.24.0 → dcnum-0.25.0}/tests/test_meta_paths.py +0 -0
  102. {dcnum-0.24.0 → dcnum-0.25.0}/tests/test_meta_ppid_bg.py +0 -0
  103. {dcnum-0.24.0 → dcnum-0.25.0}/tests/test_meta_ppid_data.py +0 -0
  104. {dcnum-0.24.0 → dcnum-0.25.0}/tests/test_meta_ppid_feat.py +0 -0
  105. {dcnum-0.24.0 → dcnum-0.25.0}/tests/test_meta_ppid_gate.py +0 -0
  106. {dcnum-0.24.0 → dcnum-0.25.0}/tests/test_meta_ppid_segm.py +0 -0
  107. {dcnum-0.24.0 → dcnum-0.25.0}/tests/test_read_basin.py +0 -0
  108. {dcnum-0.24.0 → dcnum-0.25.0}/tests/test_read_concat_hdf5.py +0 -0
  109. {dcnum-0.24.0 → dcnum-0.25.0}/tests/test_read_hdf5_basins.py +0 -0
  110. {dcnum-0.24.0 → dcnum-0.25.0}/tests/test_read_hdf5_index_mapping.py +0 -0
  111. {dcnum-0.24.0 → dcnum-0.25.0}/tests/test_segm_base.py +0 -0
  112. {dcnum-0.24.0 → dcnum-0.25.0}/tests/test_segm_mpo.py +0 -0
  113. {dcnum-0.24.0 → dcnum-0.25.0}/tests/test_segm_no_mask_proc.py +0 -0
  114. {dcnum-0.24.0 → dcnum-0.25.0}/tests/test_segm_sto.py +0 -0
  115. {dcnum-0.24.0 → dcnum-0.25.0}/tests/test_segm_thresh.py +0 -0
  116. {dcnum-0.24.0 → dcnum-0.25.0}/tests/test_segm_torch.py +0 -0
  117. {dcnum-0.24.0 → dcnum-0.25.0}/tests/test_segm_torch_preproc.py +0 -0
  118. {dcnum-0.24.0 → dcnum-0.25.0}/tests/test_write_deque_writer_thread.py +0 -0
  119. {dcnum-0.24.0 → dcnum-0.25.0}/tests/test_write_queue_collector_thread.py +0 -0
  120. {dcnum-0.24.0 → dcnum-0.25.0}/tests/test_write_writer.py +0 -0
@@ -1,3 +1,7 @@
1
+ 0.25.0
2
+ - feat: identify flickering in raw data via dcnum.read.detect_flickering
3
+ - fix: handle out-of-bounds slice indexing for BaseImageChunkCache
4
+ - fix: np.bool_ and np.floating not recognized in PPID parsing
1
5
  0.24.0
2
6
  - feat: add support for internal basins
3
7
  - feat: "image_bg" as internal basin for "sparsemed" background computer
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dcnum
3
- Version: 0.24.0
3
+ Version: 0.25.0
4
4
  Summary: numerics toolbox for imaging deformability cytometry
5
5
  Author: Maximilian Schlögel, Paul Müller, Raghava Alajangi
6
6
  Maintainer-email: Paul Müller <dev@craban.de>
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '0.24.0'
16
- __version_tuple__ = version_tuple = (0, 24, 0)
15
+ __version__ = version = '0.25.0'
16
+ __version_tuple__ = version_tuple = (0, 25, 0)
@@ -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 data compression filters). In
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 data compression filters). In
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
@@ -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}")
@@ -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
@@ -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(index.start or 0,
40
- index.stop or len(self),
41
- index.step)
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,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dcnum
3
- Version: 0.24.0
3
+ Version: 0.25.0
4
4
  Summary: numerics toolbox for imaging deformability cytometry
5
5
  Author: Maximilian Schlögel, Paul Müller, Raghava Alajangi
6
6
  Maintainer-email: Paul Müller <dev@craban.de>
@@ -46,6 +46,7 @@ src/dcnum/meta/ppid.py
46
46
  src/dcnum/read/__init__.py
47
47
  src/dcnum/read/cache.py
48
48
  src/dcnum/read/const.py
49
+ src/dcnum/read/detect_flicker.py
49
50
  src/dcnum/read/hdf5_data.py
50
51
  src/dcnum/read/mapped.py
51
52
  src/dcnum/segm/__init__.py
@@ -93,6 +94,7 @@ tests/test_meta_ppid_gate.py
93
94
  tests/test_meta_ppid_segm.py
94
95
  tests/test_read_basin.py
95
96
  tests/test_read_concat_hdf5.py
97
+ tests/test_read_detect_flicker.py
96
98
  tests/test_read_hdf5.py
97
99
  tests/test_read_hdf5_basins.py
98
100
  tests/test_read_hdf5_index_mapping.py
@@ -1,5 +1,7 @@
1
1
  import inspect
2
2
 
3
+ import numpy as np
4
+
3
5
  import pytest
4
6
 
5
7
  from dcnum.meta import ppid
@@ -80,8 +82,14 @@ def test_unique_prefix_unordered(in_list, out_list):
80
82
  "tem=90^te=a^o=0^wit=1^a=1000^win=red^tes=1"),
81
83
  ({"temperature": 10.1},
82
84
  "tem=10.1^te=a^o=0^wit=1^a=1000^win=red^tes=1"),
85
+ ({"temperature": 10.0},
86
+ "tem=10^te=a^o=0^wit=1^a=1000^win=red^tes=1"),
87
+ ({"temperature": np.float16(9.0)},
88
+ "tem=9^te=a^o=0^wit=1^a=1000^win=red^tes=1"),
83
89
  ({"with_water": False, "wine_type": "blue"},
84
90
  "tem=90^te=a^o=0^wit=0^a=1000^win=blue^tes=1"),
91
+ ({"with_water": np.bool_(1), "wine_type": "blue"},
92
+ "tem=90^te=a^o=0^wit=1^a=1000^win=blue^tes=1"),
85
93
  ])
86
94
  def test_kwargs_to_ppid(kwargs, pid):
87
95
  ptest = ppid.kwargs_to_ppid(ExampleClass, "cook", kwargs)
@@ -0,0 +1,87 @@
1
+ import numpy as np
2
+
3
+ from dcnum.read import concatenated_hdf5_data, detect_flickering
4
+
5
+ from helper_methods import retrieve_data
6
+
7
+
8
+ def test_detect_flicker_basic():
9
+ image_data = np.full((500, 80, 320), 145)
10
+ flicker_indices = [4, 9, 10, 23, 439]
11
+ for idx in flicker_indices:
12
+ image_data[idx] += 5
13
+ assert detect_flickering(image_data,
14
+ roi_height=10,
15
+ brightness_threshold=5,
16
+ count_threshold=5,
17
+ max_frames=500,
18
+ )
19
+
20
+ assert not detect_flickering(image_data,
21
+ roi_height=10,
22
+ brightness_threshold=5,
23
+ count_threshold=6, # threshold too low
24
+ max_frames=500,
25
+ )
26
+
27
+ assert not detect_flickering(image_data,
28
+ roi_height=10,
29
+ brightness_threshold=6, # threshold too low
30
+ count_threshold=5,
31
+ max_frames=500,
32
+ )
33
+
34
+ assert not detect_flickering(image_data,
35
+ roi_height=10,
36
+ brightness_threshold=5,
37
+ count_threshold=5,
38
+ max_frames=400, # too few frames
39
+ )
40
+
41
+
42
+ def test_detect_flicker_hdf5data_instance():
43
+ path = retrieve_data("fmt-hdf5_cytoshot_full-features_2023.zip")
44
+ path_out = path.with_name("input.rtdc")
45
+ # create simple concatenated dataset, repeating a file
46
+ with concatenated_hdf5_data([path]*25, path_out=path_out) as hd:
47
+ assert len(hd) == 1000
48
+ assert not detect_flickering(hd.image)
49
+ assert detect_flickering(hd.image, brightness_threshold=1)
50
+
51
+
52
+ def test_detect_flicker_none():
53
+ image_data = np.full((500, 80, 320), 145)
54
+ assert not detect_flickering(image_data,
55
+ roi_height=10,
56
+ brightness_threshold=5,
57
+ count_threshold=5,
58
+ max_frames=500,
59
+ )
60
+
61
+
62
+ def test_detect_flicker_not_outside_roi():
63
+ image_data = np.full((500, 80, 320), 145)
64
+ flicker_indices = [4, 9, 10, 23, 439]
65
+ for idx in flicker_indices:
66
+ # only modify data outside the ROI
67
+ image_data[idx, 11:, :] += 5
68
+ assert not detect_flickering(image_data,
69
+ roi_height=10,
70
+ brightness_threshold=5,
71
+ count_threshold=5,
72
+ max_frames=500,
73
+ )
74
+
75
+
76
+ def test_detect_flicker_only_inside_roi():
77
+ image_data = np.full((500, 80, 320), 145)
78
+ flicker_indices = [4, 9, 10, 23, 439]
79
+ for idx in flicker_indices:
80
+ # only modify data inside the ROI
81
+ image_data[idx, :10, :] += 5
82
+ assert detect_flickering(image_data,
83
+ roi_height=10,
84
+ brightness_threshold=5,
85
+ count_threshold=5,
86
+ max_frames=500,
87
+ )
@@ -106,6 +106,19 @@ def test_image_cache(tmp_path):
106
106
  assert 2 in hic.cache
107
107
 
108
108
 
109
+ def test_image_cache_slice_out_of_bounds(tmp_path):
110
+ path = tmp_path / "test.hdf5"
111
+ with h5py.File(path, "w") as hw:
112
+ hw["events/image"] = np.random.rand(210, 80, 180)
113
+
114
+ with h5py.File(path, "r") as h5:
115
+ hic = read.HDF5ImageCache(h5["events/image"],
116
+ chunk_size=100,
117
+ cache_size=2)
118
+ assert len(hic) == 210
119
+ assert len(hic[:300]) == 210
120
+
121
+
109
122
  def test_image_cache_index_out_of_range(tmp_path):
110
123
  path = tmp_path / "test.hdf5"
111
124
  size = 20
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes