@@ -509,6 +509,8 @@ def __init__(self, settings: ClassifierSettings, data: pd.DataFrame):
509509 "exp_prefix" ,
510510 "time" ,
511511 "distance" ,
512+ "distance_threshold" ,
513+ "distance_seg" ,
512514 "closest_id" ,
513515 "closest_lixit" ,
514516 "closest_corner" ,
@@ -677,6 +679,8 @@ def __init__(self, settings: ClassifierSettings, data: pd.DataFrame):
677679 "exp_prefix" ,
678680 "time" ,
679681 "distance" ,
682+ "distance_threshold" ,
683+ "distance_seg" ,
680684 "closest_id" ,
681685 "closest_lixit" ,
682686 "closest_corner" ,
@@ -770,6 +774,16 @@ def add_bout_features(self, feature_file: Path):
770774 "features/per_frame/centroid_velocity_mag centroid_velocity_mag" ,
771775 lambda x : np .nansum (x , initial = 0 ) / 30 ,
772776 ),
777+ FeatureInEvent (
778+ "distance_threshold" ,
779+ "features/per_frame/centroid_velocity_mag centroid_velocity_mag" ,
780+ lambda x : np .nansum (x [x > 5 ], initial = 0 ) / 30 ,
781+ ),
782+ FeatureInEvent (
783+ "distance_seg" ,
784+ "features/per_frame/shape_descriptor centroid_speed" ,
785+ lambda x : np .nansum (x , initial = 0 ) / 30 ,
786+ ),
773787 FeatureInEvent ("closest_id" , "closest_identities" , np .median ),
774788 FeatureInEvent ("closest_lixit" , "closest_lixit" , np .median ),
775789 FeatureInEvent ("closest_corner" , "closest_corners" , np .median ),
@@ -1003,6 +1017,14 @@ def bouts_to_bins(
10031017 bins_to_summarize ["calc_dist" ] = (
10041018 bins_to_summarize ["distance" ] * bins_to_summarize ["percent_bout" ]
10051019 )
1020+ bins_to_summarize ["calc_dist_threshold" ] = (
1021+ bins_to_summarize ["distance_threshold" ]
1022+ * bins_to_summarize ["percent_bout" ]
1023+ )
1024+ bins_to_summarize ["calc_dist_seg" ] = (
1025+ bins_to_summarize ["distance_seg" ]
1026+ * bins_to_summarize ["percent_bout" ]
1027+ )
10061028 else :
10071029 pass
10081030 pd .options .mode .chained_assignment = "warn"
@@ -1070,6 +1092,12 @@ def bouts_to_bins(
10701092 results ["behavior_dist" ] = bins_to_summarize .loc [
10711093 bins_to_summarize ["is_behavior" ] == 1 , "calc_dist"
10721094 ].sum ()
1095+ results ["behavior_dist_threshold" ] = bins_to_summarize .loc [
1096+ bins_to_summarize ["is_behavior" ] == 1 , "calc_dist_threshold"
1097+ ].sum ()
1098+ results ["behavior_dist_seg" ] = bins_to_summarize .loc [
1099+ bins_to_summarize ["is_behavior" ] == 1 , "calc_dist_seg"
1100+ ].sum ()
10731101 results_df_list .append (pd .DataFrame (results ))
10741102
10751103 # Remove an non-informative rows
@@ -1151,6 +1179,8 @@ def __init__(self, settings: ClassifierSettings, data: pd.DataFrame):
11511179 "time" ,
11521180 "not_behavior_dist" ,
11531181 "behavior_dist" ,
1182+ "behavior_dist_threshold" ,
1183+ "behavior_dist_seg" ,
11541184 "avg_bout_duration" ,
11551185 "_stats_sample_count" ,
11561186 "bout_duration_std" ,
0 commit comments