@@ -389,15 +389,14 @@ def render_qa_message(self, qa_message):
389389 n_animals = behavior_analysis .animal_manager .get_n_individuals ()
390390 bodypart_names = behavior_analysis .animal_manager .get_keypoint_names ()
391391 visual_manager = behavior_analysis .visual_manager
392- plots = []
393-
392+ plots = []
394393 if isinstance (function_rets , tuple ):
395394 # could be plotting tuple
396395 if isinstance (function_rets [0 ], plt .Figure ):
397396 # this is for "return fig, ax"
398397 plots .append (function_rets )
399398
400- else :
399+ else :
401400 for e in function_rets :
402401 if isinstance (e , list ) and len (e ) > 0 and isinstance (e [0 ], BaseEvent ):
403402 # here we need to understand what we do with the events
@@ -521,8 +520,8 @@ def render_temp_message(query, sandbox):
521520 print ("after code execution" )
522521 print (len (qa_message ["function_rets" ]))
523522 events = qa_message ["function_rets" ]
524- for event in events :
525- print ( event )
523+
524+ sandbox . render_qa_message ( qa_message )
526525
527526 if qa_message ["function_rets" ] is not None :
528527 st .markdown (qa_message ["function_rets" ])
@@ -543,72 +542,80 @@ def render_temp_message(query, sandbox):
543542 # testing qa message
544543 from amadeusgpt .analysis_objects .object import ROIObject
545544 from amadeusgpt .main import create_amadeus
546-
547- config = Config ("amadeusgpt/configs/mabe_template .yaml" )
545+ import pickle
546+ config = Config ("amadeusgpt/configs/EPM_template .yaml" )
548547
549548 amadeus = create_amadeus (config )
550549 sandbox = amadeus .sandbox
551-
552- def get_chases_events (config : Config ):
553- '''
554- Parameters:
555- ----------
556- config: Config
557- '''
558- # create_analysis returns an instance of AnimalBehaviorAnalysis
559- analysis = create_analysis (config )
560-
561- # Get events where the closest distance between animals is less than 40 pixels
562- closest_distance_events = analysis .get_animals_animals_events (
563- cross_animal_query_list = ['closest_distance<40' ],
564- bodypart_names = None ,
565- otheranimal_bodypart_names = None ,
566- min_window = 1 ,
567- max_window = 100000
568- )
569-
570- # Get events where the angle between animals is less than 30 degrees
571- angle_events = analysis .get_animals_animals_events (
572- cross_animal_query_list = ['relative_angle<30' ],
573- bodypart_names = None ,
574- otheranimal_bodypart_names = None ,
575- min_window = 1 ,
576- max_window = 100000
577- )
578-
579- print ('angle_events' )
580- for event in angle_events :
581- print (event )
582- return angle_events
583-
584- # Get events where the animal's speed is greater than 0.2
585- speed_events = analysis .get_animals_state_events (
586- query = 'speed>0.2' ,
587- bodypart_names = None ,
588- min_window = 1 ,
589- max_window = 100000
590- )
591-
592- # Combine the closest distance and angle events using logical AND
593- distance_angle_events = analysis .get_composite_events (
594- events_A = closest_distance_events ,
595- events_B = angle_events ,
596- composition_type = 'logical_and' ,
597- max_interval_between_sequential_events = 0 ,
598- min_window = 1 ,
599- max_window = 100000
600- )
601-
602- # Combine the result with the speed events using logical AND
603- chases_events = analysis .get_composite_events (
604- events_A = distance_angle_events ,
605- events_B = speed_events ,
606- composition_type = 'logical_and' ,
607- max_interval_between_sequential_events = 0 ,
608- min_window = 1 ,
609- max_window = 100000
610- )
611-
612- return chases_events
613-
614- get_chases_events (config )
550+ analysis = sandbox .exec_namespace ["behavior_analysis" ]
551+ with open ("temp_roi_objects.pickle" , "rb" ) as f :
552+ roi_objects = pickle .load (f )
553+
554+ for name , roi_object in roi_objects .items ():
555+ analysis .object_manager .add_roi_object (ROIObject (name , roi_object ["Path" ]))
556+
557+ render_temp_message ("random query" , sandbox )
558+
559+ # def get_head_dips_events(config: Config):
560+ # """
561+ # Identify and count the number of head_dips events.
562+
563+ # Parameters:
564+ # ----------
565+ # config: Config
566+
567+ # Returns:
568+ # -------
569+ # head_dips_events: List[BaseEvent]
570+ # List of events where head_dips behavior occurs.
571+ # num_bouts: int
572+ # Number of bouts for head_dips behavior.
573+ # """
574+ # # Create an instance of AnimalBehaviorAnalysis
575+ # analysis = create_analysis(config)
576+
577+ # # Get events where mouse_center and neck are inside ROI0
578+ # mouse_center_neck_in_ROI0_events = analysis.get_animals_object_events(
579+ # object_name='ROI0',
580+ # query='overlap == True',
581+ # bodypart_names=['mouse_center', 'neck'],
582+ # min_window=1,
583+ # max_window=100000,
584+ # negate=False
585+ # )
586+ # # print ("mouse center neck in ROI0")
587+ # # print (len(mouse_center_neck_in_ROI0_events))
588+ # # for event in mouse_center_neck_in_ROI0_events:
589+ # # print (event)
590+
591+ # # Get events where head_midpoint is outside ROI1
592+ # head_midpoint_outside_ROI1_events = analysis.get_animals_object_events(
593+ # object_name='ROI1',
594+ # query='overlap == True',
595+ # bodypart_names=['head_midpoint'],
596+ # min_window=1,
597+ # max_window=100000,
598+ # negate=True
599+ # )
600+ # # print ('mouse head not in ROI1')
601+ # # print (len(head_midpoint_outside_ROI1_events))
602+ # # for event in head_midpoint_outside_ROI1_events:
603+ # # print (event)
604+
605+ # # Combine the events to define head_dips behavior
606+ # head_dips_events = analysis.get_composite_events(
607+ # events_A=mouse_center_neck_in_ROI0_events,
608+ # events_B=head_midpoint_outside_ROI1_events,
609+ # composition_type='logical_and',
610+ # max_interval_between_sequential_events=0,
611+ # min_window=1,
612+ # max_window=100000
613+ # )
614+ # print ('head dips events', len(head_dips_events))
615+
616+ # # Count the number of bouts for head_dips behavior
617+ # num_bouts = len(head_dips_events)
618+
619+ # return head_dips_events, num_bouts
620+
621+ # get_head_dips_events(config)
0 commit comments