celldetective 1.4.2__py3-none-any.whl → 1.5.0b1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (152) hide show
  1. celldetective/__init__.py +25 -0
  2. celldetective/__main__.py +62 -43
  3. celldetective/_version.py +1 -1
  4. celldetective/extra_properties.py +477 -399
  5. celldetective/filters.py +192 -97
  6. celldetective/gui/InitWindow.py +541 -411
  7. celldetective/gui/__init__.py +0 -15
  8. celldetective/gui/about.py +44 -39
  9. celldetective/gui/analyze_block.py +120 -84
  10. celldetective/gui/base/__init__.py +0 -0
  11. celldetective/gui/base/channel_norm_generator.py +335 -0
  12. celldetective/gui/base/components.py +249 -0
  13. celldetective/gui/base/feature_choice.py +92 -0
  14. celldetective/gui/base/figure_canvas.py +52 -0
  15. celldetective/gui/base/list_widget.py +133 -0
  16. celldetective/gui/{styles.py → base/styles.py} +92 -36
  17. celldetective/gui/base/utils.py +33 -0
  18. celldetective/gui/base_annotator.py +900 -767
  19. celldetective/gui/classifier_widget.py +6 -22
  20. celldetective/gui/configure_new_exp.py +777 -671
  21. celldetective/gui/control_panel.py +635 -524
  22. celldetective/gui/dynamic_progress.py +449 -0
  23. celldetective/gui/event_annotator.py +2023 -1662
  24. celldetective/gui/generic_signal_plot.py +1292 -944
  25. celldetective/gui/gui_utils.py +899 -1289
  26. celldetective/gui/interactions_block.py +658 -0
  27. celldetective/gui/interactive_timeseries_viewer.py +447 -0
  28. celldetective/gui/json_readers.py +48 -15
  29. celldetective/gui/layouts/__init__.py +5 -0
  30. celldetective/gui/layouts/background_model_free_layout.py +537 -0
  31. celldetective/gui/layouts/channel_offset_layout.py +134 -0
  32. celldetective/gui/layouts/local_correction_layout.py +91 -0
  33. celldetective/gui/layouts/model_fit_layout.py +372 -0
  34. celldetective/gui/layouts/operation_layout.py +68 -0
  35. celldetective/gui/layouts/protocol_designer_layout.py +96 -0
  36. celldetective/gui/pair_event_annotator.py +3130 -2435
  37. celldetective/gui/plot_measurements.py +586 -267
  38. celldetective/gui/plot_signals_ui.py +724 -506
  39. celldetective/gui/preprocessing_block.py +395 -0
  40. celldetective/gui/process_block.py +1678 -1831
  41. celldetective/gui/seg_model_loader.py +580 -473
  42. celldetective/gui/settings/__init__.py +0 -7
  43. celldetective/gui/settings/_cellpose_model_params.py +181 -0
  44. celldetective/gui/settings/_event_detection_model_params.py +95 -0
  45. celldetective/gui/settings/_segmentation_model_params.py +159 -0
  46. celldetective/gui/settings/_settings_base.py +77 -65
  47. celldetective/gui/settings/_settings_event_model_training.py +752 -526
  48. celldetective/gui/settings/_settings_measurements.py +1133 -964
  49. celldetective/gui/settings/_settings_neighborhood.py +574 -488
  50. celldetective/gui/settings/_settings_segmentation_model_training.py +779 -564
  51. celldetective/gui/settings/_settings_signal_annotator.py +329 -305
  52. celldetective/gui/settings/_settings_tracking.py +1304 -1094
  53. celldetective/gui/settings/_stardist_model_params.py +98 -0
  54. celldetective/gui/survival_ui.py +422 -312
  55. celldetective/gui/tableUI.py +1665 -1701
  56. celldetective/gui/table_ops/_maths.py +295 -0
  57. celldetective/gui/table_ops/_merge_groups.py +140 -0
  58. celldetective/gui/table_ops/_merge_one_hot.py +95 -0
  59. celldetective/gui/table_ops/_query_table.py +43 -0
  60. celldetective/gui/table_ops/_rename_col.py +44 -0
  61. celldetective/gui/thresholds_gui.py +382 -179
  62. celldetective/gui/viewers/__init__.py +0 -0
  63. celldetective/gui/viewers/base_viewer.py +700 -0
  64. celldetective/gui/viewers/channel_offset_viewer.py +331 -0
  65. celldetective/gui/viewers/contour_viewer.py +394 -0
  66. celldetective/gui/viewers/size_viewer.py +153 -0
  67. celldetective/gui/viewers/spot_detection_viewer.py +341 -0
  68. celldetective/gui/viewers/threshold_viewer.py +309 -0
  69. celldetective/gui/workers.py +403 -126
  70. celldetective/log_manager.py +92 -0
  71. celldetective/measure.py +1895 -1478
  72. celldetective/napari/__init__.py +0 -0
  73. celldetective/napari/utils.py +1025 -0
  74. celldetective/neighborhood.py +1914 -1448
  75. celldetective/preprocessing.py +1620 -1220
  76. celldetective/processes/__init__.py +0 -0
  77. celldetective/processes/background_correction.py +271 -0
  78. celldetective/processes/compute_neighborhood.py +894 -0
  79. celldetective/processes/detect_events.py +246 -0
  80. celldetective/processes/downloader.py +137 -0
  81. celldetective/processes/measure_cells.py +565 -0
  82. celldetective/processes/segment_cells.py +760 -0
  83. celldetective/processes/track_cells.py +435 -0
  84. celldetective/processes/train_segmentation_model.py +694 -0
  85. celldetective/processes/train_signal_model.py +265 -0
  86. celldetective/processes/unified_process.py +292 -0
  87. celldetective/regionprops/_regionprops.py +358 -317
  88. celldetective/relative_measurements.py +987 -710
  89. celldetective/scripts/measure_cells.py +313 -212
  90. celldetective/scripts/measure_relative.py +90 -46
  91. celldetective/scripts/segment_cells.py +165 -104
  92. celldetective/scripts/segment_cells_thresholds.py +96 -68
  93. celldetective/scripts/track_cells.py +198 -149
  94. celldetective/scripts/train_segmentation_model.py +324 -201
  95. celldetective/scripts/train_signal_model.py +87 -45
  96. celldetective/segmentation.py +844 -749
  97. celldetective/signals.py +3514 -2861
  98. celldetective/tracking.py +30 -15
  99. celldetective/utils/__init__.py +0 -0
  100. celldetective/utils/cellpose_utils/__init__.py +133 -0
  101. celldetective/utils/color_mappings.py +42 -0
  102. celldetective/utils/data_cleaning.py +630 -0
  103. celldetective/utils/data_loaders.py +450 -0
  104. celldetective/utils/dataset_helpers.py +207 -0
  105. celldetective/utils/downloaders.py +235 -0
  106. celldetective/utils/event_detection/__init__.py +8 -0
  107. celldetective/utils/experiment.py +1782 -0
  108. celldetective/utils/image_augmenters.py +308 -0
  109. celldetective/utils/image_cleaning.py +74 -0
  110. celldetective/utils/image_loaders.py +926 -0
  111. celldetective/utils/image_transforms.py +335 -0
  112. celldetective/utils/io.py +62 -0
  113. celldetective/utils/mask_cleaning.py +348 -0
  114. celldetective/utils/mask_transforms.py +5 -0
  115. celldetective/utils/masks.py +184 -0
  116. celldetective/utils/maths.py +351 -0
  117. celldetective/utils/model_getters.py +325 -0
  118. celldetective/utils/model_loaders.py +296 -0
  119. celldetective/utils/normalization.py +380 -0
  120. celldetective/utils/parsing.py +465 -0
  121. celldetective/utils/plots/__init__.py +0 -0
  122. celldetective/utils/plots/regression.py +53 -0
  123. celldetective/utils/resources.py +34 -0
  124. celldetective/utils/stardist_utils/__init__.py +104 -0
  125. celldetective/utils/stats.py +90 -0
  126. celldetective/utils/types.py +21 -0
  127. {celldetective-1.4.2.dist-info → celldetective-1.5.0b1.dist-info}/METADATA +1 -1
  128. celldetective-1.5.0b1.dist-info/RECORD +187 -0
  129. {celldetective-1.4.2.dist-info → celldetective-1.5.0b1.dist-info}/WHEEL +1 -1
  130. tests/gui/test_new_project.py +129 -117
  131. tests/gui/test_project.py +127 -79
  132. tests/test_filters.py +39 -15
  133. tests/test_notebooks.py +8 -0
  134. tests/test_tracking.py +232 -13
  135. tests/test_utils.py +123 -77
  136. celldetective/gui/base_components.py +0 -23
  137. celldetective/gui/layouts.py +0 -1602
  138. celldetective/gui/processes/compute_neighborhood.py +0 -594
  139. celldetective/gui/processes/downloader.py +0 -111
  140. celldetective/gui/processes/measure_cells.py +0 -360
  141. celldetective/gui/processes/segment_cells.py +0 -499
  142. celldetective/gui/processes/track_cells.py +0 -303
  143. celldetective/gui/processes/train_segmentation_model.py +0 -270
  144. celldetective/gui/processes/train_signal_model.py +0 -108
  145. celldetective/gui/table_ops/merge_groups.py +0 -118
  146. celldetective/gui/viewers.py +0 -1354
  147. celldetective/io.py +0 -3663
  148. celldetective/utils.py +0 -3108
  149. celldetective-1.4.2.dist-info/RECORD +0 -123
  150. {celldetective-1.4.2.dist-info → celldetective-1.5.0b1.dist-info}/entry_points.txt +0 -0
  151. {celldetective-1.4.2.dist-info → celldetective-1.5.0b1.dist-info}/licenses/LICENSE +0 -0
  152. {celldetective-1.4.2.dist-info → celldetective-1.5.0b1.dist-info}/top_level.txt +0 -0
celldetective/__init__.py CHANGED
@@ -1 +1,26 @@
1
1
  from ._version import __version__
2
+ import os
3
+ from .log_manager import setup_global_logging, get_logger
4
+
5
+ # Define default log path in user home
6
+ USER_LOG_DIR = os.path.join(os.path.expanduser("~"), ".celldetective", "logs")
7
+ GLOBAL_LOG_FILE = os.path.join(USER_LOG_DIR, "celldetective.log")
8
+
9
+ # Setup logging
10
+ setup_global_logging(log_file=GLOBAL_LOG_FILE)
11
+
12
+ # Expose logger
13
+ logger = get_logger()
14
+
15
+
16
+ def get_software_location() -> str:
17
+ """
18
+ Get the installation folder of celldetective.
19
+
20
+ Returns
21
+ -------
22
+ str
23
+ Path to the celldetective installation folder.
24
+ """
25
+
26
+ return rf"{os.path.split(os.path.dirname(os.path.realpath(__file__)))[0]}"
celldetective/__main__.py CHANGED
@@ -1,66 +1,85 @@
1
1
  #!/usr/bin/env python3
2
2
  import sys
3
+ import os
4
+
5
+ os.environ["KMP_DUPLICATE_LIB_OK"] = "TRUE"
6
+
3
7
  from PyQt5.QtWidgets import QApplication, QSplashScreen
4
8
  from PyQt5.QtGui import QPixmap
5
9
  from os import sep
6
- from celldetective.utils import get_software_location
7
- from time import time, sleep
8
10
 
9
- #os.environ['QT_DEBUG_PLUGINS'] = '1'
11
+ # os.environ['QT_DEBUG_PLUGINS'] = '1'
10
12
 
11
13
  if __name__ == "__main__":
12
14
 
13
- splash=True
14
- print('Loading the libraries...')
15
+ splash = True
16
+ from celldetective import logger
17
+ from celldetective import get_software_location
18
+
19
+ logger.info("Loading the libraries...")
20
+
21
+ App = QApplication(sys.argv)
22
+ App.setStyle("Fusion")
23
+
24
+ software_location = get_software_location()
15
25
 
16
- App = QApplication(sys.argv)
17
- App.setStyle("Fusion")
26
+ if splash:
27
+ splash_pix = QPixmap(
28
+ sep.join([software_location, "celldetective", "icons", "splash.png"])
29
+ )
30
+ splash = QSplashScreen(splash_pix)
31
+ splash.setMask(splash_pix.mask())
32
+ splash.show()
33
+ App.processEvents()
18
34
 
19
- software_location = get_software_location()
35
+ # Update check in background
36
+ def check_update():
37
+ try:
38
+ import requests
39
+ import re
40
+ from celldetective import __version__
20
41
 
21
- if splash:
22
- start = time()
23
- splash_pix = QPixmap(sep.join([software_location,'celldetective','icons','splash.png']))
24
- splash = QSplashScreen(splash_pix)
25
- splash.setMask(splash_pix.mask())
26
- splash.show()
27
- #App.processEvents(QEventLoop.AllEvents, 300)
28
- while time() - start < 1:
29
- sleep(0.001)
30
- App.processEvents()
42
+ package = "celldetective"
43
+ response = requests.get(f"https://pypi.org/pypi/{package}/json", timeout=5)
44
+ latest_version = response.json()["info"]["version"]
31
45
 
32
- try:
33
-
34
- import requests
35
- import re
36
- from celldetective import __version__
46
+ latest_version_num = re.sub("[^0-9]", "", latest_version)
47
+ current_version_num = re.sub("[^0-9]", "", __version__)
37
48
 
38
- package = 'celldetective'
39
- response = requests.get(f'https://pypi.org/pypi/{package}/json')
40
- latest_version = response.json()['info']['version']
49
+ if len(latest_version_num) != len(current_version_num):
50
+ max_length = max([len(latest_version_num), len(current_version_num)])
51
+ latest_version_num = int(
52
+ latest_version_num.zfill(max_length - len(latest_version_num))
53
+ )
54
+ current_version_num = int(
55
+ current_version_num.zfill(max_length - len(current_version_num))
56
+ )
41
57
 
42
- latest_version_num = re.sub('[^0-9]','', latest_version)
43
- current_version_num = re.sub('[^0-9]','',__version__)
58
+ if latest_version_num > current_version_num:
59
+ logger.warning(
60
+ "Update is available...\nPlease update using `pip install --upgrade celldetective`..."
61
+ )
62
+ except Exception as e:
63
+ logger.error(
64
+ f"Update check failed... Please check your internet connection: {e}"
65
+ )
44
66
 
45
- if len(latest_version_num)!=len(current_version_num):
46
- max_length = max([len(latest_version_num),len(current_version_num)])
47
- latest_version_num = int(latest_version_num.zfill(max_length - len(latest_version_num)))
48
- current_version_num = int(current_version_num.zfill(max_length - len(current_version_num)))
67
+ import threading
49
68
 
50
- if latest_version_num > current_version_num:
51
- print('Update is available...\nPlease update using `pip install --upgrade celldetective`...')
52
-
53
- except Exception as e:
69
+ update_thread = threading.Thread(target=check_update)
70
+ update_thread.daemon = True
71
+ update_thread.start()
54
72
 
55
- print(f"{e=}")
73
+ from celldetective.gui.InitWindow import AppInitWindow
56
74
 
57
- from celldetective.gui.InitWindow import AppInitWindow
75
+ logger.info("Libraries successfully loaded...")
58
76
 
59
- print('Libraries successfully loaded...')
77
+ from celldetective.gui.base.utils import center_window
60
78
 
61
- window = AppInitWindow(App, software_location=software_location)
79
+ window = AppInitWindow(App, software_location=software_location)
80
+ center_window(window)
62
81
 
63
- if splash:
64
- splash.finish(window)
82
+ if splash:
83
+ splash.finish(window)
65
84
 
66
- sys.exit(App.exec())
85
+ sys.exit(App.exec())
celldetective/_version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "1.4.2"
1
+ __version__ = "1.5.0b1"