Skip to content

Commit

Permalink
fix(BlockSubjectAnalysis): handle edge case where the encoder data ar…
Browse files Browse the repository at this point in the history
…e inconsistent across patches
  • Loading branch information
ttngu207 committed Oct 24, 2024
1 parent 8762fcf commit 9078085
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion aeon/dj_pipeline/analysis/block_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,17 @@ def make(self, key):
)
subjects_positions_df.set_index("position_timestamps", inplace=True)

# Ensure wheel_timestamps are of the same length across all patches
wheel_lens = [len(p["wheel_timestamps"]) for p in block_patches]
if len(set(wheel_lens)) > 1:
max_diff = max(wheel_lens) - min(wheel_lens)
if max_diff > 10:
# if diff is more than 10 samples, raise error, this is unexpected, some patches crash?
raise ValueError(f"Wheel data lengths are not consistent across patches ({max_diff} samples diff)")
for p in block_patches:
p["wheel_timestamps"] = p["wheel_timestamps"][: min(wheel_lens)]
p["wheel_cumsum_distance_travelled"] = p["wheel_cumsum_distance_travelled"][: min(wheel_lens)]

self.insert1(key)

in_patch_radius = 130 # pixels
Expand Down Expand Up @@ -1574,7 +1585,7 @@ def make(self, key):
@schema
class AnalysisNote(dj.Manual):
definition = """ # Generic table to catch all notes generated during analysis
note_timestamp: datetime
note_timestamp: datetime(6)
---
note_type='': varchar(64)
note: varchar(3000)
Expand Down

0 comments on commit 9078085

Please sign in to comment.