Cue light tools
Methods for analyzing animal behaviours associated with cue-light states through.
Analyze
- class simba.cue_light_tools.cue_light_analyzer.CueLightAnalyzer(config_path: Union[str, PathLike], in_dir: Union[str, PathLike], cue_light_names: List[str])[source]
Bases:
ConfigReader
Analyze when cue lights are in ON and OFF states. Results are stored in the
project_folder/csv/cue_lights
cue lights directory.- Parameters
Note
Examples
>>> cue_light_analyzer = CueLightAnalyzer(config_path='MyProjectConfig', in_dir='project_folder/csv/outlier_corrected_movement_location', cue_light_names=['Cue_light']) >>> cue_light_analyzer.run()
CLF Statistics
- class simba.cue_light_tools.cue_light_clf_statistics.CueLightClfAnalyzer(config_path: Union[str, PathLike], pre_window: int, post_window: int, cue_light_names: List[str], clf_list: List[str])[source]
Bases:
ConfigReader
Compute aggregate statistics when classified behaviors are occurring in relation to the cue light ON and OFF states.
- Parameters
config_path (str) – path to SimBA project config file in Configparser format
pre_window (int) – Time period (in millisecond) before the onset of each cue light to compute aggregate classification statistics within.
post_window (int) – Time period (in millisecond) after the offset of each cue light to compute aggregate classification statistics within.
cue_light_names (List[str]) – Names of cue lights, as defined in the SimBA ROI interface.
list (List[str]) – Names of the classifiers we want to compute aggregate statistics for.
Note
Examples
>>> cue_light_clf_analyzer = CueLightClfAnalyzer(config_path='MyProjectConfig', pre_window=1000, post_window=1000, cue_light_names=['Cue_light'], clf_list=['Attack']) >>> cue_light_clf_analyzer.analyze_clf() >>> cue_light_clf_analyzer.organize_results() >>> cue_light_clf_analyzer.save_data()
- analyze_clf()[source]
Method to calculate classifier data during cue lights periods
- Returns
Attribute – results
- Return type
Movement statistics
- class simba.cue_light_tools.cue_light_movement_statistics.CueLightMovementAnalyzer(config_path: Union[str, PathLike], pre_window: int, post_window: int, cue_light_names: List[str], threshold: float, roi_setting: bool)[source]
Bases:
ConfigReader
Compute aggregate statistics of animal movement in relation to the cue light ON and OFF states.
- Parameters
config_path (str) – path to SimBA project config file in Configparser format
pre_window (int) – Time period (in millisecond) before the onset of each cue light to compute aggregate classification statistics within.
post_window (int) – Time period (in millisecond) after the offset of each cue light to compute aggregate classification statistics within.
cue_light_names (List[str]) – Names of cue lights, as defined in the SimBA ROI interface.
threshold (float) – The body-part post-estimation probability threshold. SimBA omits movement calculations for frames where the body-part probability threshold is lower than the user-specified threshold.
roi_setting (bool) – If True, SimBA calculates movement statistics within non-light cue ROIs.
Examples
>>> cue_light_movement_analyzer = CueLightMovementAnalyzer(config_path='MyProjectConfig', cue_light_names=['Cue_light'], pre_window=1000, post_window=1000, threshold=0.0, roi_setting=True) >>> cue_light_movement_analyzer.calculate_whole_session_movement() >>> cue_light_movement_analyzer.organize_results() >>> cue_light_movement_analyzer.save_results()
- calculate_whole_session_movement()[source]
Method to calculate movement in relation to cue-light(s) onsets.
- Returns
Attribute – roi_results
- Return type
Tools
- simba.cue_light_tools.cue_light_tools.find_frames_when_cue_light_on(data_df: DataFrame, cue_light_names: List[str], fps: int, prior_window_frames_cnt: int, post_window_frames_cnt: int)[source]
Private multiprocess helper for finding cue-light states. Called by meth:simba.cue_light_tools.cue_light_analyzer.CueLightAnalyzer.
Visualize
- class simba.cue_light_tools.cue_light_visualizer.CueLightVisualizer(config_path: Union[str, PathLike], cue_light_names: List[str], video_path: str, frame_setting: bool, video_setting: bool)[source]
Bases:
ConfigReader
Visualize SimBA computed cue-light ON and OFF states and the aggregate statistics of ON and OFF states.
- Parameters
config_path (str) – path to SimBA project config file in Configparser format.
cue_light_names (List[str]) – Names of cue lights, as defined in the SimBA ROI interface.
video_path (str) – Path to video which user wants to create visualizations of cue light states and aggregate statistics for.
frame_setting (bool) – If True, creates individual frames in png format.
video_setting (bool) – If True, creates compressed videos in mp4 format.
Examples
>>> cue_light_visualizer = CueLightVisualizer(config_path='SimBAConfig', cue_light_names=['Cue_light'], video_path='VideoPath', video_setting=True, frame_setting=False) >>> cue_light_visualizer.run()