How to cite: S. Suwanto, M. Bisri, D. Novitasari, and A. Asyhar, β€œClassification of EEG Signals using Fast Fourier Transform (FFT) and Adaptive Neuro Fuzzy Inference System (ANFIS)”, mantik, vol. 5, no. 1, pp. 36-45, May 2019. Jurnal Matematika MANTIK Vol. 5, No. 1, May 2019, pp. 35-44 ISSN: 2527-3159 (print) 2527-3167 (online) Classification of EEG Signals using Fast Fourier Transform (FFT) and Adaptive Neuro-Fuzzy Inference System (ANFIS) Dian C. R. Novitasari1, Suwanto2, M. Hasan Bisri3, Ahmad Hanif Asyhar4 UIN Sunan Ampel Surabaya, diancrini@uinsby.ac.id1 UIN Sunan Ampel, h72216070@uinsby.ac.id2 UIN Sunan Ampel, bisri7940@gmail.com3 UIN Sunan Ampel, hanif@uinsby.ac.id4 doi: https://doi.org/10.15642/mantik.2019.5.1.35-44 Abstrak: Epilepsi merupakan penyakit yang menyerang otak dan mengakibatkan seseorang mengalami kejang karena adanya gangguan system saraf pusat (neurologis) sehingga menyebabkan hilang kesadaran. Aktifitas listrik otak direkam menggunakan uji sinyal EEG, karena dengan uji EEG dapat digunakan untuk mendiagnosa penyakit otak dan mental seperti epilepsi. Tujuan yang hendak dicapai pada penelitian ini adalah agar dapat mengidentifikasi seseorang mengidap epilepsi atau tidak menggunakan metode Fast Fourier Transform (FFT) dan Adaptive Neuro Fuzzy Inference System (ANFIS) serta hasil tingkat akurasi, sensitivitas, dan presisi dari penggunaan metode tersebut. Metode FFT digunakan untuk mentransformasikan sinyal EEG yang semula berbasis waktu menjadi sinyal EEG berbasis frekuensi dan dilanjutkan dengan proses ekstraksi fitur untuk mengambil ciri setiap sinyal hasil pemfilteran menggunakan median, mean dan standar deviasi pada setiap sinyal EEG. Hasil dari ektraksi fitur digunakan sebagai input pada proses pengelompokan berdasarkan ciri data (klasifikasi) menggunakan ANFIS. Data sinyal EEG didapat dari database yang tersedia secara online dari Pusat Epilepsi Universitas Bonn, Jerman. Hasil sistem klasifikasi dengan dua kelas (Normal-Epilepsi) didapatkan akurasi, sensitivitas, dan presisi sebesar 100% dan sistem klasifikasi sinyal EEG menggunakan ANFIS dengan pembagian tiga kelas (Normal-Not Seizure Epilepsy-Epilepsy) menghasilkan akurasi sebesar 89.33% sensitivitas sebesar 89.37% dan presisi sebesar 89.33%. Kata kunci: Epilepsi, EEG, Ekstraksi Fitur, Klaifikasi. Abstract: Epilepsy is a disease that attacks the brain and results in seizures due to neurological disorders. The electrical activity of the brain recorded by the EEG signal test, because EEG test can be used to diagnose brain and mental diseases such as epilepsy. This study aims to identify whether a person has epilepsy or not along with the result of accurate, sensitivity, and precision rate using Fast Fourier Transform (FFT) and Adaptive Neuro-Fuzzy Inference System (ANFIS) method. The FFT is used to transform EEG signals from time-based into frequency-based and continued with feature extraction to take characteristics from each filtering signal using the median, mean, and standard deviations of each EEG signal. The results of the feature extraction used for input on the category process based on characteristics data (classification) using ANFIS. EEG signal data is obtained from epilepsy center online database of Bonn University, German. The results of the EEG signal classification system using ANFIS with two classes (Normal-Epilepsy) states accuracy, sensitivity, and precision of 100%. The classification systems with three class division (Normal-Not Seizure Epilepsy-Epilepsy) resulted in an accuracy of 89.33% sensitivity of 89.37% and precision of 89.33%. Keywords: Epilepsy, EEG, Feature Extraction, Classification. mailto:h72216070@uinsby.ac.id Jurnal Matematika MANTIK Vol. 5, No. 1, May 2019, pp. 35-44 36 1. Introduction Epilepsy comes from Greek, namely "Epilepsia" which means chronic general neurological disorders characterized by recurrent and temporary seizures. About 90% of people with epilepsy founded in developing countries. In Indonesia, the number of epilepsy sufferers is increasing every year, in 2012 there were 1.8 million active epilepsy patients per 220 million people [1]. Recently, epilepsy can be detected by looking at EEG signals. EEG signal measurement was considered easier and cheaper than measurement with another method so that the measurement of EEG signals is more desirable. EEG is a device capable of capturing spontaneous electrical activity from the brain obtained by capturing electrical signals from the neurons to neurons [2]. Alternative detection using EEG signals can use machine learning assistance, and signal data processing and early identification can be done quickly. These alternatives can be used to find specific features that exist by searching for the main signals. Research into the detection of epilepsy using EEG signals has been carried out by several methods. Some of them were conducted by [3, 4] who implemented the FCM and ANMBP methods that extracted features by clustering each signal using FCM then calculating each probability on each cluster and classifying it using ANMBP. In other research [5] Rational Discrete Short-Time Fourier Transform is used, besides that [6] also conducted EEG signal classification research using Empirical Mode Decomposition (EMD) and Adaptive Neuro- Fuzzy Inference System (ANFIS). In the EEG signal classification process, it is necessary to do preprocessing with feature extraction, there are several methods used for feature extraction, including wavelets, EMD, and FFT. In the research [6] on EEG signal classification got 95% accuracy using EMD as feature extraction, Wavelet feature extraction in the study conducted by [7] found an average accuracy percentage of 87.424%. Then in cough disease classification research was based on sound data signals using FFT as a method for feature extraction by [8] gets the highest accuracy rate of 86.6667%. Various methods for classifying data include back propagation by [9], which in the human voice signal pattern recognition study obtained an accuracy of 74%, then on the classification of types of cow leather using multilayer perceptron by [10] that found the classification accuracy rate reached 87.83%, then the research classification of employee performance by [11] using ANFIS obtained an accuracy value of 89%. Based on existing conditions, in this study a classification system will be created with FFT as a feature extraction method and ANFIS as a classification method, using these methods is expected to be able to distinguish with the best accuracy result in normal or epileptic condition and distinguish normal, epileptic not seizure, or epileptic seizure condition. 2. Literature Review 2.1 Electroencephalography (EEG) On the human scalp, there is electricity generated from the flow of ions flowing in a group of neurons in the brain. This electrical activity can be recorded by electroencephalography (EEG). Electrodes installed along the scalp to record brain activity in different positions. This EEG contains information about the state of the brain. Most doctors use EEG as a tool for diagnosing a brain and psychiatric illness [12]. EEG plays an important role in brain research, especially for diagnosing and classifying neurological diseases such as epilepsy. Recordings in patients with seizures, EEG signals show abnormal high amplitude. The object recorded is the bioelectric activity of neurons in the cortex cerebrum layer. The results of EEG recordings are brain wave signals that are in the voltage range of 5-100mV [13]. Recording this EEG signal captured by placing electrodes on the D. C. R. Novitasari, Suwanto, M. H. Bisri, and A. H. Asyhar Classification of EEG Signals using Fast Fourier Transform (FFT) and Adaptive Neuro Fuzzy Inference System (ANFIS) 37 scalp with the high temporal resolution the EEG signal will make the response to any changes in brain activity faster [14]. 2.2 Fast Fourier Transform (FFT) Fast Fourier Transform (FFT) is a Fourier transformation found by J. Fourier in 1965, which is the development of the Discrete Fourier Transform (DFT) algorithm in 1822. The FFT algorithm calculates transformation faster than DFT because there is a reduction in the looping process. FFT applied to the system to filter signals from the time domain to the frequency domain. Fourier transforms mathematically expressed as contained in equation 1 [15, 16]. 𝑠(𝑓) = ∫ 𝑠(𝑑) ∾ βˆ’βˆΎ 𝑒 βˆ’π‘—2πœ‹π‘“π‘‘ 𝑑𝑑 (1) Where: s(f) = frequency domain signal s(t) = time domain signal π‘’βˆ’π‘—2πœ‹π‘“π‘‘ = Constant f = frequency t = time 2.3 Adaptive Neuro-Fuzzy Inference System (ANFIS) ANFIS (Adaptive Neuro-Fuzzy Inference System) is a hybrid algorithm which is a combination of the Fuzzy Inference System (FIS) mechanism and the neural network method. ANFIS has two parameters, and there are premise parameters and consequent parameters. This hybrid training algorithm is carried out by step, forward, and backward [17, 18, 19]. Figure 1 shows the ANFIS architecture. Figure 1. ANFIS architecture Layer 1: Fuzzyfication In this layer, the formation of fuzzy sets will be carried out by using the membership function. There are several membership functions that can be used, including, Bell, Gaussian, trap, triangle, and others. The output in layer 1 stated as in equation 2, with i being data. 𝑂1𝑖 = ¡𝐴𝑖(x) = 1 1 + | π‘₯ βˆ’ 𝑐 π‘Ž | 2 (2) Jurnal Matematika MANTIK Vol. 5, No. 1, May 2019, pp. 35-44 38 Where: Β΅Ai(x) = degree of membership x = data input c = mean a = standard deviation Layer 2: Product In this layer, synthesized information transmitting with layer 1 and multiplying all incoming signals and sending the product out. Output in this layer expressed by equation 3: 𝑂2𝑖 = ¡𝐴𝑖(x). ¡𝐡𝑖(y) = π‘Šπ‘– (3) Where: Β΅Ai(x) = degree of membership Β΅Bi(y) = degree of membership W = firing strength Layer 3: Normalization The result of layer two normalized in layer 3. The output in layer 3 expressed in equation 4. 𝑂3𝑖 = π‘Šπ‘– π‘Š1 + π‘Š2 = Ε΄ (4) Where: W = firing strength Ε΄ = normalized firing strength Layer 4: Defuzzification Output at layer 4 calculated by using the formula in equation 5. 𝑂4𝑖 = Ŵ𝑖Ţ𝑖 = Ŵ𝑖(𝑝𝑖 π‘₯1 + π‘žπ‘– π‘₯2 + π‘Ÿπ‘– ) (5) Where: Ε΄ = normalized firing strength ΕΆ = {p, q, r} = set of consequent parameters. Layer 5: Output In this layer, the result of layer 5 is calculated by equation 6 that sum all entries. 𝑂5𝑖 = ΣŴ𝑖 Ţ𝑖 = 𝛴Ŵ𝑖Ţ𝑖 𝛴Ŵ𝑖 (6) Where: Ε΄ ΕΆ = results of layer 4 2.4 K-Fold Cross Validation Cross-Validation also is called rotation estimation is a model validation technique used to assess how the results of statistical analysis will generalize independent data sets. This technique is used to make model predictions and estimate how accurate the predictive model is when it is carried out in practice. K Fold Cross Validation is used to eliminate bias in data, where breaking data into K parts of data sets of the same size. The experiment was carried out several times. In the first experiment, the first parts were done as testing data, and the other parts were done as training data. In the second experiment, the second parts as test data and the other parts as training data, etc. [20]. K fold partition of data set represented in figure 2. D. C. R. Novitasari, Suwanto, M. H. Bisri, and A. H. Asyhar Classification of EEG Signals using Fast Fourier Transform (FFT) and Adaptive Neuro Fuzzy Inference System (ANFIS) 39 Figure 2. K Fold cross-validation of data set For each K trials, one fold is used for testing data and the remaining folds (K-1 fold) for training data, and the average error all of K trials is computed as follows equation 7. [21] 𝐸 = 1 𝐾 βˆ‘ 𝐸𝑖 𝐾 1 (7) where: E = MSE of fold K = number of fold 3. Research Methodology The research process needs to be initiated by conducting a literature study, especially prior research related to the topic, data collection and data processing, program making, and analysis of results. Before data processing using the Adaptive Neuro-Fuzzy Inference System (ANFIS) method, preprocessing needs to be done. The method for this research represented as a flowchart in figure 3. Figure 3. Research Flowchart The feature extraction process is done by changing the time domain from EEG signals to the frequency domain using the FFT method. Each EEG signal that has been in the frequency domain calculated the median value, mean, and standard deviation. These three variables become features and input to the classification process. The classification method uses the ANFIS method, which is a fuzzy inference system that is implemented in adaptive networks. Adaptive Neuro-Fuzzy Inference System (ANFIS) is a combination of the mechanism of fuzzy inference systems in neural network architecture. According to [22] the fuzzy inference system used is the first-order Takagi Sugeno Kang (TSK) model with consideration of simplicity and ease of computing. Optimal (small error)? Start Data Input FFT Filter Result Feature Extraction Extraction Result Classification (ANFIS) Classification Analisys End Yes No Jurnal Matematika MANTIK Vol. 5, No. 1, May 2019, pp. 35-44 40 The classification process using ANFIS has 5 steps, including fuzzification, product, normalization, defuzzification, and output. The fuzzification process is an input mapping into a fuzzy set to get a certain degree of membership from a classic set input transformation. The next process is product and normalization, which is the process of calculating the degree of activation, then calculating the normalized activation power by dividing each result from the second layer by the total number of w. In the fourth step, fuzzy results will be changed to the classic set (crisp), and the calculation in the fifth layer is done to get the value of the coefficient parameter and add up all the inputs from the fourth layer. 4. Result Before being classified, the original signal data as in Figure 4, at the top is the EEG signal data for normal patients, the middle image is an image with epilepsy without seizures (Epilepsy Not Seizure) and in the bottom picture is a signal image of patients suffering from Epilepsy followed by seizures. Figure 4. EEG Signals (Normal-Epilepsy Not Seizure-Epilepsy) The first step is to do preprocessing. In this study, the Fast Fourier Transform (FFT) method is used, for example, visualization of the results of signal filtering using FFT as shown in Figure 5. From Figure 4 and Figure 5, there are significant differences because in figure 5 the original signal is filtered using FFT so the noise of the original signal was removed. D. C. R. Novitasari, Suwanto, M. H. Bisri, and A. H. Asyhar Classification of EEG Signals using Fast Fourier Transform (FFT) and Adaptive Neuro Fuzzy Inference System (ANFIS) 41 Figure 5. Filtering Results of EEG Signals FFT result will be processed to the feature extraction process, this process produces three features data are used to input data on a classification process that is the mean, median, and standard deviation of the signal filtering results of each patient. The function of mean, median, and standard deviation in this study is to take characteristics of patient signal data to simplify the classification process. Some examples of this feature extraction seen in Table 1. Table 1. Extraction Result (Normal-Epilepsy) Median Mean Standard Deviation Class 0.0022 0.3544 2432.2163 Normal 0.4809 0.9299 4270.7733 Normal 0.0025 0.3656 2768.9500 Normal 0.0015 0.3385 2449.7238 Normal 0.0020 0.3601 27028.7744 Epilepsy 0.0020 0.3361 28348.9893 Epilepsy 0.0020 0.3648 20656.6976 Epilepsy 0.0041 0.2082 9421.0647 Epilepsy Jurnal Matematika MANTIK Vol. 5, No. 1, May 2019, pp. 35-44 42 Table 2. Extraction Result (Normal- Non Seizure Epilepsy -Epilepsy) The feature extraction results are the initial variables in the classification process by using Adaptive Neuro-Fuzzy Inference System (ANFIS). After obtaining the extract on each data feature, the results divided into two data, there are training data and testing data. The distribution of training and testing data are using the K-Fold Cross Validation method. Confusion matrix for the classification of two classes (Normal-Epilepsy) and three classes (Normal-Epilepsy Not Seizure-Epilepsy) represented in table 3 and table 4. The results of the level of accuracy, sensitivity, and precision shown in table 5. Table 3. Confusion matrix (Normal-Epilepsy) Class Normal Epilepsy Normal 25 0 Epilepsy 0 25 Table 4. Confusion matrix (Normal- Non Seizure Epilepsy-Epilepsy) Median Mean Standard Deviation Class 0.0022 0.3544 2432.2163 Normal 0.4809 0.9299 4270.7733 Normal 0.0025 0.3656 2768.9500 Normal 0.0023 0.3186 2866.5607 Epilepsy Not Seizure 0.0026 0.3946 2762.9526 Epilepsy Not Seizure 0.0025 0.3219 3309.7655 Epilepsy Not Seizure 0.0020 0.3601 27028.7744 Epilepsy 0.0020 0.3361 28348.9893 Epilepsy 0.0020 0.3648 20656.6976 Epilepsy Actual Classification Result Data Normal Non Seizure Epilepsy Epilepsy Normal 23 2 0 Non-Seizure Epilepsy 4 20 1 Epilepsy 0 1 24 D. C. R. Novitasari, Suwanto, M. H. Bisri, and A. H. Asyhar Classification of EEG Signals using Fast Fourier Transform (FFT) and Adaptive Neuro Fuzzy Inference System (ANFIS) 43 Table 5. Classification Result Classification by using ANFIS method get good result with provide accuracy, sensitivity, and precision value. Accuracy is the level of closeness between the results of classification with the actual value, sensitivity is possibility the results of classification being identificated correctly, and precission is level of correctly between the information requested and the classification results. The accuracy, sensitivity, and precision value for the classification of two classes (Normal-Epilepsy) of 100% and the results of the accuracy of 89.33%, sensitivity of 89.37%, and the precision 89.33% for the three classes (Normal- Epilepsy Not Seizure -Epilepsy). 5. Conclusion Based on the results of analysis and testing, it concluded that the level of accuracy, sensitivity, and precision classification of two classes (Normal-Epilepsy) are 100% and classification with three classes (Normal-Non Seizure Epilepsy-Epilepsy) level of accuracy, sensitivity, and precision of 89.33%, 89.37%, and 89.33%. References [1] N. C. W. Maryanti, "Epilepsi dan Budaya," Buletin Psikologi, vol. 24, no. 1, pp. 22- 31, 2016. [2] W. E. Zulianto, E. C. Djamal and A. Komarudin, "Deteksi Epilepsi dari Sinyal EEG Menggunakan Autoregresive dan Adaptive Backpropagation," Prosiding SNST, 2016. [3] D. C. R. Novitasari, "Klasifikasi Sinyal EEG Menggunakan Metode Fuzzy C-Means Clustering (FCM) dan Adpative Neuro Fuzzy Inference System (ANFIS)," ITS, 2013. [4] D. C. R. Novitasari, "Klasifikasi Sinyal EEG menggunakan Fuzzy C-Means Clusterimg (FCM) dan Adaptive Neighborhood Modified Backpropagation (ANMBP)," Jurnal Matematika Mantik. [5] K. Sameh, P. Kovacs and M. Gabbouj, "Epileptic Seizure Classification of EEG time-series using Rational Discrete Short Time Fourier Transform," IEEE, 2013. [6] B. Pushpa and D. Najumnissa, "Classification of Epileptic Seizure EEG signals using EMD and ANFIS," IEEE, 2014. [7] A. Surtono, T. T. Widodo and M. Tjokronagoro, "Analisis Klasifikasi Sinyal EKG Berbasis Wavelet dan Jaringan Syaraf Tiruan," JNTETI, pp. 60-66, 2012. [8] N. Afifah, A. Rizal and I. Wijayanto, "Klasifikasi Penyakit Batuk Berdasarkan Sinyal Data Suara Menggunakan Ekstraksi Ciri Fast Fourier Transform dan Power Spectral Density dengan Algoritma Jaringan Saraf Tiruan-Propagasi Balik," e- Prociding of Enginering, vol. 2, pp. 2841-2846, 2015. [9] Faradiba, "Pengenalan Pola Sinyal Suara Manusia Menggunakan Metode Back Propagation Neural Network," Jurnal EduMatSains, vol. 2, 20017. Class (Normal-Epilepsy) (Normal- Non-Seizure Epilepsy -Epilepsy) Accuracy 100% 89.33% Sensitivity 100% 89.37% Precision 100% 89.33% Jurnal Matematika MANTIK Vol. 5, No. 1, May 2019, pp. 35-44 44 [10] N. Purwaningsih, "Penerapan Multilayer Perceptron untuk Klasifikasi Jenis Kulit Sapi Tersamak," Jurnal TEKNOIF, vol. 4, 2016. [11] R. D. Nompunu, P. B. Santosa and E. Yudaningtyas, "Klasifikasi Kinerja Pegawai Universitas X dengan pendekatan Neuro-Fuzzy," EECCIS, vol. 12, pp. 47-53, 2018. [12] S. M. B, "Pembuatan Aplikasi Penerima Data EEG 3 Kanal," 2014. [13] B. Samudra, "Support Vector Machine for Epileptic Seizures Detection Based on EEG Signal," 2018. [14] N. B. Aji, "Klasifikasi EEG Epilepsi Menggunakan Singular Spectrum Analysis, Power Spectral Density dan Convolution Neural Network," 2017. [15] I. G. Harsemadi, "Implementasi Fast Fourier Transform pada Ekstraksi Fitur Mood dalam Musik," Prosiding seminar Nasional Multidisiplin Ilmu Universitas Budi Luhur, pp. 121-129, 2017. [16] P. N. Hanggarsari, H. Fitriawan and Y. Yuniati, "Simulasi Sistem Pengacakan Sinyal Suara secara Realtime Berbasis Fast Fourier transform (FFT)," ELECTRICAL Jurnal Rekayasa dan Teknologi Elektro, vol. 6, pp. 192-198, 2012. [17] S. Kinasih, "Prediksi Curah Hujan Menggunakan Adaptive Neuro Fuzzy Inference System (ANFIS)," 2018. [18] D. A. Adyanti, A. H. Asyhar, D. C. R. Novitasari, A. Lubab and M. Hafiyusholeh, "Forecasts Marine Weather On Java Sea Using Hybrid Methods: TS-ANFIS," EECSI, 2017. [19] J.-S. R. Jang, "ANFIS: Adaptive-Network-Based Fuzzy Inference System," IEEE, pp. 665-685, 1993. [20] F. Tempola, M. Muhammad and A. Khairan, "Perbandingan Klasifikasi Antara KNN dan Naive Bayes pada Penentuan Status gunung Berapi dengan K-Fold Cross Validation," Jurnal Teknologi Informasi dan Komunikasi (JTIIK), vol. V, no. 5, pp. 577-584, 2018. [21] R. Anand, V. P. S. Kirar and K. Burse, "K-Fold Cross Validation and Classification Accuracy of PIMA Indian Diabetes Data Set Using Higher Order Neural Network and PCA," International Journal of Soft Computing and Engineering (IJSCE), vol. 2, no. 6, pp. 436-438, 2013. [22] I. Haimi, "Peramalan Beban Listrik Jangka Pendek dengan Menggunakan Metode Adaptive Neuro Fuzzy Inference System (ANFIS)," UIN Sultan Syarif Kasim Riau, Pekanbaru, 2010.