Data Filtering by malj


									     Signal Processing

          ESS 5314-001
           Lecture 5

Reading: Robertson et al. 2004, Ch 11
• Component of final signal not due to process itself
  (e.g. walking)
• Sources of Noise
   – Electronic noise in device (e.g. 60 Hz from lights or
   – Spatial precision of TV scan
   – Film digitizing system
   – Human error in film digitizing

• Noise leads to error and the need for data filtering
  and smoothing
            Harmonic Analysis
• AC – Alternating Component
  – Continuously changing with time
  – Periodic (rhythmic), Random, or both

• DC – Direct Component
  – Bias value (offset if you will) about which the
    AC component fluctuates
  – Figure 2.13 in text
            Frequency Content
• Periodic Signals
  – Rhythmic – repeating - pulsing
  – Discrete Frequency (evident from spectral analysis)
  – e.g. sine wave

• Non-periodic Signals
  – More chaotic in nature – no obvious pattern
  – Power across continuous spectrum
               Periodic Signals
• Can be described by their lowest (f1), highest (f2)
  and fundamental (f0) frequencies

• Harmonics
   – Higher frequency components
   – Multiples of f0

• Thus – a perfectly periodic signals can be broken
  down into its harmonic components
                      Fourier Series
• Fourier Series
   – Summing the harmonic components of a signal
     together with proper amplitudes
V(t) = Vdc + V1sin(ω0t + θ1) + V2sin(2ω0t + θ2) + … + Vnsin(nω0t + θn)

       where:        ω0 = 2πf0
                     θn = phase angle of nth harmonic

      V(t) = (4V/ π) (sin ω0t + 1/3 sin 3ω0t + 1/5 sin 5ω0t + …)

                     …however many harmonics it takes
                Spectral Analysis
• Spectral Density Analysis
• Harmonic Plots                            Looking at signal in
                                            frequency spectrum
• Spectral Plots

• Gives amplitude or power of each frequency
  component in the signal plotted against frequency
• Power Spectral Density Analysis
  – Utilizes Fourier transformation or harmonic analysis
  – Use it to determine
     A) Necessary sampling frequency
     B) Appropriate cutoff frequency for filter
Spectral Analysis
              Sampling Theorem
• Capture
  – Film or TV or other non-image based
     • Sampling Processes

• Play back
  – Slo-Mo
     • Jumpiness
     • See distinct steps
  – Normal Speed (24 Hz film, 60 Hz TV)
     • No jumpiness – smooth motion

  – WHY?           The human eye retains an image for ~1/15 second
                   Thus, fills in any blanks and smoothes the jumps
         Our eyes deceive us…

• The human eye retains an image for ~1/15

• Short term memory allows the observer to
  smooth the jumps
                Sampling Theorem
Shannon’s Sampling Theorem (Nyquist)
• Sample at least two times (2X) as high as the
   highest frequency in the signal itself.

So how fast should I sample?
  1. Sample as fast as you can initially (computer will limit)
  2. Analyse your signal in the power spectrum (spectral
  3. Determine frequency containing almost 100% of the
     •   Use at least 2 times this to sample your data (10 times if
         possible, although sometimes this is overkill)
  4. Determine the 95% frequency (frequency at which 95%
     of the signal lies below)
     •   Set this as your filter cutoff frequency (low pass)
Signal Alias

               Winter, 1990
                  Signal versus Noise
• Goal of sampling and filtering
   – Maximize signal to noise ratio

• Video/Kinematic Data
   – Certain body segments may have different frequency content
     depending on the movement

   –   Heel
   –   Ankle            Increasing                          - Head
                                           Increasing       - Shoulder
   –   Knee         frequency content
                                      frequency content
                       (e.g. landing,                       - Trunk
   –   Hip                            (e.g. head impacts)
                         running)                           - Hip
   –   Shoulder
   –   Head
          Non-stationary Signals
• Other movements may be periodic (cyclic),
  but the frequency content shifts over time.

  – Impulsive movements
     • e.g. landing (heel strike, jumping-landing)

  – Phases of movement
     • e.g. process of damping the impact forces and
       vibrations (heel strike transient, toe contact, heel
       contact, bottom-most position)
• 2 Hz walking frequency = Stride frequency of 1 Hz
  – Thus 1 stride per second
  – Expect harmonics at 2 Hz, 3 Hz, 4 Hz, etc.
• Substantial research and analysis
  – Highest harmonics occur in heel and toe
  – 99.7% of signal power is contained in the lower 7
    harmonics (i.e., below 6 Hz)
• Thus…a greater noise component lies above 6 Hz
  – And thus lower signal to noise ratio
• So…
        Filtering and Smoothing

• Goal is to maximize signal to noise ratio
  – e.g. want as much signal below 6 Hz as possible

• Filter Cutoff
  – Frequency limit at which you filter your data
  – Select filter cutoff at the peak of signal power
  – Ex. 6 Hz for walking
               Digital Filter
• Attenuates selected frequency in signal
• Assumption
  – Signal contains low frequency
  – Noise contains high frequency

• Low Pass Filter
  – Allows signal to pass through unattenuated
  – High frequency noise is removed
Effect on Data
     Low Pass Filter
      Linear Envelop

Butterworth 2nd order, cutoff = 2 Hz
     Low Pass Filter
      Linear Envelop

Butterworth 2nd order, cutoff = 3 Hz
     Low Pass Filter
       Linear Envelop

Butterworth 2nd order, cutoff = 10 Hz
              Effects on Derivatives
• First…why do we care about derivatives?
     • Displacement (directly from coordinate data)
  – dS / dt
     • Velocity (derivative of displacement)
  – dV / dt = d2S / dt2
     • Acceleration (2nd derivative of displacement)
  – F = m∙a
     • Where we get resultant joint moments, joint loads, etc.
            Effects on Derivatives
• See Figure 2.25 in Winter (2005)
• Derivatives
   – Slopes along the curve at each data point
• 2 inflections in derivative for every inflection in
  original curve
   – Thus curve gets bumpy quick
   – “Derivation is inherently noisy”
• So if original curve is noisy…
   – Derivative will be even more noisy
   – Eventually meaningless
Effect on

     Winter, 1990
Effects on Derivatives
               Butterworth Filter
  X1i = (a0Xi) + (a1Xi-1) + (a2Xi-2) + (b1X1i-1) + (b2X1i-2)

  X1         = Filtered data
  X          = Raw data
  i          = sample #
  a#, b#     = filter coefficients (constants)

The filtered data point is just a function of the
  immediate and previous raw and filtered data points.
            Filter Coefficients

• Filter coefficients are determined by the:
  – Filter type
  – Cutoff frequency (fc)
  – Sampling frequency (fs)

• See Tables 2.1 and 2.2 for coefficient values
  (Winter, 2005)
   Cutoff Coefficients
Butterworth Low-Pass Filter

                          Winter, 1990
        Cutoff Coefficients
Critically Damped Low-Pass Filter

                          Winter, 1990
• Low Pass
  – Retains frequency below cutoff
• High Pass
  – Retains frequency above cutoff
• Band Pass
  – Retains frequency between cutoffs (limits)
• Notch
  – Filters out frequency at designated limit
  – e.g. 60 Hz notch to filter out electrical noise
• Others
             The Filtering Process
• Filtering (single pass) creates a phase shift that
  does not match original data in time
   – Single Pass = 2nd Order
• Run filter again in reverse direction
   – Dual Pass = 4th Order
   – Resets filtered data in the original time series

• Passing twice affects the frequency spectrum of
  the signal slightly (more advanced)
   – Need to adjust cutoff filter accordingly
   – For example: 6Hz / 0.802 = 7.48Hz (new cutoff)
• In Excel…
• Create a “4th order, 0-phase lag” low pass digital filter
   – Use earlier slide from Winter, 1990, p.38 for filter coefficients
• Input you will need:
   – Sampling frequency (fs) = 69.9Hz
   – Use a Cutoff frequency (fc) = 6Hz (for starters)
       • At the end, let this be a variable you can change
   – Raw kinematic data (add appropriate column headers)
   – Use the Data File provided (it is kinematics data)
   – x-y data for toe, heel, ankle, knee, hip, shoulder, WBCOM “markers”
• Output: Filtered data
   – A new column for each column of original data
• Presentation:
   – Graph raw and smoothed data (with 6Hz cutoff) – Vertical
     Position will do
   – Email or bring soft copy of spreadsheet (this will contain your
   – Organization will count. I will need to be able to figure out
     where your cutoff and sampling frequency values are, and check
     your formulas.

To top