From cb3573f69e333a829cac83b70c1463cdfd701d12 Mon Sep 17 00:00:00 2001 From: LPeurey Date: Thu, 14 Nov 2024 15:56:44 +0100 Subject: [PATCH] allowing periodic sampling grouping --- ChildProject/pipelines/samplers.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ChildProject/pipelines/samplers.py b/ChildProject/pipelines/samplers.py index 2768ec73..89f83b3b 100644 --- a/ChildProject/pipelines/samplers.py +++ b/ChildProject/pipelines/samplers.py @@ -254,17 +254,17 @@ def _sample(self): recordings = recordings.copy() recordings['start_ts'] = recordings.apply( - lambda row: int(pd.Timestamp(str(row['date_iso']) + 'T' + str(row['start_time'])).timestamp()), + lambda row: int(pd.Timestamp(str(row['date_iso']) + 'T' + str(row['start_time'])).timestamp()) * 1000, axis=1) recordings['end_ts'] = recordings['start_ts'] + recordings['duration'] segments = [] # work by groups (by argument), create a singular timeline from those groups and choose periodic segments from there # this means that recordings following each other will maintain continuity in sampling period - # it also means concurrent recordings in the same session will have the same samples kept time/date wise regardless of shifts in start + # also means concurrent recordings in the same session will have the same samples kept time/date wise regardless of shifts in start for i, gdf in recordings.groupby(self.by): all_segments = pd.DataFrame({'segment_onset': np.arange( gdf['start_ts'].min() + self.offset, - gdf['end_ts'].max() - self.length, + gdf['end_ts'].max(), self.period + self.length, )}) all_segments['segment_offset'] = all_segments['segment_onset'] + self.length