Skip to content

Commit

Permalink
clean up test syntax and fix an import. fixes #99
Browse files Browse the repository at this point in the history
  • Loading branch information
cx1111 committed Feb 1, 2018
1 parent 4be3baa commit bf0dc27
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 32 deletions.
File renamed without changes.
11 changes: 5 additions & 6 deletions tests/test_processing.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import numpy

import wfdb
from wfdb import processing


class test_processing():

def test_1(self):
Expand Down Expand Up @@ -65,7 +67,7 @@ def test_6(self):
assert numpy.array_equal(peaks, expecting)

def test_7(self):
sig, fields = wfdb.rdsamp('sample-data/100', channels = [0, 1])
sig, fields = wfdb.rdsamp('sample-data/100')
ann = wfdb.rdann('sample-data/100', 'atr')
fs = fields['fs']
min_bpm = 10
Expand All @@ -89,9 +91,6 @@ class test_qrs():
def test_xqrs_1(self):
sig, fields = wfdb.rdsamp('sample-data/100', channels=[0])
ann_reference = wfdb.rdann('sample-data/100','atr')
conf = Conf()
xqrs = XQRS(sig=sig[:,0], fs=fields['fs'], conf=conf)
conf = processing.Conf()
xqrs = processing.XQRS(sig=sig[:,0], fs=fields['fs'], conf=conf)
xqrs.detect()



5 changes: 1 addition & 4 deletions wfdb/plot/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,10 +297,7 @@ def label_figure(axes, n_subplots, sig_units, time_units, chan_name, title):


def plot_wfdb(record=None, annotation=None, time_units='samples',
plot_physical=True, plot_ann_sym=False,


title=None, sig_style=[''], ann_style=['r*'],
plot_physical=True, plot_ann_sym=False, title=None, sig_style=[''], ann_style=['r*'],



Expand Down
2 changes: 1 addition & 1 deletion wfdb/processing/basic.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy
from scipy import signal

from wfdb import Annotation
from ..io.annotation import Annotation


def resample_ann(resampled_t, ann_sample):
Expand Down
20 changes: 2 additions & 18 deletions wfdb/processing/gqrs.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy
import copy
import matplotlib.pyplot as plt


def time_to_sample_number(seconds, frequency):
return seconds * frequency + 0.5
Expand Down Expand Up @@ -188,7 +188,7 @@ def qfv_at(self, t):
def qfv_put(self, t, v):
self.qfv[t & (self.c._BUFLN - 1)] = v

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


#print('in sm: smt == %d, at_t == %d' % (smt, at_t))

v = 0
while at_t > smt:
smt += 1
Expand Down Expand Up @@ -248,9 +245,6 @@ def qf(self): # CHECKED!
self.SIG_QRS.append(v0 ** 2)

def gqrs(self, from_sample, to_sample):

print('gqrs in state: %s' % self.state)
print('dt == smt0 == %d' % self.c.dt)
q0 = None
q1 = 0
q2 = 0
Expand Down Expand Up @@ -364,7 +358,6 @@ def find_missing(r, p):
q0 = self.qfv_at(self.t)
q1 = self.qfv_at(self.t - 1)
q2 = self.qfv_at(self.t - 2)
print(self.c.qthr)
# state == RUNNING only
if q1 > self.c.pthr and q2 < q1 and q1 >= q0 and self.t > self.c.dt4:
add_peak(self.t - 1, q1, 0)
Expand Down Expand Up @@ -536,14 +529,5 @@ def gqrs_detect(x, fs, adc_gain, adc_zero, threshold=1.0,
thresh=threshold)
gqrs = GQRS()
annotations = gqrs.detect(x=x, conf=conf, adc_zero=adc_zero)
fig = plt.plot(numpy.array(gqrs.SIG_SMOOTH), 'b')
plt.show()

fig2 = plt.plot(numpy.array(gqrs.SIG_QRS), 'r')

fig3 = plt.plot(x, 'k')

print('\nSmoothed signal head and tail:')
print(gqrs.SIG_SMOOTH[:12])
print(gqrs.SIG_SMOOTH[-12:])
return numpy.array([a.time for a in annotations])
3 changes: 0 additions & 3 deletions wfdb/processing/qrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
from sklearn.cluster import KMeans
from sklearn.preprocessing import normalize

import matplotlib.pyplot as plt
import pdb

from .peaks import find_local_peaks


Expand Down

0 comments on commit bf0dc27

Please sign in to comment.