Skip to content

Commit

Permalink
btns
Browse files Browse the repository at this point in the history
  • Loading branch information
sronilsson committed Aug 2, 2024
1 parent ea8d3c9 commit cb4bd8e
Show file tree
Hide file tree
Showing 26 changed files with 65 additions and 49 deletions.
68 changes: 34 additions & 34 deletions simba/SimBA.py

Large diffs are not rendered by default.

Binary file added simba/assets/icons/SimBA_logo_3.ico
Binary file not shown.
Binary file added simba/assets/icons/SimBA_logo_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added simba/assets/icons/bar_graph_blue.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added simba/assets/icons/check_blue.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added simba/assets/icons/dice_green.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added simba/assets/icons/direction.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added simba/assets/icons/direction_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added simba/assets/icons/distance_red.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added simba/assets/icons/interactive_blue.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added simba/assets/icons/label_blue.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added simba/assets/icons/label_yellow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added simba/assets/icons/mars.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added simba/assets/icons/metrics_blue.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added simba/assets/icons/metrics_green.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added simba/assets/icons/multiple_green.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added simba/assets/icons/one.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added simba/assets/icons/one_blue.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added simba/assets/icons/split.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added simba/assets/icons/t.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added simba/assets/icons/zero.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 5 additions & 7 deletions simba/mixins/train_model_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from sklearn.ensemble import RandomForestClassifier
from sklearn.feature_selection import VarianceThreshold
from sklearn.inspection import partial_dependence, permutation_importance
from sklearn.metrics import precision_recall_curve
from sklearn.metrics import precision_recall_curve, classification_report
from sklearn.model_selection import ShuffleSplit, learning_curve
from sklearn.preprocessing import (MinMaxScaler, QuantileTransformer,
StandardScaler)
Expand Down Expand Up @@ -322,6 +322,7 @@ def smote_oversampler(
else:
return smt.fit_resample(x_train, y_train)


def calc_permutation_importance(self,
x_test: np.ndarray,
y_test: np.ndarray,
Expand Down Expand Up @@ -1373,9 +1374,6 @@ def clf_define(self,
raise SimBAModuleNotFoundError(msg='SimBA could not find the cuml library for GPU machine learning algorithms.', source=self.__class__.__name__)





def clf_fit(self,
clf: Union[RandomForestClassifier, cuRF],
x_df: pd.DataFrame,
Expand Down Expand Up @@ -1852,9 +1850,7 @@ def create_shap_log_mp(
save_file_no=save_file_no,
)

def check_df_dataset_integrity(
self, df: pd.DataFrame, file_name: str, logs_path: Union[str, os.PathLike]
) -> None:
def check_df_dataset_integrity(self, df: pd.DataFrame, file_name: str, logs_path: Union[str, os.PathLike]) -> None:
"""
Helper to check for non-numerical np.inf, -np.inf, NaN, None in a single dataframe.
:parameter pd.DataFrame x_df: Features
Expand Down Expand Up @@ -2686,6 +2682,8 @@ def find_low_variance_fields(
return low_variance_fields




# test = TrainModelMixin()
# test.read_all_files_in_folder(file_paths=['/Users/simon/Desktop/envs/troubleshooting/jake/project_folder/csv/targets_inserted/22-437C_c3_2022-11-01_13-16-23_color.csv', '/Users/simon/Desktop/envs/troubleshooting/jake/project_folder/csv/targets_inserted/22-437D_c4_2022-11-01_13-16-39_color.csv'],
# file_type='csv', classifier_names=['attack', 'non-agresive parallel swimming'])
Expand Down
17 changes: 16 additions & 1 deletion simba/pose_importers/sleap_h5_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def __init__(self,
config_path: Union[str, os.PathLike],
data_folder: Union[str, os.PathLike],
id_lst: List[str],
interpolation_settings: str,
interpolation_settings: Union[str, None],
smoothing_settings: Union[Dict[str, Any], None]):

ConfigReader.__init__(self, config_path=config_path, read_video_info=False)
Expand Down Expand Up @@ -102,11 +102,13 @@ def run(self):

csv_rows = []
n_frames, n_nodes, _, n_tracks = tracks.shape
print(tracks)
for frame_ind in range(n_frames):
csv_row = []
for track_ind in range(n_tracks):
for node_ind in range(n_nodes):
for xyp in range(3):
#print(tracks[frame_ind])
if xyp == 0 or xyp == 1:
data = tracks[frame_ind, node_ind, xyp, track_ind]
else:
Expand Down Expand Up @@ -143,6 +145,19 @@ def run(self):
self.timer.stop_timer()
stdout_success(msg="All SLEAP H5 data files imported", elapsed_time=self.timer.elapsed_time_str, source=self.__class__.__name__)



#
#
# test = SLEAPImporterH5(config_path=r"C:\troubleshooting\slp_single_rat\project_folder\project_config.ini",
# data_folder=r"C:\troubleshooting\slp_single_rat\h5",
# id_lst=['Jarryd'],
# interpolation_settings=None,
# smoothing_settings = None)
# test.run()



# test = SLEAPImporterH5(config_path="/Users/simon/Desktop/envs/simba/troubleshooting/sleap_two_animals/project_folder/project_config.ini",
# data_folder=r'/Users/simon/Desktop/envs/simba/troubleshooting/sleap_two_animals/h5_import',
# id_lst=['White', 'Black'],
Expand Down
7 changes: 6 additions & 1 deletion simba/ui/pop_ups/make_path_plot_pop_up.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,13 @@ def __init__(self):
self.body_part = Entry_Box(settings_frm, "BODY PART: ", "30")
self.data_path = FileSelect(settings_frm, "DATA PATH (e.g., H5 or CSV file): ", lblwidth="30")
color_lst = list(get_color_dict().keys())


self.background_color = DropDownMenu(settings_frm, "BACKGROUND COLOR: ", color_lst, "30")
self.background_color.setChoices(choice="White")



self.line_color = DropDownMenu(settings_frm, "LINE COLOR: ", color_lst, "30")
self.line_color.setChoices(choice="Red")
self.line_thickness = DropDownMenu(settings_frm, "LINE THICKNESS: ", list(range(1, 11)), "30")
Expand Down Expand Up @@ -82,4 +87,4 @@ def run(self):
threading.Thread(target=plotter.run).start()


# MakePathPlotPopUp()
#MakePathPlotPopUp()
6 changes: 2 additions & 4 deletions simba/ui/pop_ups/quick_path_plot_pop_up.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def __init__(self, config_path: Union[str, os.PathLike]):

check_file_exist_and_readable(file_path=config_path)
PopUpMixin.__init__(self, title="SIMPLE LINE PLOT")
ConfigReader.__init__(self, config_path=config_path, read_video_info=False)
ConfigReader.__init__(self, config_path=config_path)
if len(self.outlier_corrected_paths) == 0:
raise NoFilesFoundError(
msg=f"No data found in the {self.outlier_corrected_paths} directory. Place files in this directory to create quick path plots."
Expand Down Expand Up @@ -81,9 +81,7 @@ def __init__(self, config_path: Union[str, os.PathLike]):
def run(self):
video_name = self.video_dropdown.getChoices()
data_path = self.video_filepaths[video_name]
meta_data, _, fps = read_video_info(
vid_info_df=self.video_info_df, video_name=video_name
)
meta_data, _, fps = read_video_info(vid_info_df=self.video_info_df, video_name=video_name)
size = (int(meta_data["Resolution_width"]), int(meta_data["Resolution_height"]))
last_frm = self.last_frm_only_dropdown.getChoices()
if last_frm == "TRUE":
Expand Down
4 changes: 2 additions & 2 deletions simba/utils/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ class Paths(Enum):
SPLASH_PATH_LINUX = Path("assets/img/splash.PNG")
SPLASH_PATH_MOVIE = Path("assets/img/splash_2024.mp4")
BG_IMG_PATH = Path("assets/img/bg_2024.png")
LOGO_ICON_WINDOWS_PATH = Path("assets/icons/SimBA_logo.ico")
LOGO_ICON_DARWIN_PATH = Path("assets/icons/SimBA_logo.png")
LOGO_ICON_WINDOWS_PATH = Path("assets/icons/SimBA_logo_3.ico")
LOGO_ICON_DARWIN_PATH = Path("assets/icons/SimBA_logo_3.png")
UNSUPERVISED_MODEL_NAMES = Path("assets/lookups/model_names.parquet")
CRITICAL_VALUES = Path("simba/assets/lookups/critical_values_05.pickle")

Expand Down

0 comments on commit cb4bd8e

Please sign in to comment.