Exemple #1
0
 def test_peakdelta_cleanecg(self):
     t, s = loadtxt(path + 'cleanecg.txt')
     pr = array([
         20, 40, 87, 107, 156, 175, 225, 244, 291, 311, 355, 375, 418, 438,
         482, 501, 550, 569, 624, 644, 694, 713, 764, 784, 834, 854, 905,
         925, 978
     ])
     assert_array_equal(pr, peakdelta(s, 50)[0][:, 0].astype(int))
    def test_peakdelta_eda(self):
        t, s = loadtxt(path + 'eda.txt')
        pks = peakdelta(s, 50)

        prmax = array([0, 95, 278, 346])
        prmin = array([47, 255, 313])

        assert_array_equal(prmax, pks[0][:, 0].astype(int))
        assert_array_equal(prmin, pks[1][:, 0].astype(int))
    def test_peakdelta_eda(self):
        t, s = loadtxt(path + 'eda.txt')
        pks = peakdelta(s, 50)

        prmax = array([0, 95, 278, 346])
        prmin = array([47, 255, 313])

        assert_array_equal(prmax, pks[0][:, 0].astype(int))
        assert_array_equal(prmin, pks[1][:, 0].astype(int))
Exemple #4
0
import pandas as pd
import novainstrumentation as ni

from gmtools import *

close('all')

vm = np.array(pd.read_csv('data/test2/Accelerometer.txt', header=None))
taps = np.array(pd.read_csv('data/test2/TapCounter.txt', header=None))
t, m = vm[:, 0], vm[:, 1:-1]
mag = get_magnitude(m)

s = ni.lowpass(mag, 2, order=2, fs=100, use_filtfilt=True)

# Find all minimum peaks
pks = ni.peakdelta(s, delta=np.percentile(s, 70) - np.percentile(s, 30))
stepsl = []
stepsr = []
medsteps = np.median(pks[1][:, 1])
for (i, p) in zip(pks[1][:, 0], pks[1][:, 1]):
    if p <= medsteps:
        stepsl += [[i, p]]
    else:
        stepsr += [[i, p]]

stepsl = np.array(stepsl)
stepsr = np.array(stepsr)

# Visualization
# figure()
# plot(t, s)
Exemple #5
0
import numpy as np
import novainstrumentation as ni
import src.test_EcgBeatDetector.wfdbtools as wfdb

from pylab import *

# --- Sequence  definition --- #
start, end = 0, -1
sequence_record = './data/100'

seq_data, seq_info = wfdb.rdsamp(sequence_record, start=start, end=end)
t, ecgsig = seq_data[:, 1], seq_data[:, 2]

s = ni.bandpass(ecgsig, 5, 50, order=2, fs=seq_info['samp_freq'], use_filtfilt=True)
pks = ni.peakdelta(s, delta=np.percentile(s, 98) - np.percentile(s, 2))

figure()
plot(s)
vlines(pks[0][:, 0], np.min(s), np.max(s))

show()
 def test_peakdelta_cleanecg(self):
     t, s = loadtxt(path + 'cleanecg.txt')
     pr = array([20, 40, 87, 107, 156, 175, 225, 244, 291, 311, 355, 375, 418, 438, 482,
                 501, 550, 569, 624, 644, 694, 713, 764, 784, 834, 854, 905, 925, 978])
     assert_array_equal(pr, peakdelta(s, 50)[0][:, 0].astype(int))