An example of noise. Some basics of signal filtering (Outline) Data Filters. Another example of noise. Signal and noise

Some basics of signal filtering (Outline) An example of noise Kinematic data often contain some high frequency noise and should usually be filtered p...
Author: Mercy Ramsey
181 downloads 0 Views 361KB Size
Some basics of signal filtering (Outline)

An example of noise Kinematic data often contain some high frequency noise and should usually be filtered prior to further analysis

1. True signal versus noise 2. Some filter basics 3. A few different types of digital filters: 1. Moving Averages 2. Butterworth 3. Global Polynomials and Splines

4. Determining an appropriate cutoff frequency for your digital filter

Data Filters

Kinematic data often contain some high frequency noise and should usually be filtered prior to further analysis

Filters are often used in biomechanics to distinguish true signal of interest from random of systematic noise (contamination or interference)

Position Data

Velocity Data

Acceleration Data

Filters can: 1. Reveal the true signal by attenuating noise (random or persistent disturbance that obscures the true signal) 2. Distort the true signal by altering or eliminating important information

Optimally, a filter is able to maximize one (above) and minimize two (above) Sample kinematic data

Signal and noise Noise is additive to the true signal

Another example of noise EMG data may contain low frequency noise and need to be filtered prior to further analysis

The signal we record can be represented as: ŷ=y+e ŷ is the recorded signal y is the true signal of interest e is error that is introduced into the recorded signal (noise) An appropriate filter may allow you to keep ‘y’ while attenuating ‘e’

1

True signal versus noise

Digital Filters

Usually, some overlap exists between the frequencies of the true signal and the noise

Realistic attenuation characteristics (for a low-pass filter) passband

transition region

stopband

roll-off: steepness in transition region

Amount of signal that is allowed through the filter

transition width

0

fC Cutoff frequency

Digital Filters

Filter Basics

Moving average filter: a rudimentary digital filter

Two primary filter types: – Analog: constructed with resistors & capacitors – Digital: mathematical procedures applied to digital data (e.g., moving averages (RMS), global polynomials, and splines)

For example, to get smoothed value of x(9), you might use either of the two formulas below Sample emg data

Attenuation Characteristics: – – – –

Filters signal by averaging a certain number of values from the input signal

x’(9) = x(9) + x(10) + x(11) + x(12) + x(13)

Low-pass High-pass Band-pass Band-stop

5 x’(9) = x(7) + x(8) + x(9) + x(10) + x(11)

OR

5

Digital Filters Ideal attenuation characteristics… high-pass amplitude

amplitude

low-pass 1 pass band

0

0

fC

frequency

1 pass band

0

0

pass band

0

0

fC1

fC2

frequency

band-stop

1

amplitude

amplitude

band-pass

fC

frequency

1 pass band

0

0

pass band

fC1 fC2

Moving average filters (11-point and 51-point): As number of points used increases, signal becomes smoother, but edges lose their sharpness

frequency

2

Moving averages 1. Moving averages can smooth (filter) noisy signals 2. They cannot separate out different frequency components (can’t pick a cutoff frequency) 3. In many cases, there will be a better option than using a moving average

Butterworth digital filter To design a Butterworth low-pass recursive digital filter: C = tan(C/S)

k1 = 2  C

k2 = (C)2

a0 = k2/(1 + k1 + k2)

a1 = 2a0

a2 = a0

k3 = 2a0 / k2

b1 = -2a0 + k3,

b2 = 1 - 2a0 - k3

Butterworth filter in Excel

Butterworth digital filter 1. Most common filter used in biomechanics 2. Excellent passband response 3. Arbitrarily sharp roll-off can be achieved by increasing filter order 4. Introduces a phase (time) distortion into smoothed data, but this is easily corrected 5. Basically, is a sophisticated moving average filter

Butterworth digital filter • Phase distortion introduced by the Butterworth filter causes smoothed data to be shifted to the right • Phase shift can be canceled by filtering the smoothed data again in reverse direction of time • This effectively increases the filter order from 2nd order to 4th order (sharper roll-off) • Second pass smoothes the data more, increasing the effective cutoff frequency by about 25% • Cutoff frequency to use is obtained by multiplying desired cutoff by 0.80

Butterworth digital filter Format of a recursive

2nd

order digital filter:

Butterworth digital filter Sample calculations: Raw values:

x’n = a0xn + a1xn-1 + a2xn-2 + b1x’n-1 + b2x’n-2 where:

x’ x n n-1 n-2 a0-b2

filtered output data unfiltered (raw) input data nth sample 1 sample before n 2 samples before n filter coefficients

The filter coefficients are constants that depend on the filter type and order, sampling rate, and cutoff frequency

Coefficients: (SR = 100 Hz, cutoff = 6 Hz)

x(1) = 4.5 x(2) = 7.8 x(3) = 5.2 x(4) = 3.1 x(5) = 8.3

Smoothed values:

a0 = 0.028 a1 = 0.056 a2 = 0.028

x’(1) = 5.6 x’(2) = 5.8 x’(3) = ? x’(4) = x’(5) =

b1 = 1.476 b2 = -0.587

2nd order Butterworth digital filter smoothed value for point 3: x’(n) = a0x(n) + a1x(n-1) + a2x(n-2) + b1x’(n-1) + b2x’(n-2) x’(3) = 0.028(5.2) + 0.056(7.8) + 0.028(4.5) + 1.476(5.8) − 0.587(5.6) x’(3) = 5.98

3

Butterworth digital filter Practical Implementation •

Butterworth filter has some “start-up” issues Needs prior 2 filtered points to calculate current filtered point, but at beginning of the data these don’t exist



Cutoff Frequency Methods to determine “optimal” cutoff frequency • Residual analysis (Winter, 1990) • Jackson “knee” method (Jackson, 1979)

Common approach 1. Pad the data at the beginning and end (10-20 points) 2. Substitute first two raw values for the first two filtered values real data 3. Remove padded data 4. Or, more simply, collect additional data

• Autocorrelation-based technique (Challis, 1999) Most are based, at least partly, on an analysis of residual error

padded data

Cutoff Frequency

Cutoff Frequency - Residuals

How do you determine cutoff frequency to use with a Butterworth digital filter?

The residual difference (R) between a filtered signal (x’) and a raw signal (x) consisting of N data point is given by:

• Smooth everything at 6 Hz (no!)



• Use a cutoff frequency reported in a similar published study (well…maybe)

R=

• Use an objective method to estimate an optimal cutoff frequency, and then check (i.e., look at) your data (yes!)

n

 (Xi - X’i)2 i=1 N

Winter’s method involves smoothing at several cutoff frequencies (C), and then plotting R versus C

Cutoff Frequency

Cutoff Frequency - Residuals

Factors to consider:

Plot of residual versus cutoff frequency for determining optimal cutoff

• Optimal cutoff frequencies will be quite different for different data types (e.g., EMG and motion data)

– Head will be lower (maybe 2-3 Hz)

(i.e., cutoff freq is too low)

residual

• The optimal cutoff for different markers will be different; e.g., for running:

Experience has shown that this technique tends to over-smooth human motion data

– Distal points will be higher (maybe 10-15 Hz) • The optimal cutoff for different components (x, y, z) of a single marker will not necessarily be the same optimal C

C

4

Cutoff Frequency - Residuals Jackson’s method involves plotting 2nd derivative of R with respect to C to find the “knee” of the curve

Global polynomials Noisy raw data (blue markers)

dR2/d2C

When the plotted line drops below a threshold level, and stays below this level, the optimal cutoff has been found However, the setting of this threshold is somewhat arbitrary

optimal C

C

Cutoff Frequency Regardless of the technique chosen:

Global polynomials 5th order polynomial fit to raw data (black line)

1. Don’t use a “canned” approach blindly 2. Be consistent in your approach 3. Look at graphs of all your raw and smoothed data before proceeding with further analysis 4. Be able to defend your choice

Global polynomials Raw data can be smoothed by fitting a single polynomial of some order to the whole data set

Effect of polynomial order 3.5

1st order 3.0

order polynomial to a set

y(t) = a0 + a1t + a2t2 + a3t3 + a4t4 + a5t5 The coefficients a0-a6 are found using a leastsquares approach This can be done using matlab, excel, etc…

2.5 Displacment

For example, fit a of raw data

5th

Global polynomials

2nd order

2.0 1.5 1.0 0.5 0.0 0.00

0.25

0.50

0.75

1.00

1.25

1.50

Time

5

Global polynomials

Spline Functions

Effect of polynomial order

cubic spline example yi(t) = ai + bit + cit2 + dit3

3.5 3.0

Data do not need to be evenly spaced in time

Displacment

2.5

Endpoint conditions ensure adjacent splines connect smoothly

2.0

3rd order

1.5 1.0 0.5

4th

Splines can fit data points exactly, or can smooth out high frequency noise

order

0.0 0.00

Piece-wise nature allows rapid adaptation to local detail

0.25

0.50

0.75

1.00

1.25

1.50

Time

Global polynomials

Spline Functions

Global polynomial approach is very simple, and thus appealing, but has many shortcomings

Degree of smoothing is governed by a smoothing parameter (S)

1. Derivatives are easy to calculate, but not likely to be very accurate

A higher value of S will result in greater smoothing of the signal

2. Poor control over amount of smoothing 3. Often no basis for choosing polynomial order

Determining the value to use for S suffers from the same problems as selecting which cutoff frequency to use for a digital filter

4. Can not accommodate regions of varying complexity in a single data set

Spline Functions

Spline Functions

Spline functions consist of a number of low order polynomials, pieced together at specified points in time

Cubic spline functions have two limitations relevant to biomechanical applications:

Most common orders used in biomechanics are 3rd order (cubic splines) and 5th order (quintic splines)

– 2nd derivative (acceleration) is forced to zero at beginning and end of data set – 3rd derivative (jerk) has jump discontinuities which would mean force is changing instantaneously (which of course it can’t)

Quintic splines (5th order) do not suffer from these problems, and have been frequently used in biomechanics

6

Suggest Documents