ROI feature visualization

Visualize features that depend on the relationships between the location of the animals and user-defined ROIs. E.g., distances to centroids of ROIs, cumulative time spent in ROIs, if animals are directing towards ROIs etc.

[7]:
from simba.plotting.ROI_feature_visualizer_mp import ROIfeatureVisualizerMultiprocess

EXAMPLE 1

[8]:
#DEFINITIONS
STYLE_ATTIBUTES = {'ROI_centers': True,                  # SHOW THE CENTROID OF THE ROIs AS A CIRCLE
                   'ROI_ear_tags': True,                 # SHOW THE EAR TAGS OF THE ROIs as CIRCLES
                   'Directionality': True,               # IF VIABLE, SHOW DIRECTIONALITY TOWARDS ROIs
                   'Directionality_style': 'Funnel',     # LINE OR FUNNEL
                   'Border_color': (0, 128, 0),          # COLOR OF THE SIDE-BAR
                   'Pose_estimation': True}              # SHOW POSE-ESTIMATED LOCATIONS
CONFIG_PATH = '/Users/simon/Desktop/envs/simba/troubleshooting/two_black_animals_14bp/project_folder/project_config.ini',
VIDEO_NAME = 'Together_1.avi'
CORES = 5
[9]:
roi_feature_visualizer = ROIfeatureVisualizerMultiprocess(config_path=CONFIG_PATH,
                                                          video_name=VIDEO_NAME,
                                                          style_attr=STYLE_ATTIBUTES,
                                                          core_cnt=CORES)
roi_feature_visualizer.run()
Directionality calculations are VIABLE.
Processing 1 videos for ROI features...
Analysing ROI data for video Together_1...
Analysing ROI data for video Together_1...
Creating ROI feature images, multiprocessing (determined chunksize: 1, cores: 5)...
Image 348/1738, Video Together_1...
Image 696/1738, Video Together_1...
Image 1044/1738, Video Together_1...
Image 1392/1738, Video Together_1...
Image 1740/1738, Video Together_1...
Joining Together_1 multi-processed video...
SIMBA COMPLETE: Video concatenated (elapsed time: 21.2022s)     complete
SIMBA COMPLETE: Video Together_1 complete. Video saved in project_folder/frames/output/ROI_features. (elapsed time: 46.2801s)   complete

EXAMPLE 2

In this second example, we will plot ROI features, but we will use the Directionality_roi_subset argument in the ROIfeatureVisualizerMultiprocess class to restrict the directionality visualizations only to the names of the specified set of of ROIs

[10]:
## DEFINE A LIST OF ROI NAMES THAT WE WISH TO SEE ROI DIRECTIONALITY FOR
roi_subset = ['My_polygon']
[11]:
# WE UPDATE THE STYLE ATTRIBUTES PASS IN OUR roi_subset (LAST ROW)
STYLE_ATTIBUTES = {'ROI_centers': True,                         # SHOW THE CENTROID OF THE ROIs AS A CIRCLE
                   'ROI_ear_tags': True,                        # SHOW THE EAR TAGS OF THE ROIs as CIRCLES
                   'Directionality': True,                      # IF VIABLE, SHOW DIRECTIONALITY TOWARDS ROIs
                   'Directionality_style': 'Funnel',            # LINE OR FUNNEL
                   'Border_color': (0, 128, 0),                 # COLOR OF THE SIDE-BAR
                   'Pose_estimation': True,                     # SHOW POSE-ESTIMATED LOCATIONS
                   'Directionality_roi_subset': roi_subset}     # ONLY SHOW DIRECTIONALITY TO THE ROIS DEFINED IN LIST
[12]:
#NOW WE RE-RUN THE FEATURE VISUALIZER
roi_feature_visualizer = ROIfeatureVisualizerMultiprocess(config_path=CONFIG_PATH,
                                                          video_name=VIDEO_NAME,
                                                          style_attr=STYLE_ATTIBUTES,
                                                          core_cnt=CORES)
roi_feature_visualizer.run()
Directionality calculations are VIABLE.
Processing 1 videos for ROI features...
Analysing ROI data for video Together_1...
Analysing ROI data for video Together_1...
Creating ROI feature images, multiprocessing (determined chunksize: 1, cores: 5)...
Image 348/1738, Video Together_1...
Image 696/1738, Video Together_1...
Image 1044/1738, Video Together_1...
Image 1392/1738, Video Together_1...
Image 1740/1738, Video Together_1...
Joining Together_1 multi-processed video...
SIMBA COMPLETE: Video concatenated (elapsed time: 16.7784s)     complete
SIMBA COMPLETE: Video Together_1 complete. Video saved in project_folder/frames/output/ROI_features. (elapsed time: 42.9745s)   complete
[ ]: