Skip to content

Commit bf0dc27

Browse files
committed
clean up test syntax and fix an import. fixes MIT-LCP#99
1 parent 4be3baa commit bf0dc27

File tree

6 files changed

+9
-32
lines changed

6 files changed

+9
-32
lines changed
File renamed without changes.

tests/test_processing.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import numpy
2+
23
import wfdb
34
from wfdb import processing
45

6+
57
class test_processing():
68

79
def test_1(self):
@@ -65,7 +67,7 @@ def test_6(self):
6567
assert numpy.array_equal(peaks, expecting)
6668

6769
def test_7(self):
68-
sig, fields = wfdb.rdsamp('sample-data/100', channels = [0, 1])
70+
sig, fields = wfdb.rdsamp('sample-data/100')
6971
ann = wfdb.rdann('sample-data/100', 'atr')
7072
fs = fields['fs']
7173
min_bpm = 10
@@ -89,9 +91,6 @@ class test_qrs():
8991
def test_xqrs_1(self):
9092
sig, fields = wfdb.rdsamp('sample-data/100', channels=[0])
9193
ann_reference = wfdb.rdann('sample-data/100','atr')
92-
conf = Conf()
93-
xqrs = XQRS(sig=sig[:,0], fs=fields['fs'], conf=conf)
94+
conf = processing.Conf()
95+
xqrs = processing.XQRS(sig=sig[:,0], fs=fields['fs'], conf=conf)
9496
xqrs.detect()
95-
96-
97-

wfdb/plot/plot.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,10 +297,7 @@ def label_figure(axes, n_subplots, sig_units, time_units, chan_name, title):
297297

298298

299299
def plot_wfdb(record=None, annotation=None, time_units='samples',
300-
plot_physical=True, plot_ann_sym=False,
301-
302-
303-
title=None, sig_style=[''], ann_style=['r*'],
300+
plot_physical=True, plot_ann_sym=False, title=None, sig_style=[''], ann_style=['r*'],
304301

305302

306303

wfdb/processing/basic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import numpy
22
from scipy import signal
33

4-
from wfdb import Annotation
4+
from ..io.annotation import Annotation
55

66

77
def resample_ann(resampled_t, ann_sample):

wfdb/processing/gqrs.py

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import numpy
22
import copy
3-
import matplotlib.pyplot as plt
3+
44

55
def time_to_sample_number(seconds, frequency):
66
return seconds * frequency + 0.5
@@ -188,7 +188,7 @@ def qfv_at(self, t):
188188
def qfv_put(self, t, v):
189189
self.qfv[t & (self.c._BUFLN - 1)] = v
190190

191-
def sm(self, at_t): # CHECKED!
191+
def sm(self, at_t):
192192
# implements a trapezoidal low pass (smoothing) filter
193193
# (with a gain of 4*smdt) applied to input signal sig
194194
# before the QRS matched filter qf().
@@ -199,9 +199,6 @@ def sm(self, at_t): # CHECKED!
199199
smt = self.c.smt
200200
smdt = int(self.c.smdt)
201201

202-
203-
#print('in sm: smt == %d, at_t == %d' % (smt, at_t))
204-
205202
v = 0
206203
while at_t > smt:
207204
smt += 1
@@ -248,9 +245,6 @@ def qf(self): # CHECKED!
248245
self.SIG_QRS.append(v0 ** 2)
249246

250247
def gqrs(self, from_sample, to_sample):
251-
252-
print('gqrs in state: %s' % self.state)
253-
print('dt == smt0 == %d' % self.c.dt)
254248
q0 = None
255249
q1 = 0
256250
q2 = 0
@@ -364,7 +358,6 @@ def find_missing(r, p):
364358
q0 = self.qfv_at(self.t)
365359
q1 = self.qfv_at(self.t - 1)
366360
q2 = self.qfv_at(self.t - 2)
367-
print(self.c.qthr)
368361
# state == RUNNING only
369362
if q1 > self.c.pthr and q2 < q1 and q1 >= q0 and self.t > self.c.dt4:
370363
add_peak(self.t - 1, q1, 0)
@@ -536,14 +529,5 @@ def gqrs_detect(x, fs, adc_gain, adc_zero, threshold=1.0,
536529
thresh=threshold)
537530
gqrs = GQRS()
538531
annotations = gqrs.detect(x=x, conf=conf, adc_zero=adc_zero)
539-
fig = plt.plot(numpy.array(gqrs.SIG_SMOOTH), 'b')
540-
plt.show()
541-
542-
fig2 = plt.plot(numpy.array(gqrs.SIG_QRS), 'r')
543-
544-
fig3 = plt.plot(x, 'k')
545532

546-
print('\nSmoothed signal head and tail:')
547-
print(gqrs.SIG_SMOOTH[:12])
548-
print(gqrs.SIG_SMOOTH[-12:])
549533
return numpy.array([a.time for a in annotations])

wfdb/processing/qrs.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
from sklearn.cluster import KMeans
44
from sklearn.preprocessing import normalize
55

6-
import matplotlib.pyplot as plt
7-
import pdb
8-
96
from .peaks import find_local_peaks
107

118

0 commit comments

Comments
 (0)