Skip to content

Commit 510676b

Browse files
committed
Fixes resample_ann freezing MIT-LCP#116
Fixes the freezing seen in resample_ann when the fs_target is set too high. This causes the algorithm to develop an infinite loop which must be exited upon discovery. This pull request breaks the loop if this situation is detected. Fixes MIT-LCP#162.
1 parent 24aa0cf commit 510676b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

wfdb/processing/basic.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import numpy as np
22
from scipy import signal
3+
import pdb
34

45
from ..io.annotation import Annotation
56

@@ -23,8 +24,10 @@ def resample_ann(resampled_t, ann_sample):
2324
"""
2425
tmp = np.zeros(len(resampled_t), dtype='int16')
2526
j = 0
27+
break_loop = 0
2628
tprec = resampled_t[j]
2729
for i, v in enumerate(ann_sample):
30+
break_loop = 0
2831
while True:
2932
d = False
3033
if v < tprec:
@@ -44,6 +47,10 @@ def resample_ann(resampled_t, ann_sample):
4447
d = True
4548
j += 1
4649
tprec = tnow
50+
break_loop += 1
51+
if (break_loop > 1000):
52+
tmp[j] += 1
53+
break
4754
if d:
4855
break
4956

0 commit comments

Comments
 (0)