diff --git a/simba/SimBA.py b/simba/SimBA.py index 072ed3001..628793f6b 100644 --- a/simba/SimBA.py +++ b/simba/SimBA.py @@ -251,14 +251,14 @@ def __init__(self, config_path: str): import_frm.grid(row=0, column=0, sticky=NW) further_methods_frm = CreateLabelFrameWithIcon(parent=import_frm, header="FURTHER METHODS", icon_name=Keys.DOCUMENTATION.value, icon_link=Links.ADDITIONAL_IMPORTS.value) - extract_frm_btn = SimbaButton(parent=further_methods_frm, txt="EXTRACT FRAMES FOR ALL VIDEOS IN SIMBA PROJECT", txt_clr='blue', font=Formats.FONT_REGULAR.value, cmd=extract_frames_from_all_videos_in_directory, cmd_kwargs={'config_path': lambda:self.config_path, 'directory': lambda:self.video_dir}) - import_frm_dir_btn = SimbaButton(parent=further_methods_frm, txt="IMPORT FRAMES DIRECTORY TO SIMBA PROJECT", txt_clr='blue', font=Formats.FONT_REGULAR.value, cmd=ImportFrameDirectoryPopUp, cmd_kwargs={'config_path': lambda:self.config_path}) - add_clf_btn = SimbaButton(parent=further_methods_frm, txt="ADD CLASSIFIER TO SIMBA PROJECT", txt_clr='blue', font=Formats.FONT_REGULAR.value, cmd=AddClfPopUp, cmd_kwargs={'config_path': lambda:self.config_path}) - remove_clf_btn = SimbaButton(parent=further_methods_frm, txt="REMOVE CLASSIFIER FROM SIMBA PROJECT", txt_clr='blue', font=Formats.FONT_REGULAR.value, cmd=RemoveAClassifierPopUp, cmd_kwargs={'config_path': lambda:self.config_path}) - archive_files_btn = SimbaButton(parent=further_methods_frm, txt="ARCHIVE PROCESSED FILES IN SIMBA PROJECT", txt_clr='blue', font=Formats.FONT_REGULAR.value, cmd=ArchiveProcessedFilesPopUp, cmd_kwargs={'config_path': lambda:self.config_path}) - reverse_btn = SimbaButton(parent=further_methods_frm, txt="REVERSE TRACKING IDENTITIES IN SIMBA PROJECT", txt_clr='blue', font=Formats.FONT_REGULAR.value, cmd=None) - interpolate_btn = SimbaButton(parent=further_methods_frm, txt="INTERPOLATE POSE IN SIMBA PROJECT", txt_clr='blue', font=Formats.FONT_REGULAR.value, cmd=InterpolatePopUp, cmd_kwargs={'config_path': lambda:self.config_path}) - smooth_btn = SimbaButton(parent=further_methods_frm, txt="SMOOTH POSE IN SIMBA PROJECT", txt_clr='blue', font=Formats.FONT_REGULAR.value, cmd=SmoothingPopUp, cmd_kwargs={'config_path': lambda:self.config_path}) + extract_frm_btn = SimbaButton(parent=further_methods_frm, txt="EXTRACT FRAMES FOR ALL VIDEOS IN SIMBA PROJECT", txt_clr='blue', compound='right', img='image', font=Formats.FONT_REGULAR.value, cmd=extract_frames_from_all_videos_in_directory, cmd_kwargs={'config_path': lambda:self.config_path, 'directory': lambda:self.video_dir}) + import_frm_dir_btn = SimbaButton(parent=further_methods_frm, txt="IMPORT FRAMES DIRECTORY TO SIMBA PROJECT", txt_clr='blue', compound='right', img='import', font=Formats.FONT_REGULAR.value, cmd=ImportFrameDirectoryPopUp, cmd_kwargs={'config_path': lambda:self.config_path}) + add_clf_btn = SimbaButton(parent=further_methods_frm, txt="ADD CLASSIFIER TO SIMBA PROJECT", txt_clr='blue', compound='right', img='plus', font=Formats.FONT_REGULAR.value, cmd=AddClfPopUp, cmd_kwargs={'config_path': lambda:self.config_path}) + remove_clf_btn = SimbaButton(parent=further_methods_frm, txt="REMOVE CLASSIFIER FROM SIMBA PROJECT", txt_clr='blue', compound='right', img='trash', font=Formats.FONT_REGULAR.value, cmd=RemoveAClassifierPopUp, cmd_kwargs={'config_path': lambda:self.config_path}) + archive_files_btn = SimbaButton(parent=further_methods_frm, txt="ARCHIVE PROCESSED FILES IN SIMBA PROJECT", txt_clr='blue', compound='right', img='archive', font=Formats.FONT_REGULAR.value, cmd=ArchiveProcessedFilesPopUp, cmd_kwargs={'config_path': lambda:self.config_path}) + reverse_btn = SimbaButton(parent=further_methods_frm, txt="REVERSE TRACKING IDENTITIES IN SIMBA PROJECT", txt_clr='blue', compound='right', img='reverse_blue', font=Formats.FONT_REGULAR.value, cmd=None) + interpolate_btn = SimbaButton(parent=further_methods_frm, txt="INTERPOLATE POSE IN SIMBA PROJECT", txt_clr='blue', compound='right', img='line_chart_blue', font=Formats.FONT_REGULAR.value, cmd=InterpolatePopUp, cmd_kwargs={'config_path': lambda:self.config_path}) + smooth_btn = SimbaButton(parent=further_methods_frm, txt="SMOOTH POSE IN SIMBA PROJECT", txt_clr='blue', compound='right', img='wand_blue', font=Formats.FONT_REGULAR.value, cmd=SmoothingPopUp, cmd_kwargs={'config_path': lambda:self.config_path}) label_setscale = CreateLabelFrameWithIcon(parent=tab3, header="VIDEO PARAMETERS (FPS, RESOLUTION, PPX/MM ....)", icon_name=Keys.DOCUMENTATION.value, icon_link=Links.VIDEO_PARAMETERS.value) self.distance_in_mm_eb = Entry_Box(label_setscale, "KNOWN DISTANCE (MILLIMETERS)", "25", validation="numeric") @@ -347,13 +347,13 @@ def activate(box, *args): roi_feature_frm = CreateLabelFrameWithIcon(parent=tab5, header="APPEND ROI FEATURES", icon_name=Keys.DOCUMENTATION.value, icon_link=Links.APPEND_ROI_FEATURES.value) - append_roi_features_by_animal = SimbaButton(parent=roi_feature_frm, txt="APPEND ROI DATA TO FEATURES: BY ANIMAL (CAUTION)", txt_clr='red', font=Formats.FONT_REGULAR.value, cmd=AppendROIFeaturesByAnimalPopUp, cmd_kwargs={'config_path': lambda:self.config_path}, thread=True) - append_roi_features_by_body_part = SimbaButton(parent=roi_feature_frm, txt="APPEND ROI DATA TO FEATURES: BY BODY-PARTS (CAUTION)", txt_clr='orange', font=Formats.FONT_REGULAR.value, cmd=AppendROIFeaturesByBodyPartPopUp, cmd_kwargs={'config_path': lambda:self.config_path}, thread=False) - remove_roi_features_from_feature_set = SimbaButton(parent=roi_feature_frm, txt="REMOVE ROI FEATURES FROM FEATURE SET", txt_clr='darkred', font=Formats.FONT_REGULAR.value, cmd=RemoveROIFeaturesPopUp, cmd_kwargs={'config_path': lambda:self.config_path, 'dataset': lambda:'features_extracted'}, thread=False) + append_roi_features_by_animal = SimbaButton(parent=roi_feature_frm, txt="APPEND ROI DATA TO FEATURES: BY ANIMAL (CAUTION)", txt_clr='red', img='join_red', font=Formats.FONT_REGULAR.value, cmd=AppendROIFeaturesByAnimalPopUp, cmd_kwargs={'config_path': lambda:self.config_path}, thread=True) + append_roi_features_by_body_part = SimbaButton(parent=roi_feature_frm, txt="APPEND ROI DATA TO FEATURES: BY BODY-PARTS (CAUTION)", img='join_yellow', txt_clr='orange', font=Formats.FONT_REGULAR.value, cmd=AppendROIFeaturesByBodyPartPopUp, cmd_kwargs={'config_path': lambda:self.config_path}, thread=False) + remove_roi_features_from_feature_set = SimbaButton(parent=roi_feature_frm, txt="REMOVE ROI FEATURES FROM FEATURE SET", txt_clr='darkred', img='trash', font=Formats.FONT_REGULAR.value, cmd=RemoveROIFeaturesPopUp, cmd_kwargs={'config_path': lambda:self.config_path, 'dataset': lambda:'features_extracted'}, thread=False) feature_tools_frm = LabelFrame(tab5, text="FEATURE TOOLS", pady=5, font=Formats.FONT_HEADER.value) - compute_feature_subset_btn = SimbaButton(parent=feature_tools_frm, txt="CALCULATE FEATURE SUBSETS", txt_clr='blue', font=Formats.FONT_REGULAR.value, cmd=FeatureSubsetExtractorPopUp, cmd_kwargs={'config_path': lambda: self.config_path}, thread=False) + compute_feature_subset_btn = SimbaButton(parent=feature_tools_frm, txt="CALCULATE FEATURE SUBSETS", txt_clr='blue', img='subset_blue', font=Formats.FONT_REGULAR.value, cmd=FeatureSubsetExtractorPopUp, cmd_kwargs={'config_path': lambda: self.config_path}, thread=False) label_behavior_frm = CreateLabelFrameWithIcon(parent=tab7, header="LABEL BEHAVIOR", icon_name=Keys.DOCUMENTATION.value, icon_link=Links.LABEL_BEHAVIOR.value) select_video_btn_new = SimbaButton(parent=label_behavior_frm, txt="Select video (create new video annotation)", img='label_blue', txt_clr='navy', cmd=select_labelling_video, cmd_kwargs={'config_path': lambda :self.config_path, 'threshold_dict': lambda: None, 'setting': lambda: "from_scratch", 'continuing': lambda: False}, thread=False) @@ -426,10 +426,10 @@ def activate(box, *args): button_run_rfmodelsettings = SimbaButton(parent=label_runmachinemodel, txt="MODEL SETTINGS", txt_clr='green', img='settings', cmd=SetMachineModelParameters, cmd_kwargs={'config_path': lambda:config_path}) button_runmachinemodel = SimbaButton(parent=label_runmachinemodel, txt="RUN MODELS", txt_clr='green', img='clf', cmd=self.runrfmodel, thread=True) - kleinberg_button = SimbaButton(parent=label_runmachinemodel, txt="KLEINBERG SMOOTHING", txt_clr='green', cmd=KleinbergPopUp, cmd_kwargs={'config_path': lambda:self.config_path}) - fsttc_button = SimbaButton(parent=label_runmachinemodel, txt="FSTTC", txt_clr='green', cmd=FSTTCPopUp, cmd_kwargs={'config_path': lambda:self.config_path}) + kleinberg_button = SimbaButton(parent=label_runmachinemodel, txt="KLEINBERG SMOOTHING", txt_clr='green', img='feather_green', cmd=KleinbergPopUp, cmd_kwargs={'config_path': lambda:self.config_path}) + fsttc_button = SimbaButton(parent=label_runmachinemodel, txt="FSTTC", txt_clr='green', img='tile_green', cmd=FSTTCPopUp, cmd_kwargs={'config_path': lambda:self.config_path}) - mutual_exclusivity = SimbaButton(parent=label_runmachinemodel, txt="MUTUAL EXCLUSIVITY CORRECTION", txt_clr='green', cmd=MutualExclusivityPupUp, cmd_kwargs={'config_path': lambda:self.config_path}) + mutual_exclusivity = SimbaButton(parent=label_runmachinemodel, txt="MUTUAL EXCLUSIVITY CORRECTION", img='seperate_green', txt_clr='green', cmd=MutualExclusivityPupUp, cmd_kwargs={'config_path': lambda:self.config_path}) label_machineresults = CreateLabelFrameWithIcon( parent=tab9, header="ANALYZE MACHINE RESULTS", icon_name=Keys.DOCUMENTATION.value, icon_link=Links.ANALYZE_ML_RESULTS.value) diff --git a/simba/assets/icons/feather_green.png b/simba/assets/icons/feather_green.png new file mode 100644 index 000000000..21fa3947c Binary files /dev/null and b/simba/assets/icons/feather_green.png differ diff --git a/simba/assets/icons/join_purple.png b/simba/assets/icons/join_purple.png new file mode 100644 index 000000000..0ff372343 Binary files /dev/null and b/simba/assets/icons/join_purple.png differ diff --git a/simba/assets/icons/join_red.png b/simba/assets/icons/join_red.png new file mode 100644 index 000000000..4e5c9d513 Binary files /dev/null and b/simba/assets/icons/join_red.png differ diff --git a/simba/assets/icons/join_yellow.png b/simba/assets/icons/join_yellow.png new file mode 100644 index 000000000..ce801b4bf Binary files /dev/null and b/simba/assets/icons/join_yellow.png differ diff --git a/simba/assets/icons/line_chart_blue.png b/simba/assets/icons/line_chart_blue.png new file mode 100644 index 000000000..95a1ec4b6 Binary files /dev/null and b/simba/assets/icons/line_chart_blue.png differ diff --git a/simba/assets/icons/seperate_green.png b/simba/assets/icons/seperate_green.png new file mode 100644 index 000000000..87e0973e3 Binary files /dev/null and b/simba/assets/icons/seperate_green.png differ diff --git a/simba/assets/icons/subset_blue.png b/simba/assets/icons/subset_blue.png new file mode 100644 index 000000000..114cccca4 Binary files /dev/null and b/simba/assets/icons/subset_blue.png differ diff --git a/simba/assets/icons/tile_green.png b/simba/assets/icons/tile_green.png new file mode 100644 index 000000000..67ff5e117 Binary files /dev/null and b/simba/assets/icons/tile_green.png differ diff --git a/simba/assets/icons/wand_blue.png b/simba/assets/icons/wand_blue.png new file mode 100644 index 000000000..6af93db70 Binary files /dev/null and b/simba/assets/icons/wand_blue.png differ diff --git a/simba/ui/pop_ups/clf_probability_plot_pop_up.py b/simba/ui/pop_ups/clf_probability_plot_pop_up.py index a55c3ed00..48e331ba6 100644 --- a/simba/ui/pop_ups/clf_probability_plot_pop_up.py +++ b/simba/ui/pop_ups/clf_probability_plot_pop_up.py @@ -35,13 +35,13 @@ class VisualizeClassificationProbabilityPopUp(PopUpMixin, ConfigReader): def __init__(self, config_path: Union[str, os.PathLike]): - PopUpMixin.__init__(self, title="CREATE CLASSIFICATION PROBABILITY PLOTS") ConfigReader.__init__(self, config_path=config_path, read_video_info=False) color_names = get_color_dict().keys() self.max_y_lst = [x for x in range(10, 110, 10)] self.max_y_lst.insert(0, "auto") self.files_found_dict = get_file_name_info_in_directory(directory=self.machine_results_dir, file_type=self.file_type) check_if_filepath_list_is_empty(filepaths=list(self.files_found_dict.keys()), error_msg=f"Cannot visualize probabilities, no data in {self.machine_results_dir} directory") + PopUpMixin.__init__(self, title="CREATE CLASSIFICATION PROBABILITY PLOTS") self.style_settings_frm = CreateLabelFrameWithIcon(parent=self.main_frm, header="STYLE SETTINGS", icon_name=Keys.DOCUMENTATION.value, icon_link=Links.VISUALIZE_CLF_PROBABILITIES.value) self.resolution_dropdown = DropDownMenu(self.style_settings_frm, "Resolution:", self.resolutions, "16") diff --git a/simba/ui/pop_ups/clf_validation_plot_pop_up.py b/simba/ui/pop_ups/clf_validation_plot_pop_up.py index aa7ca9e76..8dabe0d67 100644 --- a/simba/ui/pop_ups/clf_validation_plot_pop_up.py +++ b/simba/ui/pop_ups/clf_validation_plot_pop_up.py @@ -8,11 +8,11 @@ from simba.mixins.config_reader import ConfigReader from simba.mixins.pop_up_mixin import PopUpMixin from simba.plotting.clf_validator import ClassifierValidationClips -from simba.ui.tkinter_functions import (CreateLabelFrameWithIcon, DropDownMenu, - Entry_Box, SimbaButton, SimbaCheckbox) +from simba.ui.tkinter_functions import (CreateLabelFrameWithIcon, DropDownMenu, Entry_Box, SimbaButton, SimbaCheckbox) from simba.utils.checks import check_int from simba.utils.enums import Formats, Keys, Links, Options from simba.utils.read_write import get_file_name_info_in_directory +from simba.utils.errors import NoDataError class ClassifierValidationPopUp(PopUpMixin, ConfigReader): @@ -23,11 +23,12 @@ class ClassifierValidationPopUp(PopUpMixin, ConfigReader): """ def __init__(self, config_path: Union[str, os.PathLike]): - - PopUpMixin.__init__(self, title="SIMBA CLASSIFIER VALIDATION CLIPS") ConfigReader.__init__(self, config_path=config_path, read_video_info=False) - color_names = list(self.colors_dict.keys()) self.files_found_dict = get_file_name_info_in_directory(directory=self.machine_results_dir, file_type=self.file_type) + if len(list(self.files_found_dict.keys())) == 0: + raise NoDataError(msg=f'No data found in the {self.machine_results_dir} directory. This is required for creating validation clips.', source=self.__class__.__name__) + PopUpMixin.__init__(self, title="SIMBA CLASSIFIER VALIDATION CLIPS") + color_names = list(self.colors_dict.keys()) self.settings_frm = CreateLabelFrameWithIcon(parent=self.main_frm,header="SETTINGS",icon_name=Keys.DOCUMENTATION.value,icon_link=Links.CLF_VALIDATION.value) self.seconds_entry = Entry_Box(self.settings_frm, "SECONDS PADDING: ", "20", validation="numeric") self.clf_dropdown = DropDownMenu(self.settings_frm, "CLASSIFIER: ", self.clf_names, "20") diff --git a/simba/ui/tkinter_functions.py b/simba/ui/tkinter_functions.py index 590286f10..cfeaae7cf 100644 --- a/simba/ui/tkinter_functions.py +++ b/simba/ui/tkinter_functions.py @@ -417,6 +417,7 @@ def SimbaButton(parent: Union[Frame, Canvas, LabelFrame, Toplevel], font: Optional[Tuple] = Formats.FONT_REGULAR.value, width: Optional[str] = None, height: Optional[str] = None, + compound: Optional[str] = 'left', img: Optional[Union[ImageTk.PhotoImage, str]] = None, cmd: Optional[Callable] = None, cmd_kwargs: Optional[Dict[Any, Any]] = None, @@ -444,7 +445,7 @@ def execute_command(): btn = Button(master=parent, text=txt, - compound="left", + compound=compound, image=img, relief=RAISED, fg=txt_clr,