File tree 1 file changed +17
-5
lines changed
1 file changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -10,27 +10,39 @@ def resample_ann(tt, annsamp):
10
10
11
11
# Compute the new annotation indexes
12
12
13
- result = numpy .zeros (len (tt ), dtype = 'bool ' )
13
+ tmp = numpy .zeros (len (tt ), dtype = 'int16 ' )
14
14
j = 0
15
15
tprec = tt [j ]
16
16
for i , v in enumerate (annsamp ):
17
17
while True :
18
18
d = False
19
+ if v < tprec :
20
+ j -= 1
21
+ tprec = tt [j ]
22
+
19
23
if j + 1 == len (tt ):
20
- result [j ] = 1
24
+ tmp [j ] + = 1
21
25
break
26
+
22
27
tnow = tt [j + 1 ]
23
28
if tprec <= v and v <= tnow :
24
29
if v - tprec < tnow - v :
25
- result [j ] = 1
30
+ tmp [j ] + = 1
26
31
else :
27
- result [j + 1 ] = 1
32
+ tmp [j + 1 ] + = 1
28
33
d = True
29
34
j += 1
30
35
tprec = tnow
31
36
if d :
32
37
break
33
- return numpy .where (result == 1 )[0 ].astype ('int64' )
38
+
39
+ idx = numpy .where (tmp > 0 )[0 ].astype ('int64' )
40
+ res = []
41
+ for i in idx :
42
+ for j in range (tmp [i ]):
43
+ res .append (i )
44
+ assert len (res ) == len (annsamp )
45
+ return numpy .asarray (res , dtype = 'int64' )
34
46
35
47
36
48
def resample_sig (x , fs , fs_target ):
You can’t perform that action at this time.
0 commit comments