示例#1
0
def test_emg_filter_values():
    f_name = base_dir + '/code/data/emg.txt'

    t, emg = numpy.loadtxt(f_name)
    env_ni = ni.lowpass(abs(emg), order=2, f=10, fs=1000.)

    b, a = signal.butter(2, Wn=10 / (1000.0 / 2.0))
    env_ref = signal.lfilter(b, a, abs(emg))

    assert_array_almost_equal(env_ni, env_ref)
def test_emg_filter_values():
    f_name = base_dir + '/code/data/emg.txt'

    t, emg = numpy.loadtxt(f_name)
    env_ni = ni.lowpass(abs(emg),order=2,f=10,fs=1000.)

    b,a = signal.butter(2,Wn=10/(1000.0/2.0))
    env_ref = signal.lfilter(b,a,abs(emg))

    assert_array_almost_equal(env_ni,env_ref)
示例#3
0
import numpy as np
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()
示例#4
0
def preprocessSignal(signal):
    return ni.lowpass(signal, order=1, fs=10, f=2)