dcnum 0.31.0__tar.gz → 0.31.2__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.
Files changed (173) hide show
  1. {dcnum-0.31.0 → dcnum-0.31.2}/CHANGELOG +22 -6
  2. {dcnum-0.31.0 → dcnum-0.31.2}/PKG-INFO +5 -2
  3. {dcnum-0.31.0 → dcnum-0.31.2}/README.rst +4 -1
  4. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum/_version.py +3 -3
  5. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum/common.py +28 -2
  6. dcnum-0.31.2/dcnum/external/__init__.py +1 -0
  7. dcnum-0.31.2/dcnum/external/skimage_morphology.py +70 -0
  8. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum/feat/feat_background/base.py +15 -6
  9. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum/feat/feat_background/bg_copy.py +3 -2
  10. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum/feat/feat_background/bg_roll_median.py +21 -16
  11. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum/feat/feat_background/bg_sparse_median.py +37 -15
  12. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum/feat/feat_brightness/bright_all.py +65 -6
  13. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum/feat/feat_brightness/common.py +1 -0
  14. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum/feat/feat_contour/contour.py +1 -0
  15. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum/feat/feat_contour/moments.py +1 -0
  16. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum/feat/feat_contour/volume.py +23 -10
  17. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum/feat/feat_texture/common.py +1 -0
  18. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum/feat/feat_texture/tex_all.py +13 -12
  19. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum/feat/gate.py +12 -7
  20. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum/feat/queue_event_extractor.py +10 -2
  21. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum/logic/chunk_slot.py +47 -1
  22. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum/logic/chunk_slot_data.py +27 -4
  23. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum/logic/ctrl.py +118 -16
  24. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum/logic/job.py +34 -0
  25. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum/logic/json_encoder.py +7 -0
  26. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum/logic/slot_register.py +77 -30
  27. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum/logic/universal_worker.py +69 -1
  28. dcnum-0.31.2/dcnum/meta/__init__.py +4 -0
  29. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum/meta/paths.py +1 -0
  30. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum/meta/ppid.py +106 -9
  31. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum/os_env_st.py +6 -1
  32. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum/read/__init__.py +2 -0
  33. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum/read/cache.py +48 -1
  34. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum/read/const.py +2 -0
  35. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum/read/detect_flicker.py +2 -0
  36. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum/read/hdf5_concat.py +2 -0
  37. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum/read/hdf5_data.py +67 -1
  38. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum/read/mapped.py +26 -3
  39. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum/segm/__init__.py +2 -0
  40. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum/segm/segm_thresh.py +14 -4
  41. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum/segm/segm_torch/__init__.py +2 -0
  42. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum/segm/segm_torch/segm_torch_base.py +22 -2
  43. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum/segm/segm_torch/segm_torch_mpo.py +6 -3
  44. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum/segm/segm_torch/segm_torch_sto.py +7 -2
  45. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum/segm/segm_torch/segm_torch_uni.py +22 -7
  46. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum/segm/segm_torch/torch_model.py +2 -0
  47. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum/segm/segm_torch/torch_postproc.py +2 -0
  48. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum/segm/segm_torch/torch_preproc.py +8 -6
  49. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum/segm/segm_torch/torch_setup.py +12 -0
  50. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum/segm/segmenter.py +61 -26
  51. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum/segm/segmenter_manager_thread.py +10 -2
  52. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum/segm/segmenter_mpo.py +54 -17
  53. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum/segm/segmenter_sto.py +19 -9
  54. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum/segm/segmenter_uni.py +22 -10
  55. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum/write/__init__.py +1 -0
  56. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum/write/chunk_writer.py +21 -2
  57. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum/write/event_stash.py +1 -0
  58. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum/write/queue_writer_base.py +12 -5
  59. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum/write/queue_writer_process.py +26 -0
  60. dcnum-0.31.2/dcnum/write/queue_writer_thread.py +16 -0
  61. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum/write/writer.py +22 -0
  62. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum.egg-info/PKG-INFO +5 -2
  63. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum.egg-info/SOURCES.txt +6 -0
  64. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum.egg-info/scm_file_list.json +6 -0
  65. dcnum-0.31.2/dcnum.egg-info/scm_version.json +8 -0
  66. {dcnum-0.31.0 → dcnum-0.31.2}/docs/conf.py +14 -0
  67. dcnum-0.31.2/docs/figures/pipeline_overview.py +114 -0
  68. dcnum-0.31.2/docs/figures/pipeline_steps_thresh.py +59 -0
  69. dcnum-0.31.2/docs/figures/pipeline_steps_unet.py +54 -0
  70. dcnum-0.31.2/docs/index.rst +32 -0
  71. dcnum-0.31.2/docs/sec_changelog.rst +8 -0
  72. dcnum-0.31.2/docs/sec_design.rst +109 -0
  73. dcnum-0.31.2/docs/sec_getting_started.rst +197 -0
  74. dcnum-0.31.2/docs/sec_pipeline.rst +227 -0
  75. {dcnum-0.31.0 → dcnum-0.31.2}/tests/test_feat_gate.py +31 -0
  76. {dcnum-0.31.0 → dcnum-0.31.2}/tests/test_logic_pipeline.py +163 -0
  77. dcnum-0.31.0/dcnum/external/__init__.py +0 -0
  78. dcnum-0.31.0/dcnum/external/skimage_morphology.py +0 -68
  79. dcnum-0.31.0/dcnum/meta/__init__.py +0 -3
  80. dcnum-0.31.0/dcnum/write/queue_writer_thread.py +0 -8
  81. dcnum-0.31.0/dcnum.egg-info/scm_version.json +0 -8
  82. dcnum-0.31.0/docs/index.rst +0 -21
  83. dcnum-0.31.0/docs/sec_design.rst +0 -88
  84. {dcnum-0.31.0 → dcnum-0.31.2}/.github/workflows/check.yml +0 -0
  85. {dcnum-0.31.0 → dcnum-0.31.2}/.github/workflows/deploy_pypi.yml +0 -0
  86. {dcnum-0.31.0 → dcnum-0.31.2}/.gitignore +0 -0
  87. {dcnum-0.31.0 → dcnum-0.31.2}/.readthedocs.yml +0 -0
  88. {dcnum-0.31.0 → dcnum-0.31.2}/LICENSE +0 -0
  89. {dcnum-0.31.0 → dcnum-0.31.2}/benchmark/.gitignore +0 -0
  90. {dcnum-0.31.0 → dcnum-0.31.2}/benchmark/Readme.md +0 -0
  91. {dcnum-0.31.0 → dcnum-0.31.2}/benchmark/benchmark.py +0 -0
  92. {dcnum-0.31.0 → dcnum-0.31.2}/benchmark/bm_logic_ctrl_job_runner.py +0 -0
  93. {dcnum-0.31.0 → dcnum-0.31.2}/benchmark/bm_logic_slot_register_task_extract_features.py +0 -0
  94. {dcnum-0.31.0 → dcnum-0.31.2}/benchmark/bm_segm_segmenter.py +0 -0
  95. {dcnum-0.31.0 → dcnum-0.31.2}/benchmark/bm_segm_segmenter_manager_thread.py +0 -0
  96. {dcnum-0.31.0 → dcnum-0.31.2}/benchmark/bm_write_chunk_writer.py +0 -0
  97. {dcnum-0.31.0 → dcnum-0.31.2}/benchmark/bm_write_queue_writer_thread.py +0 -0
  98. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum/__init__.py +0 -0
  99. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum/feat/__init__.py +0 -0
  100. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum/feat/feat_background/__init__.py +0 -0
  101. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum/feat/feat_brightness/__init__.py +0 -0
  102. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum/feat/feat_contour/__init__.py +0 -0
  103. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum/feat/feat_texture/__init__.py +0 -0
  104. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum/logic/__init__.py +0 -0
  105. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum.egg-info/dependency_links.txt +0 -0
  106. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum.egg-info/requires.txt +0 -0
  107. {dcnum-0.31.0 → dcnum-0.31.2}/dcnum.egg-info/top_level.txt +0 -0
  108. {dcnum-0.31.0 → dcnum-0.31.2}/docs/.gitignore +0 -0
  109. {dcnum-0.31.0 → dcnum-0.31.2}/docs/extensions/github_changelog.py +0 -0
  110. {dcnum-0.31.0 → dcnum-0.31.2}/docs/requirements.txt +0 -0
  111. {dcnum-0.31.0 → dcnum-0.31.2}/pyproject.toml +0 -0
  112. {dcnum-0.31.0 → dcnum-0.31.2}/setup.cfg +0 -0
  113. {dcnum-0.31.0 → dcnum-0.31.2}/tests/conftest.py +0 -0
  114. {dcnum-0.31.0 → dcnum-0.31.2}/tests/data/Readme.md +0 -0
  115. {dcnum-0.31.0 → dcnum-0.31.2}/tests/data/fmt-hdf5_cytoshot_extended-moments-features.zip +0 -0
  116. {dcnum-0.31.0 → dcnum-0.31.2}/tests/data/fmt-hdf5_cytoshot_full-features_2023.zip +0 -0
  117. {dcnum-0.31.0 → dcnum-0.31.2}/tests/data/fmt-hdf5_cytoshot_full-features_2024.zip +0 -0
  118. {dcnum-0.31.0 → dcnum-0.31.2}/tests/data/fmt-hdf5_cytoshot_full-features_legacy_allev_2023.zip +0 -0
  119. {dcnum-0.31.0 → dcnum-0.31.2}/tests/data/fmt-hdf5_shapein_empty.zip +0 -0
  120. {dcnum-0.31.0 → dcnum-0.31.2}/tests/data/fmt-hdf5_shapein_raw-with-variable-length-logs.zip +0 -0
  121. {dcnum-0.31.0 → dcnum-0.31.2}/tests/data/segm-torch-model_unet-dcnum-test_g1_6784c.zip +0 -0
  122. {dcnum-0.31.0 → dcnum-0.31.2}/tests/data/segm-torch-model_unet-dcnum-test_g1_910c2.zip +0 -0
  123. {dcnum-0.31.0 → dcnum-0.31.2}/tests/data/segm-torch-model_unet-dcnum-test_g2_02dcd.zip +0 -0
  124. {dcnum-0.31.0 → dcnum-0.31.2}/tests/data/segm-torch-model_unet-dcnum-test_g2_0901b.zip +0 -0
  125. {dcnum-0.31.0 → dcnum-0.31.2}/tests/data/segm-torch-model_unet-dcnum-test_g2_17ec6.zip +0 -0
  126. {dcnum-0.31.0 → dcnum-0.31.2}/tests/data/segm-torch-test-data_unet-dcnum-test_g1_910c2.zip +0 -0
  127. {dcnum-0.31.0 → dcnum-0.31.2}/tests/helper_methods.py +0 -0
  128. {dcnum-0.31.0 → dcnum-0.31.2}/tests/requirements.txt +0 -0
  129. {dcnum-0.31.0 → dcnum-0.31.2}/tests/test_common_join.py +0 -0
  130. {dcnum-0.31.0 → dcnum-0.31.2}/tests/test_common_lazy_loader.py +0 -0
  131. {dcnum-0.31.0 → dcnum-0.31.2}/tests/test_feat_background_base.py +0 -0
  132. {dcnum-0.31.0 → dcnum-0.31.2}/tests/test_feat_background_bg_copy.py +0 -0
  133. {dcnum-0.31.0 → dcnum-0.31.2}/tests/test_feat_background_bg_roll_median.py +0 -0
  134. {dcnum-0.31.0 → dcnum-0.31.2}/tests/test_feat_background_bg_sparsemed.py +0 -0
  135. {dcnum-0.31.0 → dcnum-0.31.2}/tests/test_feat_brightness.py +0 -0
  136. {dcnum-0.31.0 → dcnum-0.31.2}/tests/test_feat_haralick.py +0 -0
  137. {dcnum-0.31.0 → dcnum-0.31.2}/tests/test_feat_moments_based.py +0 -0
  138. {dcnum-0.31.0 → dcnum-0.31.2}/tests/test_feat_moments_based_extended.py +0 -0
  139. {dcnum-0.31.0 → dcnum-0.31.2}/tests/test_feat_volume.py +0 -0
  140. {dcnum-0.31.0 → dcnum-0.31.2}/tests/test_init.py +0 -0
  141. {dcnum-0.31.0 → dcnum-0.31.2}/tests/test_logic_chunk_slot.py +0 -0
  142. {dcnum-0.31.0 → dcnum-0.31.2}/tests/test_logic_job.py +0 -0
  143. {dcnum-0.31.0 → dcnum-0.31.2}/tests/test_logic_json.py +0 -0
  144. {dcnum-0.31.0 → dcnum-0.31.2}/tests/test_logic_slot_register.py +0 -0
  145. {dcnum-0.31.0 → dcnum-0.31.2}/tests/test_logic_state_warden.py +0 -0
  146. {dcnum-0.31.0 → dcnum-0.31.2}/tests/test_logic_universal_worker.py +0 -0
  147. {dcnum-0.31.0 → dcnum-0.31.2}/tests/test_meta_paths.py +0 -0
  148. {dcnum-0.31.0 → dcnum-0.31.2}/tests/test_meta_ppid_base.py +0 -0
  149. {dcnum-0.31.0 → dcnum-0.31.2}/tests/test_meta_ppid_bg.py +0 -0
  150. {dcnum-0.31.0 → dcnum-0.31.2}/tests/test_meta_ppid_data.py +0 -0
  151. {dcnum-0.31.0 → dcnum-0.31.2}/tests/test_meta_ppid_feat.py +0 -0
  152. {dcnum-0.31.0 → dcnum-0.31.2}/tests/test_meta_ppid_gate.py +0 -0
  153. {dcnum-0.31.0 → dcnum-0.31.2}/tests/test_meta_ppid_segm.py +0 -0
  154. {dcnum-0.31.0 → dcnum-0.31.2}/tests/test_read_basin.py +0 -0
  155. {dcnum-0.31.0 → dcnum-0.31.2}/tests/test_read_cache.py +0 -0
  156. {dcnum-0.31.0 → dcnum-0.31.2}/tests/test_read_concat_hdf5.py +0 -0
  157. {dcnum-0.31.0 → dcnum-0.31.2}/tests/test_read_detect_flicker.py +0 -0
  158. {dcnum-0.31.0 → dcnum-0.31.2}/tests/test_read_hdf5.py +0 -0
  159. {dcnum-0.31.0 → dcnum-0.31.2}/tests/test_read_hdf5_basins.py +0 -0
  160. {dcnum-0.31.0 → dcnum-0.31.2}/tests/test_read_hdf5_concat.py +0 -0
  161. {dcnum-0.31.0 → dcnum-0.31.2}/tests/test_read_hdf5_index_mapping.py +0 -0
  162. {dcnum-0.31.0 → dcnum-0.31.2}/tests/test_segm_base.py +0 -0
  163. {dcnum-0.31.0 → dcnum-0.31.2}/tests/test_segm_mpo.py +0 -0
  164. {dcnum-0.31.0 → dcnum-0.31.2}/tests/test_segm_no_mask_proc.py +0 -0
  165. {dcnum-0.31.0 → dcnum-0.31.2}/tests/test_segm_sto.py +0 -0
  166. {dcnum-0.31.0 → dcnum-0.31.2}/tests/test_segm_thresh.py +0 -0
  167. {dcnum-0.31.0 → dcnum-0.31.2}/tests/test_segm_torch.py +0 -0
  168. {dcnum-0.31.0 → dcnum-0.31.2}/tests/test_segm_torch_model_file.py +0 -0
  169. {dcnum-0.31.0 → dcnum-0.31.2}/tests/test_segm_torch_preproc.py +0 -0
  170. {dcnum-0.31.0 → dcnum-0.31.2}/tests/test_segm_torch_uni.py +0 -0
  171. {dcnum-0.31.0 → dcnum-0.31.2}/tests/test_write_chunk_writer.py +0 -0
  172. {dcnum-0.31.0 → dcnum-0.31.2}/tests/test_write_queue_writer_thread.py +0 -0
  173. {dcnum-0.31.0 → dcnum-0.31.2}/tests/test_write_writer.py +0 -0
@@ -1,3 +1,19 @@
1
+ 0.31.2
2
+ - fix: online gates for `size_x` and `size_y` were ignored (regression in 0.16.6)
3
+ - fix: "pipeline:dcnum yield" and "experiment:event count" were set to
4
+ zero when the pipeline did not have to be rerun on a dcnum output file
5
+ 0.31.1
6
+ - fix: pipeline failed for relative `path_in` when `path_out` is in a
7
+ different directory (basin path resolved relative to the wrong directory)
8
+ - fix: `DCNumJobRunner.get_status` counted plumbing progress twice
9
+ - fix: register `atexit` removal of temporary files only once per job
10
+ - fix: `bg_off` ignored for padded batches in `task_segment_images`
11
+ - docs: add changelog section, introduction and intersphinx links
12
+ - docs: add "Getting started" section with installation and usage
13
+ - docs: add overview of the data pipeline with figures
14
+ - docs: update outdated pipeline sequence in design section
15
+ - docs: correct description of `bg_off` computation in `BackgroundSparseMed`
16
+ - docs: complete docstrings for the API reference and fix all Sphinx warnings
1
17
  0.31.0
2
18
  - feat: introduce `UNISegmenter` which is handled by `UniversalWorker`
3
19
  - feat: `torchuni` segmenter with openvino/torch.jit/inductor" backends
@@ -57,10 +73,10 @@
57
73
  - enh: lazy-load cv2, h5py, numba-compiled functions, scipy, and torch (#26)
58
74
  - enh: introduce logging with queues in `UniversalWorker`
59
75
  - enh: move feature extraction to `UniversalWorker` (#48)
60
- - enh: start `UniversalWorker`s in background thread
76
+ - enh: start `UniversalWorker` instances in background thread
61
77
  - enh: add `HDF5Data.image_num_chunks`
62
78
  - enh: mitigate race conditions with `StateWarden`
63
- - ref: rename `get_lock` to ``get_counter_lock` in `SlotRegister`
79
+ - ref: rename `get_lock` to `get_counter_lock` in `SlotRegister`
64
80
  - ref: generalized interface for counters in `SlotRegister`
65
81
  - ref: move invalid mask notification to `DCNumJobRunner`
66
82
  - ref: migrate `write_queue_size` from `DCNumJobRunner` to `SlotRegister`
@@ -170,13 +186,13 @@
170
186
  - setup: pin dependencies
171
187
  0.25.1
172
188
  - fix: catch ValueError when computing relative path on different anchors
173
- - ref: replace np.string_ with np.bytes_
189
+ - ref: replace `np.string_` with `np.bytes_`
174
190
  - ref: remove unused `data` argument to QueueCollectorThread
175
191
  - ref: minor speed-up for QueueCollectorThread
176
192
  0.25.0
177
193
  - feat: identify flickering in raw data via dcnum.read.detect_flickering
178
194
  - fix: handle out-of-bounds slice indexing for BaseImageChunkCache
179
- - fix: np.bool_ and np.floating not recognized in PPID parsing
195
+ - fix: `np.bool_` and `np.floating` not recognized in PPID parsing
180
196
  0.24.0
181
197
  - feat: add support for internal basins
182
198
  - feat: "image_bg" as internal basin for "sparsemed" background computer
@@ -251,7 +267,7 @@
251
267
  0.19.1
252
268
  - enh: support steps when specifying data slices in `index_mapping`
253
269
  0.19.0
254
- - enh: elevate `HDF5Data`s `index_mapping` to pipeline identifier status
270
+ - enh: elevate `HDF5Data.index_mapping` to pipeline identifier status
255
271
  (this changes the pipeline identifier)
256
272
  - enh: improve sanity checks for `BackgroundRollMed`
257
273
  0.18.0
@@ -476,7 +492,7 @@
476
492
  - enh: make sure that masks are written as uint8 to HDF5 files
477
493
  - ref: haralick texture computation now returns dict instead of recarray
478
494
  - ref: renamed HDF5WriterThread to DequeWriterThread
479
- - ref: renamed feature submodules (prepended "feat_")
495
+ - ref: renamed feature submodules (prepended `feat_`)
480
496
  0.0.7
481
497
  - enh: dataset keyword arguments and mode HDF5WriterThread
482
498
  - enh: speed-up of brightness feature computation
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dcnum
3
- Version: 0.31.0
3
+ Version: 0.31.2
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>
@@ -37,7 +37,10 @@ Dynamic: license-file
37
37
  |PyPI Version| |Build Status| |Coverage Status| |Docs Status|
38
38
 
39
39
 
40
- Numerics toolbox for imaging deformability cytometry.
40
+ Numerics toolbox for imaging deformability cytometry. dcnum computes
41
+ background images, segments events (by thresholding or with
42
+ machine-learning models), and extracts event features from raw .rtdc
43
+ measurement data.
41
44
 
42
45
  Documentation
43
46
  -------------
@@ -4,7 +4,10 @@
4
4
  |PyPI Version| |Build Status| |Coverage Status| |Docs Status|
5
5
 
6
6
 
7
- Numerics toolbox for imaging deformability cytometry.
7
+ Numerics toolbox for imaging deformability cytometry. dcnum computes
8
+ background images, segments events (by thresholding or with
9
+ machine-learning models), and extracts event features from raw .rtdc
10
+ measurement data.
8
11
 
9
12
  Documentation
10
13
  -------------
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
18
18
  commit_id: str | None
19
19
  __commit_id__: str | None
20
20
 
21
- __version__ = version = '0.31.0'
22
- __version_tuple__ = version_tuple = (0, 31, 0)
21
+ __version__ = version = '0.31.2'
22
+ __version_tuple__ = version_tuple = (0, 31, 2)
23
23
 
24
- __commit_id__ = commit_id = 'ga154b5d98'
24
+ __commit_id__ = commit_id = 'g848fedabb'
@@ -1,3 +1,4 @@
1
+ """Common helpers: lazy module loading, CPU counting, and worker handling"""
1
2
  from collections.abc import Callable
2
3
  import importlib
3
4
  import logging
@@ -100,9 +101,10 @@ def cpu_count() -> int:
100
101
 
101
102
  This method handles both cases by:
102
103
 
103
- 1. Get the number of physical CPUs using `psutil.cpu_count(logical=False)`
104
+ 1. Get the number of physical CPUs using
105
+ ``psutil.cpu_count(logical=False)``
104
106
  2. Get the number of CPUs according to process affinity
105
- 3. Get the number of CPUs using `multiprocessing.cpu_count()`
107
+ 3. Get the number of CPUs using ``multiprocessing.cpu_count()``
106
108
  4. Return the minimum of all of the above
107
109
  """
108
110
  num_cpus = []
@@ -151,6 +153,30 @@ def join_worker(worker,
151
153
 
152
154
 
153
155
  def start_workers_threaded(worker_list, logger, name):
156
+ """Start a list of workers sequentially in a separate thread
157
+
158
+ The workers' ``start`` methods are called one after another in a
159
+ background thread, so that spawning (which may take a while for
160
+ processes) does not block the calling thread. If a worker fails
161
+ to spawn with a :class:`BrokenPipeError`, an error is logged and
162
+ :class:`DCNUMHaltInterrupt` is raised in that thread.
163
+
164
+ Parameters
165
+ ----------
166
+ worker_list: list
167
+ Workers (e.g. :class:`threading.Thread` or
168
+ :class:`multiprocessing.Process` instances) to start
169
+ logger: logging.Logger
170
+ Logger used for reporting the spawn time and errors
171
+ name: str
172
+ Name describing the workers, used in log messages
173
+
174
+ Returns
175
+ -------
176
+ thread: threading.Thread
177
+ The (already started) thread that starts the workers;
178
+ join it to wait until all workers are started
179
+ """
154
180
  def target(worker_list, logger, name):
155
181
  tw0 = time.perf_counter()
156
182
  w = None
@@ -0,0 +1 @@
1
+ """External code copied from third-party libraries"""
@@ -0,0 +1,70 @@
1
+ """Code copied from skimage.morphology
2
+
3
+ License: BSD-3-Clause
4
+
5
+ ::
6
+
7
+ Redistribution and use in source and binary forms, with or without
8
+ modification, are permitted provided that the following conditions
9
+ are met:
10
+ 1. Redistributions of source code must retain the above copyright
11
+ notice, this list of conditions and the following disclaimer.
12
+ 2. Redistributions in binary form must reproduce the above copyright
13
+ notice, this list of conditions and the following disclaimer in the
14
+ documentation and/or other materials provided with the distribution.
15
+ 3. Neither the name of the University nor the names of its contributors
16
+ may be used to endorse or promote products derived from this software
17
+ without specific prior written permission.
18
+ .
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20
+ ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE HOLDERS OR
23
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
+ """
31
+ import numpy as np
32
+
33
+
34
+ def disk(radius, dtype=np.uint8, *, strict_radius=True, decomposition=None):
35
+ """Generates a flat, disk-shaped footprint.
36
+
37
+ A pixel is within the neighborhood if the Euclidean distance between
38
+ it and the origin is no greater than radius (This is only approximately
39
+ True, when ``decomposition == 'sequence'``).
40
+
41
+ Parameters
42
+ ----------
43
+ radius : int
44
+ The radius of the disk-shaped footprint.
45
+
46
+ Other Parameters
47
+ ----------------
48
+ dtype : data-type, optional
49
+ The data type of the footprint.
50
+ strict_radius : bool, optional
51
+ If False, extend the radius by 0.5. This allows the circle to expand
52
+ further within a cube that remains of size ``2 * radius + 1`` along
53
+ each axis. This parameter is ignored if decomposition is not None.
54
+ decomposition : {None, 'sequence', 'crosses'}, optional
55
+ This method was copied from skimage.morphology and only supports
56
+ ``decomposition=None``.
57
+
58
+ Returns
59
+ -------
60
+ footprint : ndarray
61
+ The footprint where elements of the neighborhood are 1 and 0 otherwise.
62
+ """
63
+ if decomposition is None:
64
+ L = np.arange(-radius, radius + 1)
65
+ X, Y = np.meshgrid(L, L)
66
+ if not strict_radius:
67
+ radius += 0.5
68
+ return np.array((X**2 + Y**2) <= radius**2, dtype=dtype)
69
+ else:
70
+ raise NotImplementedError("Please use `skimage.morphology.disk`")
@@ -1,3 +1,4 @@
1
+ """Base class and helpers for background image computation"""
1
2
  import abc
2
3
  import functools
3
4
  import inspect
@@ -29,8 +30,8 @@ class Background(abc.ABC):
29
30
  the "evtens/image" dataset or an array-like object that
30
31
  behaves like an image stack (first axis enumerates events)
31
32
  output_path: pathlib.Path
32
- Path to the output file. If `input_data` is a path, you can
33
- set `output_path` to the same path to write directly to the
33
+ Path to the output file. If ``input_data`` is a path, you can
34
+ set ``output_path`` to the same path to write directly to the
34
35
  input file. The data are written in the "events/image_bg"
35
36
  dataset in the output file.
36
37
  compress: bool
@@ -38,7 +39,7 @@ class Background(abc.ABC):
38
39
  for faster processing.
39
40
  num_cpus: int
40
41
  Number of CPUs to use for median computation. Defaults to
41
- `dcnum.common.cpu_count()`.
42
+ :func:`dcnum.common.cpu_count`.
42
43
  kwargs:
43
44
  Additional keyword arguments passed to the subclass.
44
45
  """
@@ -90,7 +91,9 @@ class Background(abc.ABC):
90
91
  self.h5in = h5py.File(input_data, "a", libver="latest")
91
92
  self.h5out = self.h5in
92
93
  else:
93
- self.paths_ref.append(input_data)
94
+ # Relative basin paths are resolved relative to
95
+ # `output_path`, so we must use an absolute path here.
96
+ self.paths_ref.append(input_data.resolve())
94
97
  self.h5in = h5py.File(input_data, "r", libver="latest")
95
98
  # TODO: Properly setup HDF5 caching.
96
99
  # Right now, we are accessing the raw h5ds property of
@@ -151,7 +154,7 @@ class Background(abc.ABC):
151
154
  KEY:KW_BACKGROUND
152
155
 
153
156
  Where KEY is e.g. "sparsemed" or "rollmed", and KW_BACKGROUND is a
154
- list of keyword arguments for `check_user_kwargs`, e.g.::
157
+ list of keyword arguments for :meth:`check_user_kwargs`, e.g.::
155
158
 
156
159
  kernel_size=100^batch_size=10000
157
160
 
@@ -163,6 +166,12 @@ class Background(abc.ABC):
163
166
 
164
167
  @classmethod
165
168
  def get_ppid_code(cls):
169
+ """Return the background method code used in the PPID
170
+
171
+ The code is the lower-case class name without the leading
172
+ ``"background"`` (e.g. ``"sparsemed"`` for
173
+ ``BackgroundSparseMed``).
174
+ """
166
175
  if cls is Background:
167
176
  raise ValueError("Cannot get `key` for `Background` base class!")
168
177
  key = cls.__name__.lower()
@@ -204,7 +213,7 @@ class Background(abc.ABC):
204
213
  """Perform the background computation
205
214
 
206
215
  This irreversibly removes/overrides any "image_bg" and
207
- "bg_off" features defined in the output file `self.h5out`.
216
+ "bg_off" features defined in the output file ``self.h5out``.
208
217
  """
209
218
  t0 = time.perf_counter()
210
219
 
@@ -1,3 +1,4 @@
1
+ """Background "computation" by copying existing background data"""
1
2
  from ...common import h5py
2
3
  from ...write import HDF5Writer
3
4
  from .base import Background
@@ -10,7 +11,7 @@ class BackgroundCopy(Background):
10
11
 
11
12
  @staticmethod
12
13
  def check_user_kwargs():
13
- pass
14
+ """No keyword arguments to check (there are none)"""
14
15
 
15
16
  def process(self):
16
17
  """Copy input data to output dataset"""
@@ -51,8 +52,8 @@ class BackgroundCopy(Background):
51
52
  self.image_proc.value = 1
52
53
 
53
54
  def process_approach(self):
55
+ """Does nothing; the data are copied in :meth:`process`"""
54
56
  # We do the copying in `process`, because we do not want to modify
55
57
  # any metadata or delete datasets as is done in the base class.
56
58
  # But we still have to implement this method, because it is an
57
59
  # abstractmethod in the base class.
58
- pass
@@ -1,3 +1,4 @@
1
+ """Rolling median background image computation"""
1
2
  import queue
2
3
  import time
3
4
 
@@ -17,16 +18,16 @@ class BackgroundRollMed(Background):
17
18
  batch_size=10000, compress=True, num_cpus=None):
18
19
  """Rolling median RT-DC background image computation
19
20
 
20
- 1. There is one big shared array `shared_input` that contains
21
+ 1. There is one big shared array ``shared_input`` that contains
21
22
  the image data for each batch.
22
23
  2. User specifies batch size (10000) and kernel size (default
23
24
  is 100)
24
- 3. There is a second shared array `shared_output` that contains
25
- the median values corresponding to the data in `shared_input`.
25
+ 3. There is a second shared array ``shared_output`` that contains
26
+ the median values corresponding to the data in ``shared_input``.
26
27
  4. Background computation is done by copying the input images
27
28
  from a file into the shared array.
28
29
  5. The input array is split into and workers compute the
29
- rolling median for each point in `shared_input`.
30
+ rolling median for each point in ``shared_input``.
30
31
 
31
32
  Parameters
32
33
  ----------
@@ -35,8 +36,8 @@ class BackgroundRollMed(Background):
35
36
  the "evtens/image" dataset or an array-like object that
36
37
  behaves like an image stack (first axis enumerates events)
37
38
  output_path: pathlib.Path
38
- Path to the output file. If `input_data` is a path, you can
39
- set `output_path` to the same path to write directly to the
39
+ Path to the output file. If ``input_data`` is a path, you can
40
+ set ``output_path`` to the same path to write directly to the
40
41
  input file. The data are written in the "events/image_bg"
41
42
  dataset in the output file.
42
43
  kernel_size: int
@@ -52,7 +53,7 @@ class BackgroundRollMed(Background):
52
53
  for faster processing.
53
54
  num_cpus: int
54
55
  Number of CPUs to use for median computation. Defaults to
55
- `dcnum.common.cpu_count()`.
56
+ :func:`dcnum.common.cpu_count`.
56
57
  """
57
58
  super().__init__(
58
59
  input_data=input_data,
@@ -89,18 +90,18 @@ class BackgroundRollMed(Background):
89
90
  # https://stackoverflow.com/questions/37705974
90
91
  self.shared_input = np.ctypeslib.as_array(
91
92
  self.shared_input_raw).reshape(batch_size + kernel_size, -1)
92
- """numpy array reshaped view on `self.shared_input_raw`.
93
+ """numpy array reshaped view on ``self.shared_input_raw``.
93
94
  The first axis enumerating the events
94
95
  """
95
96
 
96
97
  self.shared_output = np.ctypeslib.as_array(
97
98
  self.shared_output_raw).reshape(batch_size, -1)
98
- """numpy array reshaped view on `self.shared_output_raw`.
99
+ """numpy array reshaped view on ``self.shared_output_raw``.
99
100
  The first axis enumerating the events
100
101
  """
101
102
 
102
103
  self.current_batch = 0
103
- """current batch index (see `self.process` and `process_next_batch`)"""
104
+ """current batch index (see ``process`` and ``process_next_batch``)"""
104
105
 
105
106
  self.worker_counter = mp_spawn.Value("q", 0)
106
107
  """counter tracking process of workers"""
@@ -153,7 +154,7 @@ class BackgroundRollMed(Background):
153
154
  def get_slices_for_batch(self, batch_index=0):
154
155
  """Returns slices for getting the input and writing to output
155
156
 
156
- The input slice is `self.kernel_size` longer.
157
+ The input slice is ``self.kernel_size`` longer.
157
158
  """
158
159
  # We always take `kernel_size` more events from the input data,
159
160
  # but we increment with `batch_size`.
@@ -171,7 +172,7 @@ class BackgroundRollMed(Background):
171
172
  return slice_in, slice_out, output_size
172
173
 
173
174
  def map_iterator(self):
174
- """Iterates over arguments for `compute_median_for_slice`"""
175
+ """Iterates over arguments for ``compute_median_for_slice``"""
175
176
  pixels_per_job = self.image_shape[0]
176
177
  ii = 0
177
178
  while True: # TODO: turn into for-loop using data size
@@ -253,7 +254,7 @@ class WorkerRollMed(mp_spawn.Process):
253
254
  self.kernel_size = kernel_size
254
255
 
255
256
  def run(self):
256
- """Main loop of worker process (breaks when `self.counter` <0)"""
257
+ """Main loop of worker process (breaks when ``self.counter`` <0)"""
257
258
  try:
258
259
  # confirm single-threadedness (prints to log)
259
260
  confirm_single_threaded()
@@ -281,6 +282,10 @@ class WorkerRollMed(mp_spawn.Process):
281
282
  return
282
283
 
283
284
  def start(self):
285
+ """Start the worker process in a single-threaded environment
286
+
287
+ See :class:`dcnum.os_env_st.RequestSingleThreaded`.
288
+ """
284
289
  # Set all relevant os environment variables such libraries in the
285
290
  # new process only use single-threaded computation.
286
291
  with RequestSingleThreaded():
@@ -300,7 +305,7 @@ def compute_median_for_slice(shared_input, shared_output, kernel_size,
300
305
  The total size of this array is
301
306
  ``batch_size * kernel_size * number_of_pixels_in_the_image``.
302
307
  shared_output: multiprocessing.RawArray
303
- Used for storing the result. Note that the last `kernel_size`
308
+ Used for storing the result. Note that the last ``kernel_size``
304
309
  elements for each pixel in this output array are junk data
305
310
  (because it is a rolling median).
306
311
  kernel_size: int
@@ -311,10 +316,10 @@ def compute_median_for_slice(shared_input, shared_output, kernel_size,
311
316
  compute the rolling median. Note that output_size + kernel_size
312
317
  events are taken from shared_input
313
318
  job_slice: slice
314
- Now this is the important part. We can write to `shared_input`
319
+ Now this is the important part. We can write to ``shared_input``
315
320
  and shared_output from multiple processes. This slice tells
316
321
  us which part of the data we are working on. Only this slice
317
- will be edited in `shared_output`. This slice defines how
322
+ will be edited in ``shared_output``. This slice defines how
318
323
  many pixels we are looking at.
319
324
  """
320
325
  input_size = output_size + kernel_size
@@ -1,3 +1,4 @@
1
+ """Sparse median background image computation with cleansing"""
1
2
  import queue
2
3
  import time
3
4
 
@@ -25,7 +26,7 @@ class BackgroundSparseMed(Background):
25
26
  ``split_time`` seconds, but with a larger window (default kernel
26
27
  size is 200 frames instead of 100 frames).
27
28
 
28
- 1. At time stamps every `split_time` seconds, a background image is
29
+ 1. At time stamps every ``split_time`` seconds, a background image is
29
30
  computed, resulting in a background series.
30
31
  2. Cleansing: The background series is checked for images that
31
32
  contain event data using a lengthy algorithm that is documented
@@ -41,8 +42,8 @@ class BackgroundSparseMed(Background):
41
42
  the "evtens/image" dataset or an array-like object that
42
43
  behaves like an image stack (first axis enumerates events).
43
44
  output_path: pathlib.Path
44
- Path to the output file. If `input_data` is a path, you can
45
- set `output_path` to the same path to write directly to the
45
+ Path to the output file. If ``input_data`` is a path, you can
46
+ set ``output_path`` to the same path to write directly to the
46
47
  input file. The data are written in the "basin_events/image_bg"
47
48
  dataset in the output file.
48
49
  kernel_size: int
@@ -54,7 +55,7 @@ class BackgroundSparseMed(Background):
54
55
  A positive floating point value for scaling the thresholding
55
56
  operation when excluding background images from the series.
56
57
  Larger values mean more background images are excluded.
57
- Set to zero to enforce a fixed fraction via `frac_cleansing`.
58
+ Set to zero to enforce a fixed fraction via ``frac_cleansing``.
58
59
  frac_cleansing: float
59
60
  Fraction between 0 and 1 indicating how many background images
60
61
  must still be present after cleansing (in case the cleansing
@@ -67,9 +68,10 @@ class BackgroundSparseMed(Background):
67
68
  variations (e.g. flickering of the illumination source), it
68
69
  is useful to have an offset value per frame that can then be
69
70
  used in a later step to perform a more accurate background
70
- correction. This offset is computed here by taking a 20px wide
71
- slice from each frame (where the channel wall is located)
72
- and computing the median therein relative to the computed
71
+ correction. This offset is computed here as the difference
72
+ between the mean brightness of the top 20 pixel rows of each
73
+ frame (where the channel wall is located) and the mean
74
+ brightness of the same region in the corresponding
73
75
  background image. The data are written to the "bg_off" feature
74
76
  in the output file alongside "image_bg". To obtain the
75
77
  corrected background image, add "image_bg" and "bg_off".
@@ -79,7 +81,7 @@ class BackgroundSparseMed(Background):
79
81
  for faster processing.
80
82
  num_cpus: int
81
83
  Number of CPUs to use for median computation. Defaults to
82
- `dcnum.common.cpu_count()`.
84
+ :func:`dcnum.common.cpu_count`.
83
85
 
84
86
  .. versionchanged:: 0.23.5
85
87
 
@@ -174,13 +176,13 @@ class BackgroundSparseMed(Background):
174
176
  # https://stackoverflow.com/questions/37705974
175
177
  self.shared_input = np.ctypeslib.as_array(
176
178
  self.shared_input_raw).reshape(kernel_size, -1)
177
- """numpy array reshaped view on `self.shared_input_raw`.
179
+ """numpy array reshaped view on ``self.shared_input_raw``.
178
180
  The First axis enumerating the events
179
181
  """
180
182
 
181
183
  self.shared_output = np.ctypeslib.as_array(
182
184
  self.shared_output_raw).reshape(self.image_shape)
183
- """numpy array reshaped view on `self.shared_output_raw`.
185
+ """numpy array reshaped view on ``self.shared_output_raw``.
184
186
  The First axis enumerating the events
185
187
  """
186
188
 
@@ -236,7 +238,7 @@ class BackgroundSparseMed(Background):
236
238
  A positive floating point value for scaling the thresholding
237
239
  operation when excluding background images from the series.
238
240
  Larger values mean more background images are excluded.
239
- Set to 0 (default) to enforce a fixed fraction `frac_cleansing`.
241
+ Set to 0 (default) to enforce a fixed fraction ``frac_cleansing``.
240
242
  frac_cleansing: float
241
243
  Fraction between 0 and 1 indicating how many background images
242
244
  must still be present after cleansing (in case the cleansing
@@ -249,9 +251,10 @@ class BackgroundSparseMed(Background):
249
251
  variations (e.g. flickering of the illumination source), it
250
252
  is useful to have an offset value per frame that can then be
251
253
  used in a later step to perform a more accurate background
252
- correction. This offset is computed here by taking a 20px wide
253
- slice from each frame (where the channel wall is located)
254
- and computing the median therein relative to the computed
254
+ correction. This offset is computed here as the difference
255
+ between the mean brightness of the top 20 pixel rows of each
256
+ frame (where the channel wall is located) and the mean
257
+ brightness of the same region in the corresponding
255
258
  background image. The data are written to the "bg_off" feature
256
259
  in the output file alongside "image_bg". To obtain the
257
260
  corrected background image, add "image_bg" and "bg_off".
@@ -397,6 +400,21 @@ class BackgroundSparseMed(Background):
397
400
  def process_second(self,
398
401
  ii: int,
399
402
  second: float | int):
403
+ """Compute one background image of the background series
404
+
405
+ The median is computed in parallel by the worker processes
406
+ over ``kernel_size`` frames, starting at the frame closest in
407
+ time to ``second`` (shifted to earlier frames if the window
408
+ would exceed the end of the data). The result is stored in
409
+ ``self.bg_images[ii]`` and the progress is updated.
410
+
411
+ Parameters
412
+ ----------
413
+ ii: int
414
+ index of the background image in the background series
415
+ second: float | int
416
+ time [s] of the background image in the series
417
+ """
400
418
  idx_start = np.argmin(np.abs(second - self.time))
401
419
  idx_stop = idx_start + self.kernel_size
402
420
  if idx_stop >= self.image_count:
@@ -451,7 +469,7 @@ class WorkerSparseMed(mp_spawn.Process):
451
469
  self.kernel_size = kernel_size
452
470
 
453
471
  def run(self):
454
- """Main loop of worker process (breaks when `self.counter` <0)"""
472
+ """Main loop of worker process (breaks when ``self.counter`` <0)"""
455
473
  try:
456
474
  self.queue.cancel_join_thread()
457
475
  # confirm single-threadedness (prints to log)
@@ -496,6 +514,10 @@ class WorkerSparseMed(mp_spawn.Process):
496
514
  return
497
515
 
498
516
  def start(self):
517
+ """Start the worker process in a single-threaded environment
518
+
519
+ See :class:`dcnum.os_env_st.RequestSingleThreaded`.
520
+ """
499
521
  # Set all relevant os environment variables such libraries in the
500
522
  # new process only use single-threaded computation.
501
523
  with RequestSingleThreaded():