simba-uw-tf-dev 4.5.8__py3-none-any.whl → 4.7.1__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 (98) hide show
  1. simba/SimBA.py +2 -2
  2. simba/assets/.recent_projects.txt +1 -0
  3. simba/assets/icons/frames_2.png +0 -0
  4. simba/assets/lookups/tooptips.json +15 -1
  5. simba/data_processors/agg_clf_counter_mp.py +52 -53
  6. simba/data_processors/blob_location_computer.py +1 -1
  7. simba/data_processors/circling_detector.py +30 -13
  8. simba/data_processors/cuda/geometry.py +45 -27
  9. simba/data_processors/cuda/image.py +1648 -1598
  10. simba/data_processors/cuda/statistics.py +72 -26
  11. simba/data_processors/cuda/timeseries.py +1 -1
  12. simba/data_processors/cue_light_analyzer.py +5 -9
  13. simba/data_processors/egocentric_aligner.py +25 -7
  14. simba/data_processors/freezing_detector.py +55 -47
  15. simba/data_processors/kleinberg_calculator.py +61 -29
  16. simba/feature_extractors/feature_subsets.py +14 -7
  17. simba/feature_extractors/mitra_feature_extractor.py +2 -2
  18. simba/feature_extractors/straub_tail_analyzer.py +4 -6
  19. simba/labelling/standard_labeller.py +1 -1
  20. simba/mixins/config_reader.py +5 -2
  21. simba/mixins/geometry_mixin.py +22 -36
  22. simba/mixins/image_mixin.py +24 -28
  23. simba/mixins/plotting_mixin.py +28 -10
  24. simba/mixins/statistics_mixin.py +48 -11
  25. simba/mixins/timeseries_features_mixin.py +1 -1
  26. simba/mixins/train_model_mixin.py +67 -29
  27. simba/model/inference_batch.py +1 -1
  28. simba/model/yolo_seg_inference.py +3 -3
  29. simba/outlier_tools/skip_outlier_correction.py +1 -1
  30. simba/plotting/ROI_feature_visualizer_mp.py +3 -5
  31. simba/plotting/clf_validator_mp.py +4 -5
  32. simba/plotting/cue_light_visualizer.py +6 -7
  33. simba/plotting/directing_animals_visualizer_mp.py +2 -3
  34. simba/plotting/distance_plotter_mp.py +378 -378
  35. simba/plotting/frame_mergerer_ffmpeg.py +137 -196
  36. simba/plotting/gantt_creator.py +29 -10
  37. simba/plotting/gantt_creator_mp.py +96 -33
  38. simba/plotting/geometry_plotter.py +270 -272
  39. simba/plotting/heat_mapper_clf_mp.py +4 -6
  40. simba/plotting/heat_mapper_location_mp.py +2 -2
  41. simba/plotting/light_dark_box_plotter.py +2 -2
  42. simba/plotting/path_plotter_mp.py +26 -29
  43. simba/plotting/plot_clf_results_mp.py +455 -454
  44. simba/plotting/pose_plotter_mp.py +28 -29
  45. simba/plotting/probability_plot_creator_mp.py +288 -288
  46. simba/plotting/roi_plotter_mp.py +31 -31
  47. simba/plotting/single_run_model_validation_video_mp.py +427 -427
  48. simba/plotting/spontaneous_alternation_plotter.py +2 -3
  49. simba/plotting/yolo_pose_track_visualizer.py +32 -27
  50. simba/plotting/yolo_pose_visualizer.py +35 -36
  51. simba/plotting/yolo_seg_visualizer.py +2 -3
  52. simba/pose_importers/simba_blob_importer.py +3 -3
  53. simba/roi_tools/roi_aggregate_stats_mp.py +5 -4
  54. simba/roi_tools/roi_clf_calculator_mp.py +4 -4
  55. simba/sandbox/analyze_runtimes.py +30 -0
  56. simba/sandbox/cuda/egocentric_rotator.py +374 -0
  57. simba/sandbox/get_cpu_pool.py +5 -0
  58. simba/sandbox/proboscis_to_tip.py +28 -0
  59. simba/sandbox/test_directionality.py +47 -0
  60. simba/sandbox/test_nonstatic_directionality.py +27 -0
  61. simba/sandbox/test_pycharm_cuda.py +51 -0
  62. simba/sandbox/test_simba_install.py +41 -0
  63. simba/sandbox/test_static_directionality.py +26 -0
  64. simba/sandbox/test_static_directionality_2d.py +26 -0
  65. simba/sandbox/verify_env.py +42 -0
  66. simba/third_party_label_appenders/transform/coco_keypoints_to_yolo.py +3 -3
  67. simba/third_party_label_appenders/transform/coco_keypoints_to_yolo_bbox.py +2 -2
  68. simba/ui/pop_ups/clf_add_remove_print_pop_up.py +37 -30
  69. simba/ui/pop_ups/clf_plot_pop_up.py +2 -2
  70. simba/ui/pop_ups/egocentric_alignment_pop_up.py +20 -21
  71. simba/ui/pop_ups/fsttc_pop_up.py +27 -25
  72. simba/ui/pop_ups/gantt_pop_up.py +31 -6
  73. simba/ui/pop_ups/interpolate_pop_up.py +2 -4
  74. simba/ui/pop_ups/kleinberg_pop_up.py +39 -40
  75. simba/ui/pop_ups/multiple_videos_to_frames_popup.py +10 -11
  76. simba/ui/pop_ups/single_video_to_frames_popup.py +10 -10
  77. simba/ui/pop_ups/video_processing_pop_up.py +186 -174
  78. simba/ui/tkinter_functions.py +10 -1
  79. simba/utils/custom_feature_extractor.py +1 -1
  80. simba/utils/data.py +90 -14
  81. simba/utils/enums.py +1 -0
  82. simba/utils/errors.py +441 -440
  83. simba/utils/lookups.py +1203 -1203
  84. simba/utils/printing.py +124 -124
  85. simba/utils/read_write.py +3769 -3721
  86. simba/utils/yolo.py +10 -1
  87. simba/video_processors/blob_tracking_executor.py +2 -2
  88. simba/video_processors/clahe_ui.py +66 -23
  89. simba/video_processors/egocentric_video_rotator.py +46 -44
  90. simba/video_processors/multi_cropper.py +1 -1
  91. simba/video_processors/video_processing.py +5264 -5300
  92. simba/video_processors/videos_to_frames.py +43 -32
  93. {simba_uw_tf_dev-4.5.8.dist-info → simba_uw_tf_dev-4.7.1.dist-info}/METADATA +4 -3
  94. {simba_uw_tf_dev-4.5.8.dist-info → simba_uw_tf_dev-4.7.1.dist-info}/RECORD +98 -86
  95. {simba_uw_tf_dev-4.5.8.dist-info → simba_uw_tf_dev-4.7.1.dist-info}/LICENSE +0 -0
  96. {simba_uw_tf_dev-4.5.8.dist-info → simba_uw_tf_dev-4.7.1.dist-info}/WHEEL +0 -0
  97. {simba_uw_tf_dev-4.5.8.dist-info → simba_uw_tf_dev-4.7.1.dist-info}/entry_points.txt +0 -0
  98. {simba_uw_tf_dev-4.5.8.dist-info → simba_uw_tf_dev-4.7.1.dist-info}/top_level.txt +0 -0
simba/utils/printing.py CHANGED
@@ -1,124 +1,124 @@
1
- __author__ = "Simon Nilsson; sronilsson@gmail.com"
2
-
3
- try:
4
- from typing import Literal
5
- except:
6
- from typing_extensions import Literal
7
-
8
-
9
- import logging
10
- import time
11
- from typing import Optional
12
-
13
- from simba.utils.enums import Defaults, TagNames
14
-
15
-
16
- def stdout_success(msg: str, source: Optional[str] = "", elapsed_time: Optional[str] = None) -> None:
17
- """
18
- Helper to parse msg of completed operation to SimBA main interface.
19
-
20
- :param str msg: Message to be parsed.
21
- :param Optional[str] source: Optional string indicating the source method or function of the msg for logging.
22
- :param Optional[str] elapsed_time: Optional string indicating the runtime of the completed operation.
23
- :return None:
24
- """
25
-
26
- log_event(logger_name=f"{source}.{stdout_success.__name__}", log_type=TagNames.COMPLETE.value, msg=msg)
27
- if elapsed_time:
28
- print(f"SIMBA COMPLETE: {msg} (elapsed time: {elapsed_time}s) {Defaults.STR_SPLIT_DELIMITER.value}{TagNames.COMPLETE.value}")
29
- else:
30
- print(f"SIMBA COMPLETE: {msg} {Defaults.STR_SPLIT_DELIMITER.value}{TagNames.COMPLETE.value}")
31
-
32
-
33
- def stdout_warning(msg: str, elapsed_time: Optional[str] = None) -> None:
34
- """
35
- Helper to parse warning msg to SimBA main interface.
36
-
37
- :param str msg: Message to be parsed.
38
- :param Optional[str] source: Optional string indicating the source method or function of the msg for logging.
39
- :param elapsed_time: Optional string indicating the runtime.
40
- :return None:
41
- """
42
-
43
- if elapsed_time:
44
- print(f"SIMBA WARNING: {msg} (elapsed time: {elapsed_time}s) {Defaults.STR_SPLIT_DELIMITER.value}{TagNames.WARNING.value}")
45
- else:
46
- print(f"SIMBA WARNING: {msg} {Defaults.STR_SPLIT_DELIMITER.value}{TagNames.WARNING.value}")
47
-
48
-
49
- def stdout_trash(msg: str, source: Optional[str] = "", elapsed_time: Optional[str] = None) -> None:
50
- """
51
- Helper to parse msg of delete operation to SimBA main interface.
52
-
53
- :param str msg: Message to be parsed.
54
- :param Optional[str] source: Optional string indicating the source method or function of the operation for logging.
55
- :param elapsed_time: Optional string indicating the runtime.
56
- :return None:
57
- """
58
-
59
- log_event(logger_name=f"{source}.{stdout_trash.__name__}", log_type=TagNames.TRASH.value, msg=msg)
60
- if elapsed_time:
61
- print(f"SIMBA COMPLETE: {msg} (elapsed time: {elapsed_time}s) {Defaults.STR_SPLIT_DELIMITER.value}{TagNames.TRASH.value}")
62
- else:
63
- print(f"SIMBA COMPLETE: {msg} {Defaults.STR_SPLIT_DELIMITER.value}{TagNames.TRASH.value}")
64
-
65
-
66
- def stdout_information(msg: str, source: Optional[str] = "", elapsed_time: Optional[str] = None) -> None:
67
- """
68
- Helper to parse information msg to SimBA main interface. E.g., how many monitors and their resolutions which is available.
69
-
70
- :param str msg: Message to be parsed.
71
- :param Optional[str] source: Optional string indicating the source method or function of the operation for logging.
72
- :param elapsed_time: Optional string indicating the runtime.
73
- :return None:
74
- """
75
-
76
- log_event(logger_name=f"{source}.{stdout_trash.__name__}", log_type=TagNames.INFORMATION.value, msg=msg)
77
- if elapsed_time:
78
- print(f"SIMBA COMPLETE: {msg} (elapsed time: {elapsed_time}s) {Defaults.STR_SPLIT_DELIMITER.value}{TagNames.INFORMATION.value}")
79
- else:
80
- print(f"{msg} {Defaults.STR_SPLIT_DELIMITER.value}{TagNames.INFORMATION.value}")
81
-
82
-
83
- class SimbaTimer(object):
84
- """Timer class for keeping track of start and end-times of calls"""
85
-
86
- def __init__(self, start: bool = False):
87
- if start:
88
- self.start_timer()
89
-
90
- def start_timer(self):
91
- self.timer = time.time()
92
-
93
- def stop_timer(self):
94
- if not hasattr(self, "timer"):
95
- self.elapsed_time = -1
96
- self.elapsed_time_str = "-1"
97
- else:
98
- self.elapsed_time = round(time.time() - self.timer, 4)
99
- self.elapsed_time_str = str(self.elapsed_time)
100
-
101
-
102
- def log_event(logger_name: str, log_type: Literal["CLASS_INIT", "error", "warning"], msg: str):
103
- logger = logging.getLogger(str(logger_name))
104
- if log_type == TagNames.CLASS_INIT.value:
105
- logger.info(f"{TagNames.CLASS_INIT.value}||{msg}")
106
- elif log_type == TagNames.ERROR.value:
107
- logger.error(f"{TagNames.ERROR.value}||{msg}")
108
- elif log_type == TagNames.WARNING.value:
109
- logger.warning(f"{TagNames.WARNING.value}||{msg}")
110
- elif log_type == TagNames.TRASH.value:
111
- logger.info(f"{TagNames.TRASH.value}||{msg}")
112
- elif log_type == TagNames.COMPLETE.value:
113
- logger.info(f"{TagNames.COMPLETE.value}||{msg}")
114
-
115
-
116
- def perform_timing(func):
117
- def decorator(*args, **kwargs):
118
- timer = SimbaTimer(start=True)
119
- results = func(*args, **kwargs, _timer=timer)
120
- timer.stop_timer()
121
- results["timer"] = timer.elapsed_time_str
122
- return results
123
-
124
- return decorator
1
+ __author__ = "Simon Nilsson; sronilsson@gmail.com"
2
+
3
+ try:
4
+ from typing import Literal
5
+ except:
6
+ from typing_extensions import Literal
7
+
8
+ import logging
9
+ import time
10
+ from datetime import datetime
11
+ from typing import Optional
12
+
13
+ from simba.utils.enums import Defaults, TagNames
14
+
15
+
16
+ def stdout_success(msg: str, source: Optional[str] = "", elapsed_time: Optional[str] = None) -> None:
17
+ """
18
+ Helper to parse msg of completed operation to SimBA main interface.
19
+
20
+ :param str msg: Message to be parsed.
21
+ :param Optional[str] source: Optional string indicating the source method or function of the msg for logging.
22
+ :param Optional[str] elapsed_time: Optional string indicating the runtime of the completed operation.
23
+ :return None:
24
+ """
25
+
26
+ log_event(logger_name=f"{source}.{stdout_success.__name__}", log_type=TagNames.COMPLETE.value, msg=msg)
27
+ if elapsed_time:
28
+ print(f"[{datetime.now().strftime('%H:%M:%S')}] SIMBA COMPLETE: {msg} (elapsed time: {elapsed_time}s) {Defaults.STR_SPLIT_DELIMITER.value}{TagNames.COMPLETE.value}")
29
+ else:
30
+ print(f"[{datetime.now().strftime('%H:%M:%S')}] SIMBA COMPLETE: {msg} {Defaults.STR_SPLIT_DELIMITER.value}{TagNames.COMPLETE.value}")
31
+
32
+
33
+ def stdout_warning(msg: str, elapsed_time: Optional[str] = None) -> None:
34
+ """
35
+ Helper to parse warning msg to SimBA main interface.
36
+
37
+ :param str msg: Message to be parsed.
38
+ :param Optional[str] source: Optional string indicating the source method or function of the msg for logging.
39
+ :param elapsed_time: Optional string indicating the runtime.
40
+ :return None:
41
+ """
42
+
43
+ if elapsed_time:
44
+ print(f"[{datetime.now().strftime('%H:%M:%S')}] SIMBA WARNING: {msg} (elapsed time: {elapsed_time}s) {Defaults.STR_SPLIT_DELIMITER.value}{TagNames.WARNING.value}")
45
+ else:
46
+ print(f"[{datetime.now().strftime('%H:%M:%S')}] SIMBA WARNING: {msg} {Defaults.STR_SPLIT_DELIMITER.value}{TagNames.WARNING.value}")
47
+
48
+
49
+ def stdout_trash(msg: str, source: Optional[str] = "", elapsed_time: Optional[str] = None) -> None:
50
+ """
51
+ Helper to parse msg of delete operation to SimBA main interface.
52
+
53
+ :param str msg: Message to be parsed.
54
+ :param Optional[str] source: Optional string indicating the source method or function of the operation for logging.
55
+ :param elapsed_time: Optional string indicating the runtime.
56
+ :return None:
57
+ """
58
+
59
+ log_event(logger_name=f"{source}.{stdout_trash.__name__}", log_type=TagNames.TRASH.value, msg=msg)
60
+ if elapsed_time:
61
+ print(f"[{datetime.now().strftime('%H:%M:%S')}] SIMBA COMPLETE: {msg} (elapsed time: {elapsed_time}s) {Defaults.STR_SPLIT_DELIMITER.value}{TagNames.TRASH.value}")
62
+ else:
63
+ print(f"[{datetime.now().strftime('%H:%M:%S')}] SIMBA COMPLETE: {msg} {Defaults.STR_SPLIT_DELIMITER.value}{TagNames.TRASH.value}")
64
+
65
+
66
+ def stdout_information(msg: str, source: Optional[str] = "", elapsed_time: Optional[str] = None) -> None:
67
+ """
68
+ Helper to parse information msg to SimBA main interface. E.g., how many monitors and their resolutions which is available.
69
+
70
+ :param str msg: Message to be parsed.
71
+ :param Optional[str] source: Optional string indicating the source method or function of the operation for logging.
72
+ :param elapsed_time: Optional string indicating the runtime.
73
+ :return None:
74
+ """
75
+
76
+ log_event(logger_name=f"{source}.{stdout_trash.__name__}", log_type=TagNames.INFORMATION.value, msg=msg)
77
+ if elapsed_time:
78
+ print(f"[{datetime.now().strftime('%H:%M:%S')}] SIMBA COMPLETE: {msg} (elapsed time: {elapsed_time}s) {Defaults.STR_SPLIT_DELIMITER.value}{TagNames.INFORMATION.value}")
79
+ else:
80
+ print(f"[{datetime.now().strftime('%H:%M:%S')}] {msg} {Defaults.STR_SPLIT_DELIMITER.value}{TagNames.INFORMATION.value}")
81
+
82
+
83
+ class SimbaTimer(object):
84
+ """Timer class for keeping track of start and end-times of calls"""
85
+
86
+ def __init__(self, start: bool = False):
87
+ if start:
88
+ self.start_timer()
89
+
90
+ def start_timer(self):
91
+ self.timer = time.time()
92
+
93
+ def stop_timer(self):
94
+ if not hasattr(self, "timer"):
95
+ self.elapsed_time = -1
96
+ self.elapsed_time_str = "-1"
97
+ else:
98
+ self.elapsed_time = round(time.time() - self.timer, 4)
99
+ self.elapsed_time_str = str(self.elapsed_time)
100
+
101
+
102
+ def log_event(logger_name: str, log_type: Literal["CLASS_INIT", "error", "warning"], msg: str):
103
+ logger = logging.getLogger(str(logger_name))
104
+ if log_type == TagNames.CLASS_INIT.value:
105
+ logger.info(f"{TagNames.CLASS_INIT.value}||{msg}")
106
+ elif log_type == TagNames.ERROR.value:
107
+ logger.error(f"{TagNames.ERROR.value}||{msg}")
108
+ elif log_type == TagNames.WARNING.value:
109
+ logger.warning(f"{TagNames.WARNING.value}||{msg}")
110
+ elif log_type == TagNames.TRASH.value:
111
+ logger.info(f"{TagNames.TRASH.value}||{msg}")
112
+ elif log_type == TagNames.COMPLETE.value:
113
+ logger.info(f"{TagNames.COMPLETE.value}||{msg}")
114
+
115
+
116
+ def perform_timing(func):
117
+ def decorator(*args, **kwargs):
118
+ timer = SimbaTimer(start=True)
119
+ results = func(*args, **kwargs, _timer=timer)
120
+ timer.stop_timer()
121
+ results["timer"] = timer.elapsed_time_str
122
+ return results
123
+
124
+ return decorator