EMG işaretlerinin özniteliklerinin çıkarılması, kNN ve YSA yöntemleri ile sınıflandırılması
Classification of the EMG signal using neural network pattern recognition and kNN algorithm
Yazar: ÇAĞRI ÇERÇİ
Danışman: PROF. DR. HAKAN TEMELTAŞ
İstanbul Teknik Üniversitesi / Fen Bilimleri Enstitüsü / Kontrol ve Otomasyon Mühendisliği Ana Bilim Dalı
Derece: Yüksek Lisans, 2017
Konu: Bilgisayar Mühendisliği Bilimleri-Bilgisayar ve Kontrol = Computer Engineering and Computer Science and Control
Dizin: Yapay sinir ağları = Artificial neural networks

Özet:
Kas hücreleri, kasılıp gevşeyerek elektriksel işaretler meydana getirir. Bu işaretlere miyoelektrik işaretler adı verilir. Bu işaretlerin elektrotlar yardımıyla elde edilip analiz edilmesine elektromiyografi (EMG) adı verilmektedir. Kasın hareketi farklılaştıkça elde edilen işaretler de farklılaşacak, öznitelik matrislerinde oluşan değerler de bu sayede değişiklikler göstereceklerdir. Bu sayede yapılan hareketlerin ayırt edilmesi de mümkün hale gelecektir.
Tez kapsamında hareket sinyalleri olarak hazır veri setleri kullanılmıştır. Sınıflandırılması amaçlanan veri setinde incelenen hareketler, El kapama (E-K), Baş parmağı (B), İşaret parmağı (İ), Orta parmak (O), Yüzük parmağı (Y), Baş-İşaret (B-İ), Baş-Orta (B-O), Baş-Yüzük (B-Y) parmaklarını kapama hareketleri olmak üzere 8 tanedir. Veri setindeki bu hareketler için 4 farklı kişinin ön kolundan, 2 elektrot kullanılarak, her bir hareket türü için 5 saniye süresince 4000 Hz frekansıyla örneklenmiş 6 sinyal alınmıştır. Daha sonra bu sinyaller 20 ile 450 Hz aralığında band geçiren filtre ile filtrelenmiştir.
Alınan sinyaller üzerine, öncelikle pencereleme işlemi uygulanmıştır. Sonrasında her bir pencere için özellik değerleri oluşturulmuştur. Pencere boyutları olarak 50 ms, 100 ms, 150 ms, 200 ms, 250 ms'lik zaman uzunlukları kullanılmıştır. Ardından her bir pencere için sıfır geçiş noktası sayısı (SG), dalga formu uzunluğu (DU), eğim işareti değişikliği (EİD), ortalama mutlak değer (OMD), willison genliği (WG), çarpıklık (Ç), varyans (VAR), karekök ortalama değeri (RMS) ve Hjorth zaman bölgesi parametreleri, değişkenlik (MOB) ve karmaşıklık (COMP) öznitelik çıkarım yöntemleri uygulanmış, böylece her bir pencere için öznitelik vektörleri oluşturulmuştur. Ardından bu öznitelik vektörlerine, kendi öznitelik grupları içerisinde min max normalizasyon işlemi uygulanmış ve tüm değerlerin 0 ile 1 arasında olması sağlanmıştır.
Son olarak elde edilen öznitelik vektörleri k en yakın komşular (kNN) algoritması ve yapay sinir ağları örüntü tanıma yöntemi uygulanarak sınıflandırılması sağlanmıştır. kNN algoritması için verilerin 3'te 2'si eğitim, 3'te 1'i ise test verisi olarak kullanılmışlardır. Kullanılacak olan en yakın komşu sayısı tespit edilmiş ardından da çoğunluk oylaması yöntemi uygulanmıştır. Yapay sinir ağları örüntü tanıma yöntemi için ise öznitelik vektörlerinin %70'i eğitim, %15'i doğrulama ve %15'i de test için kullanılmıştır. 
Tüm bu işlemler tamamlandıktan sonra sınıflandırma doğrulukları sonuçlarına geçilmiştir. Pencereleme zamanının artmasının sınıflandırma yüzdesinin de artmasına neden olduğu gösterilmiştir. Fakat pencere uzunluklarının işlem zamanına etkisi de dikkate alındığında ve gerçek zaman performansı açısından en uygun olabilecek pencerelerin 100 ve 150 ms'lik pencereler olabileceği anlatılmıştır. kNN algoritması için toplam doğruluk yüzdesi 100 ms'lik pencere için yaklaşık %84 iken pencere uzunluğu 150 ms'ye çıkarıldığında yaklaşık %89'a yükselmiştir. Aynı zamanda yapay sinir ağları algoritması için ise, 100 ms'lik pencereleme zamanı dikkate alındığında sınıflandırma doğruluğu %90 civarında olurken 150 ms'lik pencere için ise %93 civarına yükselmiştir.

Abstract:
As a result of the contraction and relaxation movements performed by the muscle cells, electrical signals occur. These signals are called as myoelectric signals. Obtaining and analyzing these signals with surface or needle electrodes is called as Electromyography (EMG). The differentiation of muscle movements will also result in differentiated signals. Therefore, the values that occur in the feature matrices will also change. Consequently, it becomes possible to distinguish which movements made. In the thesis, it is aimed to classify these myoelectric signals by using two different methods, namely the k-nearest neighbors algorithm and the artificial neural network (ANN) pattern recognition method. Later on, it is predicted that it can be used directed wheelchair, autonomous robot control and many similar works can be done by using these algorithms.
The first part is the introduction section, and it is mentioned here from the general definitions, the literature summary and thesis organization. The second part is where EMG signals are described. This section describes muscle structures, signals that are activated by the movements of the muscles, how EMG signals are formed and how to obtain them. We can get the operations up to this section, under the heading of data collection. In the next step, the features to be used to distinguish the signals from each other are explained in detail. At the same time, the windowing and normalization steps used in signal processing are described in this section. In the fourth chapter, the classification of these signals in the extracted features has been processed. In this section, detailed information about classification methods of k Nearest Neighborhood and Artificial Neural Network Pattern Recognition is given. This section was followed by comments on experimental work.
In the thesis, data sets obtained from another study were used as motion signals. Movements examined in the data set intended for classification are eight, including hand closure (EK), Thumb (B), Index (İ), Middle (O), Ring (Y), Thumb-Index (B-İ), Thumb-Middle (B-O),  Thumb-Ring (B-Y). The analyzed signals were collected from four different individuals. Three electrodes were placed in the forearm to collect the data. One of which is the reference electrode used to reduce the noise of the signal. For each motion type, six signals sampled at a frequency of 4000 Hz were obtained for five seconds. These signals are then filtered by a band pass filter between 20 and        450 Hz.
On receiving signals, firstly windowing is performed which separates the signal into small pieces. Subsequently, the feature of each window were extracted, and the feature vectors for each window were created. Applied windowing times are 50 ms, 100 ms, 150 ms, 200 ms and 250 ms. Afterwards, the number of Zero Crossing points (SG), Waveform Length (DU), the number of Slope Sign Changes (EID), Mean Absolute Value (OMD), Willison Amplitude (WG), Sample Skewness (Ç), Variance (VAR), Root Mean Square value (RMS) and Hjorth time domain parameters, Mobility (MOB) and Complexity (COMP) feature extraction methods used and they were applied for each window.
The zero crossing number indicates how many times the signal passes through the zero line. In the thesis study, the threshold value was applied on the signal and it was prevented to count the small extensions and noises on this signal, and more specific feature vectors were created.
The waveform length will ensure that the total amplitude of the signal is measured. When calculating this, the differences between consecutive points of the signal are taken. Then the absolute value of these numbers is taken and added to the general sum, named waveform length.
In the slope sign change feature extraction method, the sign of the slope of the signal is examined. With this method, it is calculated how many times the slope of the signal changes. In order not to get wrong results, it is necessary to do not take into account the slope changes caused by noise of the signal. A suitable threshold value should be determined for this.
The mean absolute value is calculated by taking the absolute value of the entire window examined and calculating the arithmetic average of these values.
The Willison amplitude analyzes two consecutive samples of the EMG signal. It compares between the difference these two samples and determined threshold value. If the difference exceeds the threshold value, the Willison Amplitude value is incremented by one. This method is useful for reducing the noise effects on the signal.
Sample skewness is calculated taking into account the amplitude values of the signal. It shows how many samples the signal has which amplitude value. The example of the skewness in this study is explained using the histogram in chapter three. Mathematical calculations are given.
In probability theory and statistics, variance is the expectation of the squared deviation of a random variable from its mean, and it informally measures how far a set of numbers are spread out from their mean.
In statistics and its applications, the root mean square is defined as the arithmetic mean of the squares of a set of numbers. It is used in the thesis as an feature extraction method.
Finally, Hjorth time domain parameters are used. Here, mobility and complexity parameters are examined. Since these calculations depend on the variance of the signal, they are considered suitable for the calculation load. Additionally, the more similar the signal is to the pure sinus signal, the closer the complexity value is to one.
Using the methods described above, feature vectors for each window were created. In order to make the classification performance more efficient, the normalization process of the created feature matrices should be used. In the attribute matrices, some values may be too large or too small, depending on the attribute type. These values affect the classifiers negatively. All inputs scaled between 0 and 1 within their feature set for better classification results. Normalization step is performed for this two-channel signal, normalization is done separately within the attribute groups. Min Max normalization process is applied as normalization method. Consequently, all values are set between zero and one.
Finally, in the classification step, the obtained feature vectors are classified by applying the k Nearest Neighbors (kNN) algorithm and Artificial Neural Network (ANN) pattern recognition method. Classified signals are received from 4 people, includes 8 movements and data length is 5 seconds. The number of feature vectors to be classified according to window lengths (50, 100, 150, 200, 250 ms) varies between 4800 and 640. To measure the accuracy of the k nearest neighbourhood algorithm, two-thirds of the data of these vectors were used as training and one-three of the data of these vectors were used as test vectors. The number of the nearest neighbors to be used was determined and then the majority voting method was applied. In order to calculate the accuracy percentage of the artificial neural network pattern recognition method, 15% of the feature vectors were used for the test, 70% of the network was train and 15% was used for validation.
After all these operations are completed, classification accuracy is shown. Classification accuracy was obtained for four different people and five different window sizes from 50 ms to 150 ms. Then, the average of four results was calculated. It was determined that increasing the windowing time also increased the classification percentage. However, it was explained that the windows which can be most suitable in terms of the real time performance and the effect of window lengths on processing times are 100 and 150 ms windows. The total accuracy percentage for the k Nearest Neighborhood algorithm was found to be about 84% for a window of 100 ms, and about 89% when the window length was increased to 150 ms. On the other hand, for the artificial neural network method, when 100 ms windowing time is taken into consideration, the classification accuracy is about 90%, whereas it is about 93% for 150 ms window.