forked from kelhad00/IBPY
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocessing.py
More file actions
29 lines (27 loc) · 972 Bytes
/
Copy pathprocessing.py
File metadata and controls
29 lines (27 loc) · 972 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
def tuple_to_sequence(lst, width, shift):
"""Convert [(strt, stp, val)] to sequence of val.
Args:
lst (list): start and stop times of each val.
width (numeric): window width in ms.
shift (numeric): window shift in ms.
Returns:
list: sequence of vals corresponding to the tuples in lst.
"""
lst = sorted(lst)
seq = []
last_frame = (lst[-1][1] - width) / shift
frame_id = 0
ind = 0
while (frame_id * shift) < (last_frame * shift) and ind < len(lst):
if lst[ind][1] >= (frame_id * shift) >= lst[ind][0]:
while (frame_id * shift) < lst[ind][1]:
seq.append(lst[ind][2])
frame_id += 1
ind += 1
else:
while (frame_id * shift) < lst[ind][0]:
seq.append(None)
frame_id += 1
if (frame_id * shift) >= (last_frame * shift):
return seq
return seq