Bounding-box tools
On this page
Aggregate Statistics
- class simba.bounding_box_tools.agg_boundary_stats.AggBoundaryStatisticsCalculator(config_path, measures, shortest_allowed_interaction)[source]
Bases:
simba.mixins.config_reader.ConfigReaderCompute aggregate boundary statistics
- Parameters
config_path (str) – SimBA project config file in Configparser format
measures (List[str]) – Aggregate statistics measurements. OPTIONS: ‘DETAILED INTERACTIONS TABLE’, ‘INTERACTION TIME (s)’, ‘INTERACTION BOUT COUNT’, ‘INTERACTION BOUT MEAN (s)’, ‘INTERACTION BOUT MEDIAN (s)’
shortest_allowed_interaction (int) – The shortest allowed animal-anchored ROI intersection in millisecond.
Notes
Examples
>>> boundary_stats_calculator = AggBoundaryStatisticsCalculator('MyProjectConfig', measures=['INTERACTION TIME (s)'], shortest_allowed_interaction=200) >>> boundary_stats_calculator.run() >>> boundary_stats_calculator.save()
Statistics
- class simba.bounding_box_tools.boundary_statistics.BoundaryStatisticsCalculator(config_path, roi_intersections, roi_keypoint_intersections, save_format)[source]
Bases:
simba.mixins.config_reader.ConfigReaderCompute boundary intersection statistics.
- Parameters
config_path (str) – Path to SimBA project config file in Configparser format.
roi_intersections (bool) – If True, calculates intersection of animal-anchored ROIs
roi_keypoint_intersections (bool) – If True, calculates intersection of animal-anchored ROIs and pose-estimated animal key-points.
save_format (str) – Output data format. OPTIONS: CSV, PARQUET, PICKLE.
Notes
Examples
>>> boundary_stats_calculator = BoundaryStatisticsCalculator(config_path='MyConfigFile',roi_intersections=True, roi_keypoint_intersections=True, save_format='CSV') >>> boundary_stats_calculator.save_results()
Find Boundaries
- class simba.bounding_box_tools.find_boundaries.AnimalBoundaryFinder(config_path, roi_type, force_rectangle, body_parts=None, parallel_offset=None)[source]
Bases:
simba.mixins.config_reader.ConfigReader,simba.mixins.feature_extraction_mixin.FeatureExtractionMixinCompute boundaries (animal-anchored) ROIs for animals in each frame. Result is saved as a pickle in the
project_folder/logsdirectory of the SimBA project.- Parameters
config_path (str) – path to SimBA project config file in Configparser format
roi_type (str) –
shape type of ROI. OPTIONS: “ENTIRE ANIMAL”, “SINGLE BODY-PART SQUARE”, “SINGLE BODY-PART CIRCLE”. For more information/examples, see Tutorial.
force_rectangle (bool) – If True, forces roi shape into minimum bounding rectangle. If False, then polygon.
body_parts (Optional[dict] or None) – If roi_type is ‘SINGLE BODY-PART CIRCLE’ or ‘SINGLE BODY-PART SQUARE’, then body-parts to anchor the ROI to with keys as animal names and values as body-parts. E.g., body_parts={‘Animal_1’: ‘Head_1’, ‘Animal_2’: ‘Head_2’}.
parallel_offset (Optional[int]) – Offset of ROI from the animal outer bounds in millimeter. If None, then no offset.
Examples
>>> animal_boundary_finder = AnimalBoundaryFinder(config_path='project_folder/project_config.ini', roi_type='SINGLE BODY-PART CIRCLE',body_parts={'Animal_1': 'Head_1', 'Animal_2': 'Head_2'}, force_rectangle=False, parallel_offset=15) >>> animal_boundary_finder.run()
Visualize
- class simba.bounding_box_tools.visualize_boundaries.BoundaryVisualizer(config_path, video_name, include_key_points, greyscale, show_intersections, roi_attributes)[source]
Bases:
simba.mixins.config_reader.ConfigReader,simba.mixins.plotting_mixin.PlottingMixinVisualisation of user-specified animal-anchored ROI boundaries. Results are stored in the
project_folder/frames/output/anchored_roisdirectory of the SimBA project- Parameters
config_path (str) – Path to SimBA project config file in Configparser format
video_name (str) – Name of the video in the SimBA project to create bounding box video for
include_key_points (bool) – If True, includes pose-estimated body-parts in the video.
greyscale (bool) – If True, converts the video (but not the shapes/keypoints) to greyscale.
show_intersections (bool) – If True, then produce highlight boundaries/keypoints to signify present intersections. See this example for highlighted intersections
Note
Examples
>>> boundary_visualizer = BoundaryVisualizer(config_path='MySimBAConfig', video_name='MyVideoName', include_key_points=True, greyscale=True) >>> boundary_visualizer.run()