Skip to content

Commit

Permalink
cleaned
Browse files Browse the repository at this point in the history
  • Loading branch information
sronilsson committed Oct 22, 2023
1 parent 5943b7c commit 54859e1
Show file tree
Hide file tree
Showing 11 changed files with 96 additions and 83 deletions.
27 changes: 14 additions & 13 deletions simba/SimBA.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,14 @@
from simba.ui.pop_ups.movement_analysis_pop_up import MovementAnalysisPopUp
from simba.ui.pop_ups.movement_analysis_time_bins_pop_up import \
MovementAnalysisTimeBinsPopUp
#from simba.ui.pop_ups.mutual_exclusivity_pop_up import MutualExclusivityPupUp
# from simba.ui.pop_ups.mutual_exclusivity_pop_up import MutualExclusivityPupUp
from simba.ui.pop_ups.outlier_settings_pop_up import OutlierSettingsPopUp
from simba.ui.pop_ups.path_plot_pop_up import PathPlotPopUp
from simba.ui.pop_ups.pose_bp_drop_pop_up import DropTrackingDataPopUp
from simba.ui.pop_ups.pose_reorganizer_pop_up import PoseReorganizerPopUp
from simba.ui.pop_ups.pup_retrieval_pop_up import PupRetrievalPopUp
from simba.ui.pop_ups.quick_path_plot_pop_up import QuickLineplotPopup
#from simba.ui.pop_ups.remove_roi_features_pop_up import RemoveROIFeaturesPopUp
# from simba.ui.pop_ups.remove_roi_features_pop_up import RemoveROIFeaturesPopUp
from simba.ui.pop_ups.roi_analysis_pop_up import ROIAnalysisPopUp
from simba.ui.pop_ups.roi_analysis_time_bins_pop_up import \
ROIAnalysisTimeBinsPopUp
Expand All @@ -114,10 +114,9 @@
ClipVideoPopUp, ConcatenatingVideosPopUp, ConcatenatorPopUp,
ConvertVideoPopUp, CreateGIFPopUP, CropVideoPopUp, DownsampleVideoPopUp,
ExtractAllFramesPopUp, ExtractAnnotationFramesPopUp, ExtractSEQFramesPopUp,
ExtractSpecificFramesPopUp,
ImportFrameDirectoryPopUp, MergeFrames2VideoPopUp, MultiCropPopUp,
MultiShortenPopUp, VideoRotatorPopUp,
VideoTemporalJoinPopUp)
ExtractSpecificFramesPopUp, ImportFrameDirectoryPopUp,
MergeFrames2VideoPopUp, MultiCropPopUp, MultiShortenPopUp,
VideoRotatorPopUp, VideoTemporalJoinPopUp)
from simba.ui.pop_ups.visualize_pose_in_dir_pop_up import \
VisualizePoseInFolderPopUp
from simba.ui.tkinter_functions import DropDownMenu, Entry_Box, FileSelect
Expand All @@ -138,7 +137,7 @@

# from simba.unsupervised.unsupervised_ui import UnsupervisedGUI

sys.setrecursionlimit(10 ** 6)
sys.setrecursionlimit(10**6)
currentPlatform = platform.system()


Expand All @@ -155,7 +154,9 @@ def __init__(self):
icon_link=Links.LOAD_PROJECT.value,
)
self.selected_file = FileSelect(
self.load_project_frm, "Select file: ", title="Select project_config.ini file"
self.load_project_frm,
"Select file: ",
title="Select project_config.ini file",
)
self.load_project_btn = Button(
self.load_project_frm,
Expand Down Expand Up @@ -1128,7 +1129,7 @@ def activate(box, *args):
roi_feature_frm.grid(row=1, column=0, sticky=NW)
append_roi_features_by_animal.grid(row=0, column=0, sticky=NW)
append_roi_features_by_body_part.grid(row=1, column=0, sticky=NW)
#remove_roi_features_from_feature_set.grid(row=2, column=0, sticky=NW)
# remove_roi_features_from_feature_set.grid(row=2, column=0, sticky=NW)

feature_tools_frm.grid(row=2, column=0, sticky=NW)
compute_feature_subset_btn.grid(row=0, column=0, sticky=NW)
Expand Down Expand Up @@ -1162,7 +1163,7 @@ def activate(box, *args):
lbl_tools_frm.grid(row=9, column=0, sticky=NW)
visualize_annotation_img_btn.grid(row=0, column=0, sticky=NW)
third_party_annotations_btn.grid(row=1, column=0, sticky=NW)
#remove_roi_features_from_annotation_set.grid(row=2, column=0, sticky=NW)
# remove_roi_features_from_annotation_set.grid(row=2, column=0, sticky=NW)

label_trainmachinemodel.grid(row=6, sticky=W)
button_trainmachinesettings.grid(row=0, column=0, sticky=NW, padx=5)
Expand All @@ -1183,7 +1184,7 @@ def activate(box, *args):
button_runmachinemodel.grid(row=1, sticky=NW)
kleinberg_button.grid(row=2, sticky=NW)
fsttc_button.grid(row=3, sticky=NW)
#mutual_exclusivity.grid(row=4, sticky=NW)
# mutual_exclusivity.grid(row=4, sticky=NW)

label_machineresults.grid(row=9, sticky=W, pady=5)
button_process_datalog.grid(row=2, column=0, sticky=W, padx=3)
Expand Down Expand Up @@ -1831,13 +1832,13 @@ def __init__(self):
if OS.PYTHON_VER.value != "3.6":
PythonVersionWarning(
msg=f"SimBA is not extensively tested beyond python 3.6. You are using python {OS.PYTHON_VER.value}. If you encounter errors in python>3.6, please report them on GitHub or Gitter and we will fix! (links in the help toolbar)",
source="python different than 3.6"
source="python different than 3.6",
)

if not check_ffmpeg_available():
FFMpegNotFoundWarning(
msg='SimBA could not find a FFMPEG installation on computer (as evaluated by "ffmpeg" returning None). SimBA works best with FFMPEG and it is recommended to install it on your computer',
source="ffmpeg checker"
source="ffmpeg checker",
)

def restart(self):
Expand Down
2 changes: 1 addition & 1 deletion simba/data_processors/agg_clf_calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def save(self) -> None:
self.results_df = (
self.results_df[
self.results_df["Measure"].isin(
self.chosen_measures# + self.video_meta_data
self.chosen_measures # + self.video_meta_data
)
]
.sort_values(by=["Video", "Classifier", "Measure"])
Expand Down
3 changes: 2 additions & 1 deletion simba/mixins/train_model_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1290,7 +1290,8 @@ def clf_predict_proba(
else:
raise FeatureNumberMismatchError(
f"The model expects {clf_n_features} features. The data contains {len(x_df.columns)} features.",
source=self.__class__.__name__)
source=self.__class__.__name__,
)
p_vals = clf.predict_proba(x_df)
if p_vals.shape[1] != 2:
raise ClassifierInferenceError(
Expand Down
46 changes: 23 additions & 23 deletions simba/roi_tools/ROI_define.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class ROI_definitions(ConfigReader):
"""

def __init__(self, config_path: str, video_path: str,image_data : ROI_image_class):
def __init__(self, config_path: str, video_path: str, image_data: ROI_image_class):
ConfigReader.__init__(self, config_path=config_path)
self.video_path = video_path
_, self.file_name, self.file_ext = get_fn_ext(self.video_path)
Expand Down Expand Up @@ -110,7 +110,6 @@ def on_close(self):
self.master.destroy()
self.root.destroy()


def show_video_info(self):
self.video_info_frame = LabelFrame(
self.master,
Expand Down Expand Up @@ -313,7 +312,7 @@ def apply_from_other_videos_menu(self):
)
self.apply_from_other_video.grid(row=7, sticky=W)
self.video_dropdown.config(direction=RIGHT)
self.video_dropdown.grid(row=1, column=1,sticky="ew", pady=20)
self.video_dropdown.grid(row=1, column=1, sticky="ew", pady=20)
self.apply_button.grid(row=1, column=3, sticky=W, pady=10)

def select_shape(self):
Expand Down Expand Up @@ -545,10 +544,10 @@ def draw_menu(self):

def show_shape_information(self):
if (
len(self.image_data.out_rectangles)
+ len(self.image_data.out_circles)
+ len(self.image_data.out_polygon)
== 0
len(self.image_data.out_rectangles)
+ len(self.image_data.out_circles)
+ len(self.image_data.out_polygon)
== 0
):
print("No shapes to print info for.")

Expand Down Expand Up @@ -691,10 +690,10 @@ def set_interact_state(self, c_interact):
def call_delete_all_rois(self):
self.shape_info_btn.configure(text="Show shape info.")
if (
len(self.image_data.out_rectangles)
+ len(self.image_data.out_circles)
+ len(self.image_data.out_polygon)
== 0
len(self.image_data.out_rectangles)
+ len(self.image_data.out_circles)
+ len(self.image_data.out_polygon)
== 0
):
NoDataFoundWarning(msg="SimBA finds no ROIs to delete.")
else:
Expand All @@ -714,7 +713,7 @@ def get_duplicate_shape_name(self):
c_no += 1
else:
self.new_shape_data["Name"] = (
str(self.shape_type) + ": " + self.new_name
str(self.shape_type) + ": " + self.new_name
)
break

Expand All @@ -728,7 +727,7 @@ def get_duplicate_coords(self):
)
for shape in self.image_data.out_rectangles:
if (shape["topLeftX"] == self.new_shape_x) and (
shape["topLeftY"] == self.new_shape_y
shape["topLeftY"] == self.new_shape_y
):
self.new_shape_x += self.duplicate_jump_size
self.new_shape_y += self.duplicate_jump_size
Expand All @@ -741,7 +740,7 @@ def get_duplicate_coords(self):
)
for shape in self.image_data.out_circles:
if (shape["centerY"] == self.new_shape_x) and (
shape["centerY"] == self.new_shape_y
shape["centerY"] == self.new_shape_y
):
self.new_shape_x += self.duplicate_jump_size
self.new_shape_y += self.duplicate_jump_size
Expand All @@ -754,7 +753,7 @@ def get_duplicate_coords(self):
)
for shape in self.image_data.out_polygon:
if (shape["Center_X"] == self.new_shape_x) and (
shape["centerY"] == self.new_shape_y
shape["centerY"] == self.new_shape_y
):
self.new_shape_x += self.duplicate_jump_size
self.new_shape_y += self.duplicate_jump_size
Expand All @@ -764,9 +763,9 @@ def call_duplicate_ROI(self):
self.shape_info_btn.configure(text="Show shape info.")
if shape_name[0] != "None":
all_roi_list = (
self.image_data.out_rectangles
+ self.image_data.out_circles
+ self.image_data.out_polygon
self.image_data.out_rectangles
+ self.image_data.out_circles
+ self.image_data.out_polygon
)
self.shape_type, shape_name = shape_name[0], shape_name[1]
self.current_shape_data = [
Expand Down Expand Up @@ -849,11 +848,11 @@ def save_data(self):
polygons_found = pd.read_hdf(self.roi_coordinates_path, key="polygons")
other_vid_rectangles = rectangles_found[
rectangles_found["Video"] != self.file_name
]
]
other_vid_circles = circles_found[circles_found["Video"] != self.file_name]
other_vid_polygons = polygons_found[
polygons_found["Video"] != self.file_name
]
]

new_rectangles = pd.DataFrame.from_dict(self.image_data.out_rectangles)
new_circles = pd.DataFrame.from_dict(self.image_data.out_circles)
Expand Down Expand Up @@ -916,9 +915,9 @@ def __init__(self, shape_data, image_data):
shape_name = shape_data.selected_video.get().split(": ")
if shape_name[0] != "None":
self.all_roi_list = (
shape_data.image_data.out_rectangles
+ shape_data.image_data.out_circles
+ shape_data.image_data.out_polygon
shape_data.image_data.out_rectangles
+ shape_data.image_data.out_circles
+ shape_data.image_data.out_polygon
)
self.shape_type, self.shape_name = shape_name[0], shape_name[1]
current_shape_data = [
Expand Down Expand Up @@ -1119,6 +1118,7 @@ def save_prefs(self, image_data):
image_data.duplicate_jump_size = self.duplicate_jump_size.get()
stdout_success(msg="Saved ROI preference settings.")


#
# test = ROI_definitions(config_path='/Users/simon/Desktop/envs/simba_dev/tests/test_data/mouse_open_field/project_folder/project_config.ini',
# video_path='/Users/simon/Desktop/envs/simba_dev/tests/test_data/mouse_open_field/project_folder/videos/Video1.mp4')
Loading

0 comments on commit 54859e1

Please sign in to comment.