Skip to content

Commit

Permalink
kmeans
Browse files Browse the repository at this point in the history
  • Loading branch information
sronilsson committed Nov 26, 2024
1 parent 6091a11 commit 41cc6ad
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 14 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
# Setup configuration
setuptools.setup(
name="Simba-UW-tf-dev",
version="2.3.5",
version="2.3.6",
author="Simon Nilsson, Jia Jie Choong, Sophia Hwang",
author_email="[email protected]",
description="Toolkit for computer classification and analysis of behaviors in experimental animals",
Expand Down
4 changes: 2 additions & 2 deletions simba/data_processors/agg_clf_calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,9 @@ def save(self) -> None:
)


# test = AggregateClfCalculator(config_path=r"D:\troubleshooting\mitra\project_folder\project_config.ini",
# test = AggregateClfCalculator(config_path=r"C:\troubleshooting\mitra\project_folder\project_config.ini",
# data_measures=["Bout count", "Total event duration (s)", "Mean event bout duration (s)", "Median event bout duration (s)", "First event occurrence (s)", "Mean event bout interval duration (s)", "Median event bout interval duration (s)"],
# classifiers=['lay-on-belly'],
# classifiers=['rearing'],
# video_meta_data =['Frame count', "Video length (s)"],
# transpose=True)
# test.run()
Expand Down
11 changes: 6 additions & 5 deletions simba/data_processors/circling_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ class CirclingDetector(ConfigReader):
.. important::
Circling is detected as :underline:`present` when **the circular range of the animal is above the ``circular_range_threshold`` within the preceding ``time_threshold``** AND
**the movement of the animal (defined as the sum of the center movement) is above the ``movement_threshold`` within the preceding ``time_threshold``.**
Circling is detected as `present` when **the circular range of the animal is above the specied circular range threshold within the passed preceding time threshold** AND
**the movement of the animal (defined as the sum of the center movement) is above the specified movement threshold within the passed preceding time threshold.**
Circling is detected as :underline:`absent` when not present.
Expand Down Expand Up @@ -120,8 +120,9 @@ def run(self):
agg_results.to_csv(agg_results_path)
stdout_success(msg=f'Results saved in {self.save_dir} directory.')



# detector = CirclingDetector(data_dir=r'D:\troubleshooting\mitra\project_folder\csv\outlier_corrected_movement_location', config_path=r"D:\troubleshooting\mitra\project_folder\project_config.ini")
#
#
# detector = CirclingDetector(data_dir=r'C:\troubleshooting\mitra\project_folder\csv\outlier_corrected_movement_location',
# config_path=r"C:\troubleshooting\mitra\project_folder\project_config.ini")
# detector.run()

10 changes: 5 additions & 5 deletions simba/data_processors/freezing_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ class FreezingDetector(ConfigReader):
.. important::
Freezing is detected as :underline:`present` when ** the velocity (computed from the mean movement of the nape, nose, and tail-base body-parts) falls below
the movement threshold for the duration of the defined time-window or longer.
Freezing is detected as `present` when **the velocity (computed from the mean movement of the nape, nose, and tail-base body-parts) falls below
the movement threshold for the duration (and longer) of the specied time-window.
Freezing is detected as :underline:`absent` when not present.
Freezing is detected as `absent` when not present.
:param Union[str, os.PathLike] data_dir: Path to directory containing pose-estimated body-part data in CSV format.
:param Union[str, os.PathLike] config_path: Path to SimBA project config file.
Expand Down Expand Up @@ -90,7 +90,7 @@ def run(self):
check_all_file_names_are_represented_in_video_log(video_info_df=self.video_info_df, data_paths=self.data_paths)
for file_cnt, file_path in enumerate(self.data_paths):
video_name = get_fn_ext(filepath=file_path)[1]
print(f'Analyzing {video_name}...')
print(f'Analyzing {video_name}...({file_cnt+1}/{len(self.data_paths)})')
save_file_path = os.path.join(self.save_dir, f'{video_name}.csv')
df = read_df(file_path=file_path, file_type='csv').reset_index(drop=True)
_, px_per_mm, fps = read_video_info(vid_info_df=self.video_info_df, video_name=video_name)
Expand Down Expand Up @@ -131,4 +131,4 @@ def run(self):

#
# FreezingDetector(data_dir=r'C:\troubleshooting\mitra\project_folder\csv\outlier_corrected_movement_location',
# config_path=r"D:\troubleshooting\mitra\project_folder\project_config.ini")
# config_path=r"C:\troubleshooting\mitra\project_folder\project_config.ini")
2 changes: 1 addition & 1 deletion simba/mixins/plotting_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1909,7 +1909,7 @@ def plot_bar_chart(df: pd.DataFrame,
check_valid_lst(data=list(df[y]), source=f"{PlottingMixin.plot_bar_chart.__name__} y", valid_dtypes=Formats.NUMERIC_DTYPES.value)
fig, ax = plt.subplots(figsize=fig_size)
sns.barplot(x=x, y=y, data=df, palette=palette, ax=ax)
ax.set_xticklabels(df[x], rotation=90, fontsize=8)
ax.set_xticklabels(df[x].unique(), rotation=90, fontsize=8)
if error is not None:
check_str(name=f"{PlottingMixin.plot_bar_chart.__name__} error", value=error, options=tuple(df.columns))
check_valid_lst(data=list(df[error]), source=f"{PlottingMixin.plot_bar_chart.__name__} error",valid_dtypes=Formats.NUMERIC_DTYPES.value)
Expand Down
5 changes: 5 additions & 0 deletions simba/model/inference_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ def run(self):
self.timer.stop_timer()
stdout_success(msg=f"Machine predictions complete. Files saved in {self.save_dir} directory", elapsed_time=self.timer.elapsed_time_str, source=self.__class__.__name__)

# test = InferenceBatch(config_path=r"C:\troubleshooting\mitra\project_folder\project_config.ini")
# test.run()





# test = InferenceBatch(config_path=r"D:\troubleshooting\mitra\project_folder\project_config.ini",
Expand Down

0 comments on commit 41cc6ad

Please sign in to comment.