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
@@ -54,15 +54,15 @@ class COCOKeypoints2Yolo:
54
54
  :return: None
55
55
 
56
56
  :example:
57
- >>> runner = COCOKeypoints2Yolo(coco_path=r"D:\cvat_annotations\frames\coco_keypoints_1\s1\annotations\s1.json", img_dir=r"D:\cvat_annotations\frames\simon", save_dir=r"D:\cvat_annotations\frames\yolo_keypoints", clahe=True)
57
+ >>> runner = COCOKeypoints2Yolo(coco_path=r"D:/cvat_annotations/frames/coco_keypoints_1/s1/annotations/s1.json", img_dir=r"D:/cvat_annotations/frames/simon", save_dir=r"D:/cvat_annotations/frames/yolo_keypoints", clahe=True)
58
58
  >>> runner.run()
59
59
 
60
60
  :example II:
61
- >>> runner = COCOKeypoints2Yolo(coco_path=r"D:\cvat_annotations\frames\coco_keypoints_1\merged.json", img_dir=r"D:\cvat_annotations\frames", save_dir=r"D:\cvat_annotations\frames\yolo", clahe=False)
61
+ >>> runner = COCOKeypoints2Yolo(coco_path=r"D:/cvat_annotations/frames/coco_keypoints_1/merged.json", img_dir=r"D:/cvat_annotations/frames", save_dir=r"D:/cvat_annotations/frames/yolo", clahe=False)
62
62
  >>> runner.run()
63
63
 
64
64
  :example III:
65
- >>> runner = COCOKeypoints2Yolo(coco_path=r"E:\netholabs_videos\mosaics\subset\to_annotate\2d_mosaic_batch_1.json", img_dir=r"E:\netholabs_videos\mosaics\subset\to_annotate", save_dir=r"E:\netholabs_videos\mosaics\yolo_mdl", clahe=False)
65
+ >>> runner = COCOKeypoints2Yolo(coco_path=r"E:/netholabs_videos/mosaics/subset/to_annotate/2d_mosaic_batch_1.json", img_dir=r"E:/netholabs_videos/mosaics/subset/to_annotate", save_dir=r"E:/netholabs_videos/mosaics/yolo_mdl", clahe=False)
66
66
  >>> runner.run()
67
67
 
68
68
  :references:
@@ -58,11 +58,11 @@ class COCOKeypoints2YoloBbox:
58
58
  :return: None
59
59
 
60
60
  :example:
61
- >>> runner = COCOKeypoints2Yolo(coco_path=r"D:\cvat_annotations\frames\coco_keypoints_1\s1\annotations\s1.json", img_dir=r"D:\cvat_annotations\frames\simon", save_dir=r"D:\cvat_annotations\frames\yolo_keypoints", clahe=True)
61
+ >>> runner = COCOKeypoints2YoloBbox(coco_path=r"D:/cvat_annotations/frames/coco_keypoints_1/s1/annotations/s1.json", img_dir=r"D:/cvat_annotations/frames/simon", save_dir=r"D:/cvat_annotations/frames/yolo_keypoints", clahe=True)
62
62
  >>> runner.run()
63
63
 
64
64
  :example II:
65
- >>> runner = COCOKeypoints2Yolo(coco_path=r"D:\cvat_annotations\frames\coco_keypoints_1\merged.json", img_dir=r"D:\cvat_annotations\frames", save_dir=r"D:\cvat_annotations\frames\yolo", clahe=False)
65
+ >>> runner = COCOKeypoints2YoloBbox(coco_path=r"D:/cvat_annotations/frames/coco_keypoints_1/merged.json", img_dir=r"D:/cvat_annotations/frames", save_dir=r"D:/cvat_annotations/frames/yolo", clahe=False)
66
66
  >>> runner.run()
67
67
 
68
68
  :references:
@@ -7,21 +7,22 @@ from typing import Union
7
7
  from simba.mixins.config_reader import ConfigReader
8
8
  from simba.mixins.pop_up_mixin import PopUpMixin
9
9
  from simba.pose_processors.pose_reset import PoseResetter
10
- from simba.ui.tkinter_functions import (CreateLabelFrameWithIcon, DropDownMenu,
11
- Entry_Box, FileSelect, SimbaButton,
10
+ from simba.ui.tkinter_functions import (CreateLabelFrameWithIcon, Entry_Box,
11
+ FileSelect, SimbaButton, SimBADropDown,
12
12
  TwoOptionQuestionPopUp)
13
13
  from simba.utils.checks import check_str
14
14
  from simba.utils.enums import ConfigKey, Keys, Links
15
- from simba.utils.errors import DuplicationError
15
+ from simba.utils.errors import DuplicationError, NoDataError
16
16
  from simba.utils.printing import stdout_success, stdout_trash
17
17
  from simba.utils.read_write import tabulate_clf_info
18
18
 
19
19
 
20
20
  class AddClfPopUp(PopUpMixin, ConfigReader):
21
- def __init__(self, config_path: Union[str, os.PathLike]):
22
- PopUpMixin.__init__(self, config_path=config_path, title="ADD CLASSIFIER")
21
+ def __init__(self,
22
+ config_path: Union[str, os.PathLike]):
23
+ PopUpMixin.__init__(self, config_path=config_path, title="ADD CLASSIFIER", icon='plus')
23
24
  ConfigReader.__init__(self, config_path=config_path, read_video_info=False)
24
- self.clf_eb = Entry_Box(self.main_frm, "CLASSIFIER NAME:", "15")
25
+ self.clf_eb = Entry_Box(parent=self.main_frm, fileDescription="CLASSIFIER NAME:", labelwidth=25, entry_box_width=30, justify='center', img='decision_tree_small')
25
26
  add_btn = SimbaButton(parent=self.main_frm, txt="ADD CLASSIFIER", cmd=self.run, img='rocket')
26
27
  self.clf_eb.grid(row=0, column=0, sticky=NW)
27
28
  add_btn.grid(row=1, column=0, sticky=NW)
@@ -43,36 +44,42 @@ class AddClfPopUp(PopUpMixin, ConfigReader):
43
44
 
44
45
  class RemoveAClassifierPopUp(PopUpMixin, ConfigReader):
45
46
  def __init__(self, config_path: Union[str, os.PathLike]):
46
- PopUpMixin.__init__(self, title="Warning: Remove classifier(s) settings")
47
+
47
48
  ConfigReader.__init__(self, config_path=config_path, read_video_info=False)
49
+ if not isinstance(self.clf_names, (list, tuple)) or len(self.clf_names) < 1:
50
+ raise NoDataError(msg='The SimBA project has no classifiers: Cannot remove a classifier.', source=self.__class__.__name__)
51
+ PopUpMixin.__init__(self, title="WARNING: REMOVE CLASSIFIER", icon='trash_red')
48
52
  self.remove_clf_frm = CreateLabelFrameWithIcon( parent=self.main_frm, header="SELECT A CLASSIFIER TO REMOVE", icon_name=Keys.DOCUMENTATION.value, icon_link=Links.REMOVE_CLF.value)
49
- self.clf_dropdown = DropDownMenu(self.remove_clf_frm, "Classifier", self.clf_names, "12")
50
- self.clf_dropdown.setChoices(self.clf_names[0])
51
-
53
+ self.clf_dropdown = SimBADropDown(parent=self.remove_clf_frm, dropdown_options=self.clf_names, label_width=20, dropdown_width=40, label='CLASSIFIER:', value=self.clf_names[0])
52
54
  run_btn = SimbaButton(parent=self.main_frm, txt="REMOVE CLASSIFIER", cmd=self.run, img='trash')
53
- self.remove_clf_frm.grid(row=0, sticky=W)
54
- self.clf_dropdown.grid(row=0, sticky=W)
55
+ self.remove_clf_frm.grid(row=0, column=0, sticky=W)
56
+ self.clf_dropdown.grid(row=0, column=0, sticky=W)
55
57
  run_btn.grid(row=1, pady=10)
56
58
 
57
59
  def run(self):
58
- for i in range(len(self.clf_names)):
59
- self.config.remove_option("SML settings", f"model_path_{i+1}")
60
- self.config.remove_option("SML settings", f"target_name_{i+1}")
61
- self.config.remove_option("threshold_settings", f"threshold_{i+1}")
62
- self.config.remove_option("Minimum_bout_lengths", f"min_bout_{i+1}")
63
- self.clf_names.remove(self.clf_dropdown.getChoices())
64
- self.config.set("SML settings", "no_targets", str(len(self.clf_names)))
65
-
66
- for clf_cnt, clf_name in enumerate(self.clf_names):
67
- self.config.set("SML settings", f"model_path_{clf_cnt + 1}", "")
68
- self.config.set("SML settings", f"target_name_{clf_cnt + 1}", clf_name)
69
- self.config.set("threshold_settings", f"threshold_{clf_cnt + 1}", "None")
70
- self.config.set("Minimum_bout_lengths", f"min_bout_{clf_cnt + 1}", "None")
71
-
72
- with open(self.config_path, "w") as f:
73
- self.config.write(f)
74
-
75
- stdout_trash(msg=f"{self.clf_dropdown.getChoices()} classifier removed from SimBA project.", source=self.__class__.__name__)
60
+ clf_to_remove = self.clf_dropdown.get_value()
61
+ question = TwoOptionQuestionPopUp(title="WARNING!", question=f"Do you want to remove the {clf_to_remove} \nclassifier from the SimBA project?", option_one="YES", option_two="NO")
62
+ if question.selected_option == "YES":
63
+ for i in range(len(self.clf_names)):
64
+ self.config.remove_option("SML settings", f"model_path_{i+1}")
65
+ self.config.remove_option("SML settings", f"target_name_{i+1}")
66
+ self.config.remove_option("threshold_settings", f"threshold_{i+1}")
67
+ self.config.remove_option("Minimum_bout_lengths", f"min_bout_{i+1}")
68
+ self.clf_names.remove(self.clf_dropdown.getChoices())
69
+ self.config.set("SML settings", "no_targets", str(len(self.clf_names)))
70
+
71
+ for clf_cnt, clf_name in enumerate(self.clf_names):
72
+ self.config.set("SML settings", f"model_path_{clf_cnt + 1}", "")
73
+ self.config.set("SML settings", f"target_name_{clf_cnt + 1}", clf_name)
74
+ self.config.set("threshold_settings", f"threshold_{clf_cnt + 1}", "None")
75
+ self.config.set("Minimum_bout_lengths", f"min_bout_{clf_cnt + 1}", "None")
76
+
77
+ with open(self.config_path, "w") as f:
78
+ self.config.write(f)
79
+
80
+ stdout_trash(msg=f"{self.clf_dropdown.getChoices()} classifier removed from SimBA project.", source=self.__class__.__name__)
81
+ else:
82
+ pass
76
83
 
77
84
 
78
85
  # _ = RemoveAClassifierPopUp(config_path='/Users/simon/Desktop/envs/troubleshooting/Two_animals_16bps/project_folder/project_config.ini')
@@ -49,8 +49,8 @@ class SklearnVisualizationPopUp(PopUpMixin, ConfigReader):
49
49
  pose_palettes = Options.PALETTE_OPTIONS_CATEGORICAL.value + Options.PALETTE_OPTIONS.value
50
50
  PopUpMixin.__init__(self, title="VISUALIZE CLASSIFICATION (SKLEARN) RESULTS", icon='photos')
51
51
  bp_threshold_frm = CreateLabelFrameWithIcon(parent=self.main_frm, header="BODY-PART VISUALIZATION THRESHOLD", icon_name='threshold', icon_link=Links.SKLEARN_PLOTS.value, padx=5, pady=5, relief='solid')
52
- self.bp_threshold_lbl = SimBALabel(parent=bp_threshold_frm, txt="Body-parts detected below the set threshold won't be shown in the output videos.", font=Formats.FONT_REGULAR_ITALICS.value)
53
- self.bp_threshold_entry = Entry_Box(parent=bp_threshold_frm, fileDescription='BODY-PART PROBABILITY THRESHOLD: ', labelwidth=40, entry_box_width=15, value=0.00, img='green_dice')
52
+ self.bp_threshold_lbl = SimBALabel(parent=bp_threshold_frm, txt="Body-parts detected below the set threshold won't be shown in the output videos (use 0.0 to see all body-part predictions)", font=Formats.FONT_REGULAR_ITALICS.value)
53
+ self.bp_threshold_entry = Entry_Box(parent=bp_threshold_frm, fileDescription='BODY-PART PROBABILITY THRESHOLD: ', labelwidth=40, entry_box_width=15, value=0.00, img='green_dice', justify='center')
54
54
  self.get_bp_probability_threshold()
55
55
 
56
56
  bp_threshold_frm.grid(row=0, column=0, sticky=NW)
@@ -5,13 +5,12 @@ from typing import Union
5
5
  from simba.data_processors.egocentric_aligner import EgocentricalAligner
6
6
  from simba.mixins.config_reader import ConfigReader
7
7
  from simba.mixins.pop_up_mixin import PopUpMixin
8
- from simba.ui.tkinter_functions import (CreateLabelFrameWithIcon, DropDownMenu,
9
- FolderSelect, SimbaCheckbox,
8
+ from simba.ui.tkinter_functions import (CreateLabelFrameWithIcon, FolderSelect,
10
9
  SimBADropDown)
11
10
  from simba.utils.checks import check_if_dir_exists, check_nvidea_gpu_available
12
11
  from simba.utils.enums import Keys, Links
13
12
  from simba.utils.errors import InvalidInputError, NoDataError, SimBAGPUError
14
- from simba.utils.lookups import get_color_dict
13
+ from simba.utils.lookups import find_closest_string, get_color_dict
15
14
  from simba.utils.read_write import (find_all_videos_in_directory,
16
15
  find_files_of_filetypes_in_directory,
17
16
  get_fn_ext, str_2_bool)
@@ -31,19 +30,19 @@ class EgocentricAlignPopUp(ConfigReader, PopUpMixin):
31
30
  ConfigReader.__init__(self, config_path=config_path, read_video_info=False, create_logger=False)
32
31
  self.clr_dict = get_color_dict()
33
32
  gpu_status = NORMAL if check_nvidea_gpu_available() else DISABLED
34
-
35
-
36
33
  settings_frm = CreateLabelFrameWithIcon(parent=self.main_frm, header="SETTINGS", icon_name=Keys.DOCUMENTATION.value, icon_link=Links.VIDEO_TOOLS.value)
37
- self.data_dir = FolderSelect(settings_frm, "DATA DIRECTORY:", lblwidth=45, initialdir=self.outlier_corrected_dir, lbl_icon='folder')
38
- self.videos_dir = FolderSelect(settings_frm, "VIDEO DIRECTORY:", lblwidth=45, initialdir=self.video_dir, lbl_icon='folder')
39
- self.save_dir = FolderSelect(settings_frm, "SAVE DIRECTORY:", lblwidth=45, initialdir=self.video_dir, lbl_icon='folder')
34
+ self.data_dir = FolderSelect(settings_frm, "DATA DIRECTORY:", lblwidth=45, initialdir=self.outlier_corrected_dir, lbl_icon='folder', tooltip_key='EGOCENTRIC_DATA_DIR')
35
+ self.videos_dir = FolderSelect(settings_frm, "VIDEO DIRECTORY:", lblwidth=45, initialdir=self.video_dir, lbl_icon='folder', tooltip_key='EGOCENTRIC_VIDEO_DIR')
36
+ self.save_dir = FolderSelect(settings_frm, "SAVE DIRECTORY:", lblwidth=45, initialdir=self.project_path, lbl_icon='folder', tooltip_key='SAVE_DIR')
37
+ default_center = find_closest_string(target='center', string_list=self.body_parts_lst)[0]
38
+ default_direction = find_closest_string(target='nose', string_list=self.body_parts_lst)[0]
40
39
 
41
- self.center_anchor_dropdown = SimBADropDown(parent=settings_frm, label="CENTER ANCHOR:", dropdown_options=self.body_parts_lst, label_width=45, dropdown_width=45, img='center', value=self.body_parts_lst[0])
42
- self.direction_anchor_dropdown = SimBADropDown(parent=settings_frm, label="DIRECTION ANCHOR:", dropdown_options=self.body_parts_lst, label_width=45, dropdown_width=45, img='direction', value=self.body_parts_lst[1])
43
- self.direction_dropdown = SimBADropDown(parent=settings_frm, label="DIRECTION:", dropdown_options=list(range(0, 361)), label_width=45, dropdown_width=45, img='direction_2', value=0)
44
- self.fill_clr_dropdown = SimBADropDown(parent=settings_frm, label="ROTATION COLOR:", dropdown_options=list(self.clr_dict.keys()), label_width=45, dropdown_width=45, img='fill', value='Black')
45
- self.core_cnt_dropdown = SimBADropDown(parent=settings_frm, label="CPU COUNT:", dropdown_options=list(range(1, self.cpu_cnt + 1)), label_width=45, dropdown_width=45, img='cpu_small', value=self.cpu_cnt)
46
- self.gpu_dropdown = SimBADropDown(parent=settings_frm, label='USE GPU:', dropdown_options=['TRUE', 'FALSE'], label_width=45, dropdown_width=45, img='gpu_3', value='FALSE', state=gpu_status)
40
+ self.center_anchor_dropdown = SimBADropDown(parent=settings_frm, label="CENTER ANCHOR:", dropdown_options=self.body_parts_lst, label_width=45, dropdown_width=45, img='center', value=default_center, tooltip_key='EGOCENTRIC_ANCHOR')
41
+ self.direction_anchor_dropdown = SimBADropDown(parent=settings_frm, label="DIRECTION ANCHOR:", dropdown_options=self.body_parts_lst, label_width=45, dropdown_width=45, img='direction', value=default_direction, tooltip_key='EGOCENTRIC_DIRECTION_ANCHOR')
42
+ self.direction_dropdown = SimBADropDown(parent=settings_frm, label="DIRECTION:", dropdown_options=list(range(0, 361)), label_width=45, dropdown_width=45, img='direction_2', value=0, tooltip_key='EGOCENTRIC_DIRECTION')
43
+ self.fill_clr_dropdown = SimBADropDown(parent=settings_frm, label="ROTATION COLOR:", dropdown_options=list(self.clr_dict.keys()), label_width=45, dropdown_width=45, img='fill', value='Black', tooltip_key='ROTATE_FILL_COLOR')
44
+ self.core_cnt_dropdown = SimBADropDown(parent=settings_frm, label="CPU COUNT:", dropdown_options=list(range(1, self.cpu_cnt + 1)), label_width=45, dropdown_width=45, img='cpu_small', value=int(self.cpu_cnt/2), tooltip_key='CORE_COUNT')
45
+ self.gpu_dropdown = SimBADropDown(parent=settings_frm, label='USE GPU:', dropdown_options=['TRUE', 'FALSE'], label_width=45, dropdown_width=45, img='gpu_3', value='FALSE', state=gpu_status, tooltip_key='USE_GPU')
47
46
 
48
47
  settings_frm.grid(row=0, column=0, sticky=NW)
49
48
  self.data_dir.grid(row=0, column=0, sticky=NW)
@@ -62,9 +61,10 @@ class EgocentricAlignPopUp(ConfigReader, PopUpMixin):
62
61
  data_dir, video_dir = self.data_dir.folder_path, self.videos_dir.folder_path
63
62
  save_dir = self.save_dir.folder_path
64
63
  gpu = str_2_bool(self.gpu_dropdown.get_value())
65
- check_if_dir_exists(in_dir=data_dir);
66
- check_if_dir_exists(in_dir=video_dir);
64
+ check_if_dir_exists(in_dir=data_dir)
65
+ check_if_dir_exists(in_dir=video_dir)
67
66
  check_if_dir_exists(in_dir=save_dir)
67
+ core_cnt = int(self.core_cnt_dropdown.get_value())
68
68
  if (save_dir == data_dir) or (save_dir == video_dir):
69
69
  raise InvalidInputError(msg='The save directory cannot be the same as the data/video directories',source=self.__class__.__name__)
70
70
  center_anchor, direction_anchor = self.center_anchor_dropdown.getChoices(), self.direction_anchor_dropdown.getChoices()
@@ -72,12 +72,10 @@ class EgocentricAlignPopUp(ConfigReader, PopUpMixin):
72
72
  direction = int(self.direction_dropdown.getChoices())
73
73
  if gpu and not check_nvidea_gpu_available():
74
74
  raise SimBAGPUError(msg='No NVIDEA GPU detected.', source=self.__class__.__name__)
75
- data_file_paths = find_files_of_filetypes_in_directory(directory=data_dir, extensions=[f'.{self.file_type}'],
76
- raise_error=True)
75
+ data_file_paths = find_files_of_filetypes_in_directory(directory=data_dir, extensions=[f'.{self.file_type}'], raise_error=True)
77
76
  data_file_paths = [os.path.join(data_dir, x) for x in data_file_paths]
78
77
  data_file_names = [get_fn_ext(filepath=x)[1] for x in data_file_paths]
79
- video_file_paths = list(
80
- find_all_videos_in_directory(directory=video_dir, as_dict=True, raise_error=True).values())
78
+ video_file_paths = list( find_all_videos_in_directory(directory=video_dir, as_dict=True, raise_error=True).values())
81
79
  video_file_names = [get_fn_ext(filepath=x)[1] for x in video_file_paths]
82
80
  missing_video_files = [x for x in video_file_names if x not in data_file_names]
83
81
  if len(missing_video_files) > 0: raise NoDataError(
@@ -89,6 +87,7 @@ class EgocentricAlignPopUp(ConfigReader, PopUpMixin):
89
87
  anchor_2=direction_anchor,
90
88
  direction=direction,
91
89
  anchor_location=None,
90
+ core_cnt=core_cnt,
92
91
  fill_clr=self.clr_dict[fill_clr],
93
92
  verbose=True,
94
93
  gpu=gpu,
@@ -97,4 +96,4 @@ class EgocentricAlignPopUp(ConfigReader, PopUpMixin):
97
96
  aligner.run()
98
97
 
99
98
 
100
- #_ = EgocentricAlignPopUp(config_path=r"C:\troubleshooting\mitra\project_folder\project_config.ini")
99
+ #_ = EgocentricAlignPopUp(config_path=r"D:\troubleshooting\mitra\project_folder\project_config.ini")
@@ -7,25 +7,29 @@ from typing import Union
7
7
  from simba.data_processors.fsttc_calculator import FSTTCCalculator
8
8
  from simba.mixins.config_reader import ConfigReader
9
9
  from simba.mixins.pop_up_mixin import PopUpMixin
10
- from simba.ui.tkinter_functions import CreateLabelFrameWithIcon, Entry_Box
10
+ from simba.ui.tkinter_functions import (CreateLabelFrameWithIcon, Entry_Box,
11
+ SimbaCheckbox)
11
12
  from simba.utils.checks import check_int
12
- from simba.utils.enums import Defaults, Formats, Keys, Links
13
+ from simba.utils.enums import Formats, Keys, Links
13
14
  from simba.utils.errors import CountError
14
15
 
15
16
 
16
17
  class FSTTCPopUp(PopUpMixin, ConfigReader):
17
- def __init__(self, config_path: Union[str, os.PathLike]):
18
+ def __init__(self,
19
+ config_path: Union[str, os.PathLike]):
18
20
 
19
- PopUpMixin.__init__(self, title="FORWARD SPIKE TIME TILING COEFFICIENTS", icon='dependency')
20
21
  ConfigReader.__init__(self, config_path=config_path, read_video_info=False)
22
+ if len(self.clf_names) < 2:
23
+ raise CountError(msg=f'Cannot compute FSTTC: Needs project with at least 2 classified behaviors, got {len(self.clf_names)}', source=self.__class__.__name__)
24
+
25
+ PopUpMixin.__init__(self, title="FORWARD SPIKE TIME TILING COEFFICIENTS", icon='dependency')
21
26
  settings_frm = CreateLabelFrameWithIcon( parent=self.main_frm, header="SETTINGS", icon_name=Keys.DOCUMENTATION.value, icon_link=Links.FSTTC.value,)
22
- self.time_delta_eb = Entry_Box(settings_frm, "TIME-DELTA", "10", validation="numeric")
23
- self.graph_cb_var = BooleanVar(value=False)
24
- graph_cb = Checkbutton(settings_frm, font=Formats.FONT_REGULAR.value, text="CREATE GRAPH", variable=self.graph_cb_var)
25
- self.join_bouts_within_delta_var = BooleanVar(value=False)
26
- join_bouts_within_delta_cb = Checkbutton(settings_frm, text="JOIN BOUTS WITHIN TIME-DELTA", font=Formats.FONT_REGULAR.value, variable=self.join_bouts_within_delta_var,)
27
- self.time_delta_at_onset_var = BooleanVar(value=False)
28
- time_delta_at_onset_cb = Checkbutton( settings_frm, text="TIME-DELTA AT BOUT START", font=Formats.FONT_REGULAR.value, variable=self.time_delta_at_onset_var)
27
+ self.time_delta_eb = Entry_Box(parent=settings_frm, fileDescription="TIME-DELTA", labelwidth=25, validation="numeric", entry_box_width=20, img='timer_2')
28
+
29
+ graph_cb, self.graph_cb_var = SimbaCheckbox(parent=settings_frm, font=Formats.FONT_REGULAR.value, val=False, txt_img='line_chart_blue', txt="CREATE GRAPH")
30
+ join_bouts_within_delta_cb, self.join_bouts_within_delta_var = SimbaCheckbox(parent=settings_frm, font=Formats.FONT_REGULAR.value, val=False, txt_img='join_purple', txt="JOIN BOUTS WITHIN TIME-DELTA")
31
+ time_delta_at_onset_cb, self.time_delta_at_onset_var = SimbaCheckbox(parent=settings_frm, font=Formats.FONT_REGULAR.value, val=False, txt_img='play', txt="TIME-DELTA AT BOUT START")
32
+
29
33
  settings_frm.grid(row=0, column=0, sticky=NW)
30
34
  self.time_delta_eb.grid(row=0, column=0, sticky="NW")
31
35
  join_bouts_within_delta_cb.grid(row=1, column=0, sticky="NW")
@@ -43,22 +47,20 @@ class FSTTCPopUp(PopUpMixin, ConfigReader):
43
47
  targets.append(behaviour)
44
48
 
45
49
  if len(targets) < 2:
46
- raise CountError(
47
- msg="FORWARD SPIKE TIME TILING COEFFICIENTS REQUIRE 2 OR MORE BEHAVIORS.",
48
- source=self.__class__.__name__,
49
- )
50
-
51
- fsttc_calculator = FSTTCCalculator(
52
- config_path=self.config_path,
53
- time_window=self.time_delta_eb.entry_get,
54
- join_bouts_within_delta=self.join_bouts_within_delta_var.get(),
55
- time_delta_at_onset=self.time_delta_at_onset_var.get(),
56
- behavior_lst=targets,
57
- create_graphs=self.graph_cb_var.get(),
58
- )
50
+ raise CountError(msg="FORWARD SPIKE TIME TILING COEFFICIENTS REQUIRE 2 OR MORE BEHAVIORS.", source=self.__class__.__name__,)
51
+
52
+ fsttc_calculator = FSTTCCalculator(config_path=self.config_path,
53
+ time_window=self.time_delta_eb.entry_get,
54
+ join_bouts_within_delta=self.join_bouts_within_delta_var.get(),
55
+ time_delta_at_onset=self.time_delta_at_onset_var.get(),
56
+ behavior_lst=targets,
57
+ create_graphs=self.graph_cb_var.get())
59
58
  fsttc_calculator.run()
60
59
 
61
60
 
62
- #ExtractAnnotationFramesPopUp(config_path=)
61
+
63
62
 
64
63
  #_ = FSTTCPopUp(config_path=r"C:\troubleshooting\multi_animal_dlc_two_c57\project_folder\project_config.ini")
64
+
65
+ #_ = FSTTCPopUp(config_path=r"C:\troubleshooting\mitra\project_folder\project_config.ini")
66
+
@@ -13,6 +13,7 @@ from simba.ui.tkinter_functions import (CreateLabelFrameWithIcon, SimbaButton,
13
13
  from simba.utils.checks import check_if_filepath_list_is_empty
14
14
  from simba.utils.enums import Formats, Links, Options
15
15
  from simba.utils.errors import NoSpecifiedOutputError
16
+ from simba.utils.lookups import get_fonts
16
17
  from simba.utils.read_write import find_files_of_filetypes_in_directory
17
18
 
18
19
 
@@ -29,7 +30,9 @@ class GanttPlotPopUp(PopUpMixin, ConfigReader):
29
30
  check_if_filepath_list_is_empty(filepaths=self.machine_results_paths,error_msg=f"SIMBA ERROR: Zero files found in the {self.machine_results_dir} directory. Create classification results before visualizing gantt charts",)
30
31
  palettes = Options.PALETTE_OPTIONS_CATEGORICAL.value + Options.PALETTE_OPTIONS.value
31
32
  self.data_paths = find_files_of_filetypes_in_directory(directory=self.machine_results_dir, extensions=[f'.{self.file_type}'], as_dict=True)
32
- max_file_name_len = max(len(k) for k in self.data_paths) + 5
33
+ max_file_name_len, fonts = max(len(k) for k in self.data_paths) + 5, list(get_fonts(sort_alphabetically=True).keys())
34
+ fonts.insert(0, 'AUTO')
35
+ default_font = 'Arial' if 'Arial' in fonts else 'AUTO'
33
36
  PopUpMixin.__init__(self, config_path=config_path, title="VISUALIZE GANTT PLOTS", icon='gantt_small')
34
37
 
35
38
  self.style_settings_frm = CreateLabelFrameWithIcon(parent=self.main_frm, header="STYLE SETTINGS", icon_name='settings', icon_link=Links.GANTT_PLOTS.value, relief='solid', padx=5, pady=5)
@@ -39,6 +42,15 @@ class GanttPlotPopUp(PopUpMixin, ConfigReader):
39
42
  self.palette_dropdown = SimBADropDown(parent=self.style_settings_frm, dropdown_options=palettes, label='COLOR PALETTE: ', label_width=30, dropdown_width=30, value='Set1', img='palette_small')
40
43
  self.time_format_dropdown = SimBADropDown(parent=self.style_settings_frm, dropdown_options=['SECONDS', 'HH:MM:SS'], label='X-AXIS TIME FORMAT: ', label_width=30, dropdown_width=30, value='SECONDS', img='timer_2')
41
44
  self.core_dropdown = SimBADropDown(parent=self.style_settings_frm, dropdown_options=list(range(1, self.cpu_cnt+1)), label='CPU CORES: ', label_width=30, dropdown_width=30, value=int(self.cpu_cnt/2), img='cpu_small')
45
+ self.font_dropdown = SimBADropDown(parent=self.style_settings_frm, dropdown_options=fonts, label='FONT: ', label_width=30, dropdown_width=30, value=default_font, img='font')
46
+
47
+
48
+ self.clf_frm = CreateLabelFrameWithIcon(parent=self.main_frm, header="BEHAVIORS", icon_name='forest', icon_link=Links.GANTT_PLOTS.value, relief='solid', padx=5, pady=5)
49
+ self.clf_choices = {}
50
+ for cnt, clf_name in enumerate(self.clf_names):
51
+ gantt_frames_cb, self.gantt_frames_var = SimbaCheckbox(parent=self.clf_frm, txt=clf_name, val=True)
52
+ self.clf_choices[clf_name] = self.gantt_frames_var
53
+ gantt_frames_cb.grid(row=cnt, column=0, sticky=NW)
42
54
 
43
55
  self.settings_frm = CreateLabelFrameWithIcon(parent=self.main_frm, header="VISUALIZATION SETTINGS", icon_name='eye', icon_link=Links.GANTT_PLOTS.value, relief='solid', padx=5, pady=5)
44
56
  gantt_frames_cb, self.gantt_frames_var = SimbaCheckbox(parent=self.settings_frm, txt='CREATE FRAMES', txt_img='frames', val=False)
@@ -57,18 +69,20 @@ class GanttPlotPopUp(PopUpMixin, ConfigReader):
57
69
  self.font_rotation_dropdown.grid(row=2, sticky=NW)
58
70
  self.palette_dropdown.grid(row=3, sticky=NW)
59
71
  self.time_format_dropdown.grid(row=4, sticky=NW)
60
- self.core_dropdown.grid(row=5, sticky=NW)
72
+ self.font_dropdown.grid(row=5, sticky=NW)
73
+ self.core_dropdown.grid(row=6, sticky=NW)
61
74
 
62
- self.settings_frm.grid(row=1, sticky=NW, padx=10, pady=10)
75
+ self.clf_frm.grid(row=1, sticky=NW, padx=10, pady=10)
76
+ self.settings_frm.grid(row=2, sticky=NW, padx=10, pady=10)
63
77
  gantt_videos_cb.grid(row=0, sticky=NW)
64
78
  gantt_frames_cb.grid(row=1, sticky=W)
65
79
  gantt_last_frame_cb.grid(row=2, sticky=NW)
66
80
 
67
- self.run_single_video_frm.grid(row=2, sticky=NW)
81
+ self.run_single_video_frm.grid(row=3, sticky=NW)
68
82
  self.run_single_video_btn.grid(row=0, sticky=NW)
69
83
  self.single_video_dropdown.grid(row=0, column=1, sticky=NW)
70
84
 
71
- self.run_multiple_videos.grid(row=3, sticky=NW)
85
+ self.run_multiple_videos.grid(row=4, sticky=NW)
72
86
  self.run_multiple_video_btn.grid(row=0, sticky=NW)
73
87
 
74
88
  self.main_frm.mainloop()
@@ -85,8 +99,14 @@ class GanttPlotPopUp(PopUpMixin, ConfigReader):
85
99
  video_setting = self.gantt_videos_var.get()
86
100
  last_frm_setting = self.gantt_last_frame_var.get()
87
101
  palette = self.palette_dropdown.get_value()
102
+ font = self.font_dropdown.get_value()
103
+ font = None if font == 'AUTO' else font
88
104
  hhmmss = True if self.time_format_dropdown.get_value() == 'HH:MM:SS' else False
89
-
105
+ clf_names = []
106
+ for clf_name, clf_val in self.clf_choices.items():
107
+ if clf_val.get(): clf_names.append(clf_name)
108
+ if len(clf_names) < 1:
109
+ raise NoSpecifiedOutputError(msg="Select AT LEAST one behavior name.")
90
110
  if not frame_setting and not video_setting and not last_frm_setting:
91
111
  raise NoSpecifiedOutputError(msg="SIMBA ERROR: Please select gantt videos, frames, and/or last frame.")
92
112
 
@@ -103,6 +123,8 @@ class GanttPlotPopUp(PopUpMixin, ConfigReader):
103
123
  data_paths=data_paths,
104
124
  width=width,
105
125
  height=height,
126
+ font=font,
127
+ clf_names=clf_names,
106
128
  font_size=font_size,
107
129
  font_rotation=font_rotation,
108
130
  core_cnt=core_cnt,
@@ -116,7 +138,9 @@ class GanttPlotPopUp(PopUpMixin, ConfigReader):
116
138
  last_frm_setting=last_frm_setting,
117
139
  data_paths=data_paths,
118
140
  width=width,
141
+ font=font,
119
142
  height=height,
143
+ clf_names=clf_names,
120
144
  font_size=font_size,
121
145
  font_rotation=font_rotation,
122
146
  palette=palette)
@@ -124,6 +148,7 @@ class GanttPlotPopUp(PopUpMixin, ConfigReader):
124
148
 
125
149
 
126
150
  #_ = GanttPlotPopUp(config_path=r"D:\troubleshooting\maplight_ri\project_folder\project_config.ini")
151
+ #_ = GanttPlotPopUp(config_path=r"C:\troubleshooting\mitra\project_folder\project_config.ini")
127
152
  # _ = GanttPlotPopUp(config_path=r"/Users/simon/Desktop/envs/simba/troubleshooting/two_black_animals_14bp/project_folder/project_config.ini")
128
153
 
129
154
  # _ = GanttPlotPopUp(config_path=r"C:\troubleshooting\RAT_NOR\project_folder\project_config.ini")
@@ -35,8 +35,6 @@ class InterpolatePopUp(PopUpMixin, ConfigReader):
35
35
  self.config_path = config_path
36
36
 
37
37
  self.settings_frm= CreateLabelFrameWithIcon(parent=self.main_frm, header="SETTINGS", icon_name='settings')
38
-
39
- #self.settings_frm = LabelFrame(self.main_frm, text="SETTINGS", font=Formats.FONT_HEADER.value)
40
38
  instruction_lbl_1 = SimBALabel(parent=self.settings_frm, txt=INSTRUCTIONS_LBL_1, font=Formats.FONT_REGULAR_ITALICS.value, justify='center')
41
39
  self.type_dropdown = SimBADropDown(parent=self.settings_frm, dropdown_options=['MISSING BODY-PARTS', 'MISSING ANIMALS'], label="INTERPOLATION TYPE:", label_width=35, value='MISSING BODY-PARTS', dropdown_width=35, img='file_type')
42
40
  self.method_dropdown = SimBADropDown(parent=self.settings_frm, dropdown_options=['NEAREST', 'LINEAR', 'QUADRATIC'], label="INTERPOLATION METHOD:", label_width=35, value='NEAREST', dropdown_width=35, img='equation_small')
@@ -50,7 +48,7 @@ class InterpolatePopUp(PopUpMixin, ConfigReader):
50
48
 
51
49
  self.single_file_frm = LabelFrame(self.main_frm, text="INTERPOLATE SINGLE DATA FILE", font=Formats.FONT_HEADER.value)
52
50
  instruction_lbl_single = SimBALabel(parent=self.single_file_frm, txt=INSTRUCTIONS_LBL_2, font=Formats.FONT_REGULAR_ITALICS.value, justify='center')
53
- self.selected_file = FileSelect(self.single_file_frm, "DATA PATH:", lblwidth=35, file_types=[("VIDEO FILE", ".csv .parquet")], initialdir=self.project_path)
51
+ self.selected_file = FileSelect(self.single_file_frm, "DATA PATH:", lblwidth=35, file_types=[("VIDEO FILE", ".csv .parquet")], initialdir=self.project_path, lbl_icon='file')
54
52
  self.run_btn_single = SimbaButton(parent=self.single_file_frm, txt="RUN SINGLE DATA FILE INTERPOLATION", img='rocket', txt_clr="blue", font=Formats.FONT_REGULAR.value, cmd=self.run, cmd_kwargs={'multiple': False})
55
53
 
56
54
  self.single_file_frm.grid(row=1, column=0, sticky=NW)
@@ -60,7 +58,7 @@ class InterpolatePopUp(PopUpMixin, ConfigReader):
60
58
 
61
59
  self.multiple_file_frm = LabelFrame(self.main_frm, text="INTERPOLATE DIRECTORY OF DATA", font=Formats.FONT_HEADER.value)
62
60
  instruction_lbl_multiple = SimBALabel(parent=self.multiple_file_frm, txt=INSTRUCTIONS_LBL_3, font=Formats.FONT_REGULAR_ITALICS.value, justify='center')
63
- self.selected_dir = FolderSelect(self.multiple_file_frm, "SELECT DIRECTORY OF DATA FILES:", lblwidth=35, initialdir=self.project_path)
61
+ self.selected_dir = FolderSelect(self.multiple_file_frm, "SELECT DIRECTORY OF DATA FILES:", lblwidth=35, initialdir=self.project_path, lbl_icon='folder')
64
62
  self.run_btn_multiple = SimbaButton(parent=self.multiple_file_frm, txt="RUN DATA DIRECTORY INTERPOLATION", img='rocket', txt_clr="blue", font=Formats.FONT_REGULAR.value, cmd=self.run, cmd_kwargs={'multiple': True})
65
63
  self.multiple_file_frm.grid(row=2, column=0, sticky=NW)
66
64
  instruction_lbl_multiple.grid(row=0, column=0, sticky=NW)
@@ -8,12 +8,13 @@ from simba.data_processors.kleinberg_calculator import KleinbergCalculator
8
8
  from simba.mixins.config_reader import ConfigReader
9
9
  from simba.mixins.pop_up_mixin import PopUpMixin
10
10
  from simba.ui.tkinter_functions import (CreateLabelFrameWithIcon, Entry_Box,
11
- SimbaButton, SimBADropDown)
11
+ SimbaButton, SimBADropDown, SimBALabel)
12
12
  from simba.utils.checks import check_float, check_int
13
13
  from simba.utils.enums import Formats, Keys, Links
14
14
  from simba.utils.errors import NoChoosenClassifierError, NoDataError
15
- from simba.utils.read_write import str_2_bool
15
+ from simba.utils.read_write import get_current_time, str_2_bool
16
16
 
17
+ INSTRUCTIONS_TXT = 'Results in the project_folder/csv/machine_results folder are overwritten.\n If saving the originals, the original un-smoothened data is saved in a subdirectory of \nthe project_folder/csv/machine_results folder'
17
18
 
18
19
  class KleinbergPopUp(PopUpMixin, ConfigReader):
19
20
  def __init__(self,
@@ -24,61 +25,59 @@ class KleinbergPopUp(PopUpMixin, ConfigReader):
24
25
  raise NoDataError(msg=f'Cannot perform Kleinberg smoothing: No data files found in {self.machine_results_dir} directory', source=self.__class__.__name__)
25
26
  PopUpMixin.__init__(self, title="APPLY KLEINBERG BEHAVIOR CLASSIFICATION SMOOTHING", icon='smooth')
26
27
  kleinberg_settings_frm = CreateLabelFrameWithIcon(parent=self.main_frm, header="KLEINBERG SETTINGS", icon_name=Keys.DOCUMENTATION.value, icon_link=Links.KLEINBERG.value)
27
- self.k_sigma = Entry_Box(kleinberg_settings_frm, fileDescription="SIGMA", img='sigma', value='2', justify='center', labelwidth=35, entry_box_width=35)
28
- self.k_gamma = Entry_Box(kleinberg_settings_frm, fileDescription="GAMMA", img='gamma', value='0.3', justify='center', labelwidth=35, entry_box_width=35)
29
- self.k_hierarchy = Entry_Box(kleinberg_settings_frm, fileDescription="HIERARCHY", value=1, img='hierarchy_2', justify='center', labelwidth=35, entry_box_width=35)
30
- self.h_search_dropdown = SimBADropDown(parent=kleinberg_settings_frm, dropdown_options=['TRUE', 'FALSE'], label="HIERACHICAL SEARCH", value='FALSE', img='hierarchy', label_width=35, dropdown_width=35)
28
+ self.k_sigma = Entry_Box(kleinberg_settings_frm, fileDescription="SIGMA", img='sigma', value='2', justify='center', labelwidth=35, entry_box_width=35, tooltip_key='KLEINBERG_SIGMA')
29
+ self.k_gamma = Entry_Box(kleinberg_settings_frm, fileDescription="GAMMA", img='gamma', value='0.3', justify='center', labelwidth=35, entry_box_width=35, tooltip_key='KLEINBERG_GAMMA')
30
+ self.k_hierarchy = Entry_Box(kleinberg_settings_frm, fileDescription="HIERARCHY", value=1, img='hierarchy_2', justify='center', labelwidth=35, entry_box_width=35, validation='numeric', tooltip_key='KLEINBERG_HIERARCHY')
31
+ self.h_search_dropdown = SimBADropDown(parent=kleinberg_settings_frm, dropdown_options=['TRUE', 'FALSE'], label="HIERARCHICAL SEARCH", value='FALSE', img='hierarchy', label_width=35, dropdown_width=35, tooltip_key='KLEINBERG_HIERARCHY_SEARCH')
32
+ self.save_originals_dropdown = SimBADropDown(parent=kleinberg_settings_frm, dropdown_options=['TRUE', 'FALSE'], label="SAVE ORIGINAL DATA:", value='TRUE', img='save', label_width=35, dropdown_width=35, tooltip_key='KLEINBERG_SAVE_ORIGINALS')
33
+ self.instructions_lbl = SimBALabel(parent=kleinberg_settings_frm, txt=INSTRUCTIONS_TXT, justify='center', txt_clr='blue', font=Formats.FONT_REGULAR_ITALICS.value)
31
34
 
32
35
 
33
- kleinberg_table_frame = LabelFrame(self.main_frm, text="CHOOSE CLASSIFIER(S) FOR KLEINBERG SMOOTHING", font=Formats.FONT_HEADER.value)
36
+ kleinberg_table_frame = CreateLabelFrameWithIcon(parent=self.main_frm, header="CHOOSE CLASSIFIER(S) FOR KLEINBERG SMOOTHING", icon_name=Keys.DOCUMENTATION.value, icon_link=Links.KLEINBERG.value)
34
37
  clf_var_dict, clf_cb_dict = {}, {}
35
38
  for clf_cnt, clf in enumerate(self.clf_names):
36
39
  clf_var_dict[clf] = BooleanVar()
37
40
  clf_cb_dict[clf] = Checkbutton(kleinberg_table_frame, text=clf, font=Formats.FONT_REGULAR.value, variable=clf_var_dict[clf])
38
- clf_cb_dict[clf].grid(row=clf_cnt, sticky=NW)
41
+ clf_cb_dict[clf].grid(row=clf_cnt, column=0, sticky=NW)
39
42
 
40
43
  run_kleinberg_btn = SimbaButton(parent=self.main_frm, txt="APPLY KLEINBERG SMOOTHER", img='rocket', txt_clr="blue", font=Formats.FONT_REGULAR.value, cmd=self.run_kleinberg, cmd_kwargs={'behaviors_dict': lambda: clf_var_dict, 'hierarchical_search': lambda: str_2_bool(self.h_search_dropdown.get_value())})
41
- kleinberg_settings_frm.grid(row=0, sticky=W, padx=10)
42
- self.k_sigma.grid(row=0, sticky=W)
43
- self.k_gamma.grid(row=1, sticky=W)
44
- self.k_hierarchy.grid(row=2, sticky=W)
45
- self.h_search_dropdown.grid(row=3, column=0, sticky=W)
46
- kleinberg_table_frame.grid(row=1, pady=10, padx=10)
47
- run_kleinberg_btn.grid(row=2)
44
+ kleinberg_settings_frm.grid(row=0, sticky=W, pady=(15, 0))
45
+ self.instructions_lbl.grid(row=0, sticky=W)
46
+ self.k_sigma.grid(row=1, sticky=W)
47
+ self.k_gamma.grid(row=2, sticky=W)
48
+ self.k_hierarchy.grid(row=3, sticky=W)
49
+ self.h_search_dropdown.grid(row=4, column=0, sticky=W)
50
+ self.save_originals_dropdown.grid(row=5, column=0, sticky=W)
51
+ kleinberg_table_frame.grid(row=1, column=0, sticky=NW, pady=(15, 0))
52
+ run_kleinberg_btn.grid(row=2, column=0, sticky=NW, pady=(15, 0))
48
53
  self.main_frm.mainloop()
49
54
 
50
55
  def run_kleinberg(self, behaviors_dict: dict, hierarchical_search: bool):
51
56
  targets = []
52
57
  for behaviour, behavior_val in behaviors_dict.items():
53
- if behavior_val.get():
54
- targets.append(behaviour)
58
+ if behavior_val.get(): targets.append(behaviour)
55
59
 
56
60
  if len(targets) == 0:
57
61
  raise NoChoosenClassifierError(source=self.__class__.__name__)
58
62
 
59
- check_int(name="Hierarchy", value=self.k_hierarchy.entry_get)
60
- check_float(name="Sigma", value=self.k_sigma.entry_get)
61
- check_float(name="Gamma", value=self.k_gamma.entry_get)
62
-
63
- try:
64
- print(
65
- "Applying kleinberg hyperparameter Setting: Sigma: {}, Gamma: {}, Hierarchy: {}".format(
66
- str(self.k_sigma.entry_get),
67
- str(self.k_gamma.entry_get),
68
- str(self.k_hierarchy.entry_get),
69
- )
70
- )
71
- except:
72
- print("Please insert accurate values for all hyperparameters.")
73
-
74
- kleinberg_analyzer = KleinbergCalculator(
75
- config_path=self.config_path,
76
- classifier_names=targets,
77
- sigma=self.k_sigma.entry_get,
78
- gamma=self.k_gamma.entry_get,
79
- hierarchy=self.k_hierarchy.entry_get,
80
- hierarchical_search=hierarchical_search,
81
- )
63
+ k_hierarchy = self.k_hierarchy.entry_get
64
+ k_sigma = self.k_sigma.entry_get
65
+ k_gamma = self.k_gamma.entry_get
66
+ save_originals = str_2_bool(self.save_originals_dropdown.get_value())
67
+
68
+ check_int(name="Hierarchy", value=k_hierarchy, min_value=1, allow_negative=False, allow_zero=False, raise_error=True)
69
+ check_float(name="Sigma", value=k_sigma, allow_negative=False, allow_zero=False, raise_error=True)
70
+ check_float(name="Gamma", value=k_gamma, allow_negative=False, allow_zero=False, raise_error=True)
71
+
72
+ print(f"[{get_current_time()}] Applying kleinberg hyperparameter Setting: Sigma: {k_sigma}, Gamma: {k_gamma}, Hierarchy: {k_hierarchy}")
73
+
74
+ kleinberg_analyzer = KleinbergCalculator(config_path=self.config_path,
75
+ classifier_names=targets,
76
+ sigma=float(k_sigma),
77
+ gamma=float(k_gamma),
78
+ hierarchy=int(k_hierarchy),
79
+ hierarchical_search=hierarchical_search,
80
+ save_originals=save_originals)
82
81
  kleinberg_analyzer.run()
83
82
 
84
83
 
@@ -19,17 +19,16 @@ class MultipleVideos2FramesPopUp(PopUpMixin):
19
19
  PopUpMixin.__init__(self, title="EXTRACT FRAMES FROM SINGLE VIDEO", icon='frames')
20
20
  core_cnt = find_core_cnt()[0]
21
21
  settings_frm = CreateLabelFrameWithIcon(parent=self.main_frm, header='SETTINGS', icon_name='settings', padx=5, pady=5, relief='solid')
22
-
23
- self.video_dir = FolderSelect(parent=settings_frm, folderDescription="VIDEO DIRECTORY:", lblwidth=50)
24
- self.save_dir = FolderSelect(parent=settings_frm, folderDescription="SAVE DIRECTORY:", lblwidth=50)
25
- self.core_cnt_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=list(range(1, core_cnt+1)), label='CORE COUNT: ', label_width=50, value=int(core_cnt/2))
26
- self.quality_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=list(range(1, 101)), label='IMAGE QUALITY: ', label_width=50, value=90, state='disabled')
27
- self.img_format = SimBADropDown(parent=settings_frm, dropdown_options=['jpeg', 'png', 'webp'], label='IMAGE FORMAT: ', label_width=50, value='png', command=self._inactivate_quality)
28
- self.verbose_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=['TRUE', 'FALSE'], label='VERBOSE: ', label_width=50, value='TRUE')
29
- self.greyscale_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=['TRUE', 'FALSE'], label='GREYSCALE: ', label_width=50, value='FALSE')
30
- self.bw_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=['TRUE', 'FALSE'], label='BLACK & WHITE: ',label_width=50, value='FALSE')
31
- self.clahe_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=['TRUE', 'FALSE'], label='CLAHE: ', label_width=50, value='FALSE')
32
- self.include_fn_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=['TRUE', 'FALSE'], label='INCLUDE VIDEO NAME IN IMAGE NAMES: ',label_width=50, value='FALSE')
22
+ self.video_dir = FolderSelect(parent=settings_frm, folderDescription="VIDEO DIRECTORY:", lblwidth=50, lbl_icon='folder')
23
+ self.save_dir = FolderSelect(parent=settings_frm, folderDescription="SAVE DIRECTORY:", lblwidth=50, lbl_icon='folder')
24
+ self.core_cnt_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=list(range(1, core_cnt+1)), label='CORE COUNT: ', label_width=50, value=int(core_cnt/2), img='cpu_small')
25
+ self.quality_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=list(range(1, 101)), label='IMAGE QUALITY: ', label_width=50, value=90, state='disabled', img='pct_2')
26
+ self.img_format = SimBADropDown(parent=settings_frm, dropdown_options=['jpeg', 'png', 'webp'], label='IMAGE FORMAT: ', label_width=50, value='png', command=self._inactivate_quality, img='file_type')
27
+ self.verbose_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=['TRUE', 'FALSE'], label='VERBOSE: ', label_width=50, value='TRUE', img='verbose')
28
+ self.greyscale_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=['TRUE', 'FALSE'], label='GREYSCALE: ', label_width=50, value='FALSE', img='grey')
29
+ self.bw_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=['TRUE', 'FALSE'], label='BLACK & WHITE: ',label_width=50, value='FALSE', img='black_and_white')
30
+ self.clahe_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=['TRUE', 'FALSE'], label='CLAHE: ', label_width=50, value='FALSE', img='clahe')
31
+ self.include_fn_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=['TRUE', 'FALSE'], label='INCLUDE VIDEO NAME IN IMAGE NAMES: ',label_width=50, value='FALSE', img='id_card_2')
33
32
 
34
33
  settings_frm.grid(row=0, column=0, sticky=NW, padx=10, pady=10)
35
34
  self.video_dir.grid(row=0, column=0, sticky=NW)