Skip to content

Commit b40ad37

Browse files
authored
Merge pull request #51 from KumarLabJax/distance-filter-experiments
Adding extra features to run comparisons
2 parents c93d1ca + 99cc0d4 commit b40ad37

File tree

3 files changed

+99
-0
lines changed

3 files changed

+99
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Locomotion in corner
2+
# Within 20% distance of any 2 walls
3+
# Mouse is moving > 5cm/s
4+
# This is really slow for a mouse, but essentially just removes noise from micromovements
5+
behavior:
6+
Locomotion In Corner
7+
8+
interpolate:
9+
5
10+
11+
stitch:
12+
5
13+
14+
min_bout:
15+
15
16+
17+
definition:
18+
and:
19+
- minimum:
20+
- 2
21+
- less than:
22+
- wall_distances/wall_0
23+
- divide:
24+
- avg_wall_length
25+
- 5
26+
- less than:
27+
- wall_distances/wall_1
28+
- divide:
29+
- avg_wall_length
30+
- 5
31+
- less than:
32+
- wall_distances/wall_2
33+
- divide:
34+
- avg_wall_length
35+
- 5
36+
- less than:
37+
- wall_distances/wall_3
38+
- divide:
39+
- avg_wall_length
40+
- 5
41+
- greater than:
42+
- features/per_frame/centroid_velocity_mag centroid_velocity_mag
43+
- 5.0
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Locomotion in periphery
2+
# Within 20% distance of any wall
3+
# Mouse is moving > 5cm/s
4+
# This is really slow for a mouse, but essentially just removes noise from micromovements
5+
behavior:
6+
Locomotion In Periphery
7+
8+
interpolate:
9+
5
10+
11+
stitch:
12+
5
13+
14+
min_bout:
15+
15
16+
17+
definition:
18+
and:
19+
- less than:
20+
- features/per_frame/corner_distances distance to wall
21+
- divide:
22+
- avg_wall_length
23+
- 5
24+
- greater than:
25+
- features/per_frame/centroid_velocity_mag centroid_velocity_mag
26+
- 5.0

src/jabs_postprocess/utils/project_utils.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)