signal processing and pattern recognition using …rbgandhi.mysite.syr.edu/fpga.pdf · signal...

16
CSE-791 FPGA Circuits and Applications Fall 2009 Project Report on Signal Processing and Pattern Recognition using Continuous Wavelets Under guidance of Prof. Fred Schlereth By Ronak Gandhi

Upload: lyhanh

Post on 09-Feb-2018

223 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Signal Processing and Pattern Recognition using …rbgandhi.mysite.syr.edu/FPGA.pdf · Signal Processing and Pattern Recognition using Continuous Wavelets Ronak Gandhi, Syracuse University,

CSE-791 FPGA Circuits and Applications Fall 2009

Project Report on

Signal Processing and Pattern Recognition using Continuous Wavelets

Under guidance of

Prof. Fred Schlereth

By

Ronak Gandhi

Page 2: Signal Processing and Pattern Recognition using …rbgandhi.mysite.syr.edu/FPGA.pdf · Signal Processing and Pattern Recognition using Continuous Wavelets Ronak Gandhi, Syracuse University,

Signal Processing and Pattern Recognition using Continuous Wavelets Ronak Gandhi, Syracuse University, Fall 2009

Goal

This work aims at designing and implementing FPGA based module to process and perform pattern recognition on EMG (Electromyography) signals that are received from human muscular movements that are otherwise complex to analyze on some standard methods.

Purpose

On the completion of this work we want to gain proficiency in following areas

Studying the available algorithms for processing wavelets

Generation and composition of periodic and random signals similar to natural EMG signals using available MATLAB functions

Gaining experience and analyzing the stages involved for processing EMG data

Examining the EMG signals using Wavelet functions and Toolbox on MATLAB

Developing our own algorithm for EMG detection using MATLAB

Implementing our algorithm on real time FPGA based system and familiarize with Xilinx tools

Final aim is to implement the design on Spartan 3E kit and analyzing the results on real time input from hardware interface.

Abstract In recent time biological signals like EMG which are used in medical diagnose and researchers have studied not only time field but also frequency field. Electromyography (EMG) is a technique for evaluating and recording the activation signal of muscles. EMG recording technique is performed using an instrument called an electromyograph, to produce a record called an electromyogram. Mathematical models to analyze electromyogram includes wavelet transform, time-frequency approaches, Fourier transform, Wigner-Ville Distribution (WVD), statistical measures, and higher-order statistics. All approaches towards signal recognition include Artificial Neural Networks (ANN), dynamic recurrent neural networks (DRNN), and fuzzy logic system. In most of the present approach Genetic Algorithm (GA) has also been applied in evolvable hardware chip for the mapping of EMG inputs to desired hand actions. Metrics method has also been used to quantatively analyzing EMG signals by accessing their timing and amplitude characteristics in the past where the method tries to correlate the portions of EMG signals with the previously available metrics. We designed our mother wavelet and performed Wavelet transformation method to detect the specific pattern of generated wavelet in the give EMG signal. These signals are then categorized for different hand movement and disablitites.

Page 3: Signal Processing and Pattern Recognition using …rbgandhi.mysite.syr.edu/FPGA.pdf · Signal Processing and Pattern Recognition using Continuous Wavelets Ronak Gandhi, Syracuse University,

Signal Processing and Pattern Recognition using Continuous Wavelets Ronak Gandhi, Syracuse University, Fall 2009

Introduction Electromyography (EMG) signal is a kind of biology electric motion which was produced by muscles and the neural system. EMG signals are non-stationary and have highly complex time and frequency characteristics. Consequently, these signals can not be analyzed using classical methods such as Fourier Transform, AR, MA, ARMA. Although the STFT can be used to satisfy the stationary condition for such nonstationary signals, it suffers from the fact that the performance depends on appropriate length of the desired segment of the signal. To overcome such problems, wavelet transform was used as a future extraction method and has been widely used in signal analysis. The transform techniques, which are used in signal analysis, has been thought only in time domain or in frequency domain. Although there is a relationship between time and frequency domain, existing analysis techniques are limited to one of these domains. The wavelet transform, which has improved to reveal the information that the signal contains both in time, frequency and space to analyze non-stationary signals, is obtained by getting projection at signal over wavelet functions. Wavelet functions are obtained by shifting and spreading the mother wavelet. The proposed work addresses the issue and methodologies for generating signals that are periodic in nature. We designed a pattern and then modeled it to mother wavelet for our analysis. Apart from that we generated pseudorandom signals which are able to accurately detect the pattern within the random signal with ample amount of noise. The wavelets are then searched within complex/noise signals that are generated from source.

Page 4: Signal Processing and Pattern Recognition using …rbgandhi.mysite.syr.edu/FPGA.pdf · Signal Processing and Pattern Recognition using Continuous Wavelets Ronak Gandhi, Syracuse University,

Signal Processing and Pattern Recognition using Continuous Wavelets Ronak Gandhi, Syracuse University, Fall 2009

What is EMG?

An electromyography(EMG) detects the electrical potential generated by muscle cells when these cells are both mechanically active and at rest. The signals can be analyzed in order to detect medical abnormalities or analyze the biomechanics of human or animal movement. There are still limitations in detection and characterization of existing nonlinearities in the surface electromyography (sEMG, a special technique for studying muscle signals) signal, estimation of the phase, acquiring exact information due to derivation from normality. Traditional system reconstruction algorithms have various limitations and considerable computational complexity and many show high variance (1). Recent advances in technologies of signal processing and mathematical models have made it practical to develop advanced EMG detection and analysis techniques. Various mathematical techniques and Artificial Intelligence (AI) have received extensive attraction. There are two kinds of EMG in widespread use: surface EMG and needle (intramuscular) EMG. To perform intramuscular EMG, a needle electrode is inserted through the skin into the muscle tissue. A trained professional (most often a physiatrist, neurologist, physical therapist, or chiropractor) observes the electrical activity while inserting the electrode. The insertional activity provides valuable information about the state of the muscle and its innervating nerve. Normal muscles at rest make certain, normal electrical sounds when the needle is inserted into them. Then the electrical activity when the muscle is at rest is studied. Abnormal spontaneous activity might indicate some nerve and/or muscle damage. Then the patient is asked to contract the muscle smoothly. The shape, size and frequency of the resulting motor unit potentials is judged. Then the electrode is retracted a few millimeters, and again the activity is analyzed until at least 10-20 units have been collected. Each electrode track gives only a very local picture of the activity of the whole muscle. Because skeletal muscles differ in the inner structure, the electrode has to be placed at various locations to obtain an accurate study. Instead, a surface electrode may be used to monitor the general picture of muscle activation, as opposed to the activity of only a few fibres as observed using a needle. This technique is used in a number of settings; for example, in the physiotherapy clinic, muscle activation is monitored using surface EMG and patients have an auditory or visual stimulus to help them know when they are activating the muscle (biofeedback). A motor unit is defined as one motor neuron and all of the muscle fibers it innervates. When a motor unit fires, the impulse (called an action potential) is carried down the motor neuron to the muscle. The area where the nerve contacts the muscle is called the neuromuscular junction, or the motor end plate. After the action potential is transmitted across the neuromuscular junction, an action potential is elicited in all of the innervated muscle fibers of that particular motor unit. The sum of all this electrical activity is known as a motor unit action potential (MUAP). This electrophysiologic activity from multiple motor units is the signal typically evaluated during an EMG. The composition of the motor unit, the number of muscle fibres per motor unit, the metabolic type of muscle fibres and many other factors affect the shape of the motor unit potentials in the myogram.

Page 5: Signal Processing and Pattern Recognition using …rbgandhi.mysite.syr.edu/FPGA.pdf · Signal Processing and Pattern Recognition using Continuous Wavelets Ronak Gandhi, Syracuse University,

Signal Processing and Pattern Recognition using Continuous Wavelets Ronak Gandhi, Syracuse University, Fall 2009

What is Wavelets? The fundamental idea behind wavelets is to analyze according to scale. Indeed, some researchers in the wavelet field feel that, by using wavelets, one is adopting a whole new mindset or perspective in processing data. Wavelets are functions that satisfy certain mathematical requirements and are used in representing data or other functions. Approximation using superposition of functions that could superpose sines and cosines to represent other functions. However, in wavelet analysis, the scale that we use to look at data plays a special role. Wavelet algorithms process data at different scales or resolutions. If we look at a signal with a large "window," we would notice gross features. Similarly, if we look at a signal with a small "window," we would notice small features. This makes wavelets interesting and useful. By their definition, these functions are non-local. They therefore do a very poor job in approximating sharp spikes. But with wavelet analysis, we can use approximating functions that are contained neatly in finite domains. Wavelets are well-suited for approximating data with sharp discontinuities. The wavelet analysis procedure is to adopt a wavelet prototype function, called an analyzing wavelet or mother wavelet. Temporal analysis is performed with a contracted, high-frequency version of the prototype wavelet, while frequency analysis is performed with a dilated, low-frequency version of the same wavelet. Because the original signal or function can be represented in terms of a wavelet expansion (using coefficients in a linear combination of the wavelet functions), data operations can be performed using just the corresponding wavelet coefficients. And if you further choose the best wavelets adapted to your data, or truncate the coefficients below a threshold, your data is sparsely represented. This sparse coding makes wavelets an excellent tool in the field of data compression.

Page 6: Signal Processing and Pattern Recognition using …rbgandhi.mysite.syr.edu/FPGA.pdf · Signal Processing and Pattern Recognition using Continuous Wavelets Ronak Gandhi, Syracuse University,

Signal Processing and Pattern Recognition using Continuous Wavelets Ronak Gandhi, Syracuse University, Fall 2009

Types of wavelets Continuous Wavelet Transform : Mathematically, the process of Fourier analysis is represented by the Fourier transform:

which is the sum over all time of the signal f(t) multiplied by a complex exponential. (Recall that a complex exponential can be broken down into real and imaginary sinusoidal components.) The results of the transform are the Fourier coefficients F(ᵚ) , which when multiplied by a sinusoid of frequency yield the constituent sinusoidal components of the original signal. Graphically, the process looks like

Similarly, the continuous wavelet transform (CWT) is defined as the sum over all time of the signal multiplied by scaled, shifted versions of the wavelet function ᵠ :

The results of the CWT are many wavelet coefficients C, which are a function of scale and position. Multiplying each coefficient by the appropriately scaled and shifted wavelet yields the constituent wavelets of the original signal

What's Continuous About the Continuous Wavelet Transform? Any signal processing performed on a computer using real-world data must be performed on a discrete signal -- that is, on a signal that has been measured at discrete time. CWT distinguishes set of scales and positions at which it operates. Unlike the discrete wavelet transform, the CWT can operate at every scale, from that of the original signal up to some maximum scale that you determine by trading off your need for detailed analysis with available computational horsepower. The CWT is also continuous in terms of shifting: during computation, the analyzing wavelet is shifted smoothly over the full domain of the analyzed function.

Page 7: Signal Processing and Pattern Recognition using …rbgandhi.mysite.syr.edu/FPGA.pdf · Signal Processing and Pattern Recognition using Continuous Wavelets Ronak Gandhi, Syracuse University,

Signal Processing and Pattern Recognition using Continuous Wavelets Ronak Gandhi, Syracuse University, Fall 2009

Discrete Wavelet Transform Calculating wavelet coefficients at every possible scale is a fair amount of work, and it generates an awful lot of data. In this scales and positions based on powers of two -- so-called dyadic scales and positions -- then our analysis which are more efficient and just as accurate. We obtain such an analysis from the discrete wavelet transform (DWT). An efficient way to implement this scheme using filters was developed in 1988 by Mallat. The Mallat algorithm is in fact a classical scheme known in the signal processing community as a two-channel sub band coder .This very practical filtering algorithm yields a fast wavelet transform -- a box into which a signal passes, and out of which wavelet coefficients quickly emerge. Let's examine this in more depth. One-Stage Filtering: Approximations and Details For many signals, the low-frequency content is the most important part. It is what gives the signal its identity. The high-frequency content, on the other hand, imparts flavor or nuance. Consider the human voice. If you remove the high-frequency components, the voice sounds different, but you can still tell what's being said. However, if you remove enough of the low-frequency components, you hear gibberish. In wavelet analysis, we often speak of approximations and details. The approximations are the high-scale, low-frequency components of the signal. The details are the low-scale, high-frequency components. The filtering process, at its most basic level, looks like this.

The original signal, S, passes through two complementary filters and emerges as two signals. Unfortunately, if we actually perform this operation on a real digital signal, we wind up with twice as much data as we started with. Suppose, for instance, that the original signal S consists of 1000 samples of data. Then the resulting signals will each have 1000 samples, for a total of 2000. These signals A and D are interesting, but we get 2000 values instead of the 1000 we had. There exists a more subtle way to perform the decomposition using wavelets. By looking carefully at the computation, we may keep only one point out of two in each of the two 2000-length samples to get the complete information. This is the notion of downsampling. We produce two sequences called cA and cD.

Page 8: Signal Processing and Pattern Recognition using …rbgandhi.mysite.syr.edu/FPGA.pdf · Signal Processing and Pattern Recognition using Continuous Wavelets Ronak Gandhi, Syracuse University,

Signal Processing and Pattern Recognition using Continuous Wavelets Ronak Gandhi, Syracuse University, Fall 2009

The process on the right, which includes downsampling, produces DWT coefficients. To gain a better appreciation of this process, let's perform a one-stage discrete wavelet transform of a signal. Our signal will be a pure sinusoid with high-frequency noise added to it. Here is our schematic diagram with real signals inserted into it.

Page 9: Signal Processing and Pattern Recognition using …rbgandhi.mysite.syr.edu/FPGA.pdf · Signal Processing and Pattern Recognition using Continuous Wavelets Ronak Gandhi, Syracuse University,

Signal Processing and Pattern Recognition using Continuous Wavelets Ronak Gandhi, Syracuse University, Fall 2009

Wavelet Packet Analysis The wavelet packet method is a generalization of wavelet decomposition that offers a richer range of possibilities for signal analysis. In wavelet analysis, a signal is split into an approximation and a detail. The approximation is then itself split into a second-level approximation and detail, and the process is repeated. For an n-level decomposition, there are n+1 possible ways to decompose or encode the signal.

In wavelet packet analysis, the details as well as the approximations can be split. This yields more than different ways to encode the signal. This is the wavelet packet decomposition tree.

The wavelet decomposition tree is a part of this complete binary tree. For instance, wavelet packet analysis allows the signal S to be represented as A1 + AAD3 + DAD3 + DD2. This is an example of a representation that is not possible with ordinary wavelet analysis. Choosing one out of all these possible encodings presents an interesting problem. In this toolbox, we use an entropy-based criterion to select the most suitable decomposition of a given signal. This means we look at each node of the decomposition tree and quantify the information to be gained by performing each split.

Page 10: Signal Processing and Pattern Recognition using …rbgandhi.mysite.syr.edu/FPGA.pdf · Signal Processing and Pattern Recognition using Continuous Wavelets Ronak Gandhi, Syracuse University,

Signal Processing and Pattern Recognition using Continuous Wavelets Ronak Gandhi, Syracuse University, Fall 2009

Simple and efficient algorithms exist for both wavelet packet decomposition and optimal decomposition selection. This toolbox uses an adaptive filtering algorithm, based on work by Coifman and Wickerhauser (see [CoiW92] in References), with direct applications in optimal signal coding and data compression. Such algorithms allow the Wavelet Packet 1-D and Wavelet Packet 2-D tools to include "Best Level" and "Best Tree" features that optimize the decomposition both globally and with respect to each node.

Page 11: Signal Processing and Pattern Recognition using …rbgandhi.mysite.syr.edu/FPGA.pdf · Signal Processing and Pattern Recognition using Continuous Wavelets Ronak Gandhi, Syracuse University,

Signal Processing and Pattern Recognition using Continuous Wavelets Ronak Gandhi, Syracuse University, Fall 2009

Design Overview The signal generation mechanism for EMG signals comprises of the summation of many muscle unit action potentials (MUAPS) which are located in the muscle fibers. These impulse-like signals from the muscle are captured by the sensor through the skin interface and sensor. We hypothesize that the motion of the hand during the formation of a character is associated with the firing of thousands of MUAPs which occur at different times and with different amplitudes. The surface sensor can only see the summation of these individual signals. MUAPs that are known to have different shapes from simple impulse, square wave to complex Mexican hat function as shown below

Wavelet for Impulse

Haar Wavelet (Square in shape)

Mexican Hat

Page 12: Signal Processing and Pattern Recognition using …rbgandhi.mysite.syr.edu/FPGA.pdf · Signal Processing and Pattern Recognition using Continuous Wavelets Ronak Gandhi, Syracuse University,

Signal Processing and Pattern Recognition using Continuous Wavelets Ronak Gandhi, Syracuse University, Fall 2009

For our project we input complex pattern that was build in Matlab as shown below

Figure shows the input generated for generating wavelet

This pattern was converted in to wavelet with use of wavelet tool for analysis. Else can also be build with the help of Matlab function. The wavelet generated from above pattern

Figure shows the wavelet generated from the input pattern

Page 13: Signal Processing and Pattern Recognition using …rbgandhi.mysite.syr.edu/FPGA.pdf · Signal Processing and Pattern Recognition using Continuous Wavelets Ronak Gandhi, Syracuse University,

Signal Processing and Pattern Recognition using Continuous Wavelets Ronak Gandhi, Syracuse University, Fall 2009

Different test signals were applied like adding wavelet within EMG and also added three large MUAPs to the typical EMG signal. The result were shown below.

Figure shows the input on top in which input patter is super imposed on ECG and 3D is the response of detection

Figure shows different addition of three different pattern within EMG and the respose in 3D show the detection of signal

Page 14: Signal Processing and Pattern Recognition using …rbgandhi.mysite.syr.edu/FPGA.pdf · Signal Processing and Pattern Recognition using Continuous Wavelets Ronak Gandhi, Syracuse University,

Signal Processing and Pattern Recognition using Continuous Wavelets Ronak Gandhi, Syracuse University, Fall 2009

Creating a new wavelet

%% Creating a wavelet of type 4 - wavelet without scaling function. % Next we create a wavelet family of type 4. These wavelets have no % associated scaling function and so, are only available for continuous % wavelet analysis.

familyName = 'Give a suitlable family name'; familyShortName = 'Give a suitable short name'; familyWaveType = 4; familyNums = 'version number for the wave'; fileWaveName = 'load the wavelet file'; familyBounds = [Max -Min limit for wavelet];

%% % Add this new wavelet family to the stack of wavelet families. wavemngr('add',familyName,familyShortName,familyWaveType, ... familyNums,fileWaveName,familyBounds)

%% % The file *mywwavf.m* is already defined, so we can display its content.

%% % Note that this function is available in the directory % |$MATLABHOME/wavelet/wavedemo| of the Wavelet Toolbox. %% % Verify that the wavelet family is created.

%% % Display the wavelet function.

%% % Load data file

% Now compute the scalogram of the |sumsin| signal using this new % wavelet. %%

%% % We can analyze the same signal using the Continuous Wavelet Transform % (CWT) with the new wavelet and display it as a 3-D representation.

Page 15: Signal Processing and Pattern Recognition using …rbgandhi.mysite.syr.edu/FPGA.pdf · Signal Processing and Pattern Recognition using Continuous Wavelets Ronak Gandhi, Syracuse University,

Signal Processing and Pattern Recognition using Continuous Wavelets Ronak Gandhi, Syracuse University, Fall 2009

Analysis of Results

From the above results we can conclude that we will have the coefficients produced at different scales by different sections of the signal. The coefficients constitute the results of a regression of the original signal performed on the wavelets.

We plot the response in 2D on which the x-axis represents position along the signal (time), the y-axis represents scale, and the color at each x-y point represents the magnitude of the wavelet coefficient C. These are the coefficient plots generated by the graphical tools. These coefficient plots resemble a bumpy surface viewed from above. If we could look at the same surface from the side.

The continuous wavelet transform coefficient plots are precisely the time-scale view of the signal we referred to earlier. It is a different view of signal data from the time-frequency Fourier view, but it is not unrelated.

We can conclude that from a given complex pattern we can accurately spot the wavelet from the given signal and also the position and it time value along with the magnitude of each in term of co-efficient.

Future Work – The road ahead

We are planning to develop algorithm for detection of EMG and developing a standalone FPGA model.

This work can be extended to making modules using the developed algorithm for real time fast computation of EMG signals in different applications where in which these modules can be used as standalone systems.

Page 16: Signal Processing and Pattern Recognition using …rbgandhi.mysite.syr.edu/FPGA.pdf · Signal Processing and Pattern Recognition using Continuous Wavelets Ronak Gandhi, Syracuse University,

Signal Processing and Pattern Recognition using Continuous Wavelets Ronak Gandhi, Syracuse University, Fall 2009

References

Quantification of the dynamic properties of EMG patterns during gait, Anthony L. Ricamato, Joseph M. Hidler, Journal of Electromyography and Kinesiology

Comparison of Wavelet and Short Time Fourier Transform Methods in the Analysis of EMG Signals, Mehmet Rahmi Canal

Mathwork manual, www.mathwork.com

Adaptive signal Processing, Warren &Stoarns

Stratification of time frequency abnormalities in the signal averaged high resolution ECG in Post infarction Patients with and without ventricular tachycardic and congenitial long QT syndrome by Jean Philippe, Samir Fareh & Philippe Chevalier

Detection of Spindles in Sleep EEGs Using a Novel Algorithm Based on Hilbert-Huang Transform by Zhihua Yang, Lihua Yang and Dongxu Qi

Techniques of EMG signal analysis: detection, processing, classification and applications

Biological Procedure Online. M.B.I. Raez, M.S. Hussain, and F. Mohd-Yasin

An evaluation of the utility and limitation of counting motor unit action potential in the surface electromyogram, Ping Zhou and William Zev Rymer