# A Linear Multi-Layer Perceptron for Identifying Harmonic Contents of Biomedical Signals

Thien Minh Nguyen, Patrice Wira

► To cite this version:

Thien Minh Nguyen, Patrice Wira. A Linear Multi-Layer Perceptron for Identifying Harmonic Contents of Biomedical Signals. 9th Artificial Intelligence Applications and Innovations (AIAI), Sep 2013, Paphos, Greece. pp.262-271, 10.1007/978-3-642-41142-7_27. hal-01459618

HAL Id: hal-01459618

https://inria.hal.science/hal-01459618

Submitted on 7 Feb 2017

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_1.png" /></figure>
# A linear Multi-Layer Perceptron for identifying harmonic contents of biomedical signals

Thien Minh Nguyen¹ and Patrice Wira¹

Université de Haute Alsace, Laboratoire MIPS, Mulhouse, France,
{thien-minh.nguyen, patrice.wira}@uha.fr,
WWW home page: http://www.mips.uha.fr/

**Abstract.** A linear Multi Layer Perceptron (MLP) is proposed as a new approach to identify the harmonic content of biomedical signals and to characterize them. This layered neural network uses only linear neurons. Some synthetic sinusoidal terms are used as inputs and represent a priori knowledge. A measured signal serves as a reference, then a supervised learning allows to adapt the weights and to fit its Fourier series. The amplitudes of the fundamental and high-order harmonics can be directly deduced from the combination of the weights. The effectiveness of the approach is evaluated and compared. Results show clearly that the linear MLP is able to identify in real-time the amplitudes of harmonic terms from measured signals such as electrocardiogram records under noisy conditions.

**Keywords:** frequency analysis, harmonics, MLP, linear learning, ECG

## 1 Introduction

Generally, decomposing a complex signal measured through time into simpler parts in the frequency domain (spectrum) facilitate analysis. So, different signal processing techniques have been widely used for estimating harmonic amplitudes, among them Fourier-based transforms like the Fast Fourier Transform (FFT), wavelet transforms or even time-frequency distributions. The analysis of the signal can be viewed from two different standpoints: Time domain or frequency domain. However, they are susceptible to the presence of noise in the distorted signals. Harmonic detection based on Fourier transformations also requires input data for one cycle of the current waveform and requires time for the analysis in next coming cycle.

Artificial Neural Networks (ANNs) offer an alternative way to tackle complex and ill-defined problems [1]. They can learn from examples, are fault tolerant and able to deal with nonlinearities and, once trained, can perform generalization and prediction [2]. However, the design of the neural approach must necessarily be relevant, i.e., must take into account a priori knowledge [3].

This paper presents a new neural approach for harmonics identification. It is based on a linear Multi Layer Perceptron (MLP) whose architecture is able to fit any weighted sums of time-varying signals. The linear MLP is perfectly able
to estimate Fourier series by expressing any periodic signal as a sum of harmonic
terms. The prior knowledge, i.e., the supposed harmonics present in the signal,
allows to design the inputs. Learning consists in finding out optimal weights
according to the difference between the output and the considered signal. The
estimated amplitudes of the harmonic terms are obtained from the weights. This
allows to individually estimate the amplitude of the fundamental and high-order
harmonics in real-time. With its learning capabilities, the neural harmonic esti-
mator is able to handle every type of periodic signal and is suitable under noise
and time-varying conditions. Thus, it can be used to analyze biomedical signals,
even non-stationary signals. This will be illustrated by identifying harmonics of
electrocardiogram (ECG) recordings.

## 2 Context of this Study

An ECG is a recording of the electrical activity of the heart and is used in the investigation of heart diseases. For this, the conventional approach generally consists in detecting the P, Q, R, S and T deflections [4] which can be achieved by digital analyses of slopes, amplitudes, and widths [5]. Other well-known approaches use independent components analysis (for example for fetal electrocardiogram extraction) or time-frequency methods like the S-transform [6].

Our objective is to develop an approach that is general and therefore able
to process various types biomedical and non-stationary signals. Its principle is
illustrated by Fig. 1. Generic and relevant features are first extracted. They are
the harmonic terms and statistical moments and will be used to categorize the
signals in order to help the diagnosis of abnormal phenomenons and diseases.

The following study focuses on the harmonic terms extraction from ECG. A
harmonic term is a sinusoidal component of a periodic wave or quantity having a
frequency that is an integer multiple of the fundamental frequency. It is therefore
a frequency component of the signal. We want to estimate the main frequency
components of biomedical signals, and specially non-stationary signals. Neural
approaches are therefore used. They have been applied successfully for estimating
the harmonic currents of power system [7,8].

<figure><img src="image_2.png" /><figcaption>Fig. 1. General principle for characterizing ECG records</figcaption></figure>
Estimating harmonics can be achieved with an Adaline [9] whose mathematical model directly assumes the signal to be a sum of harmonic components. As a result, the weights of the Adaline represent the coefficients of the terms in the Fourier series [8, 10, 11]. MPL approaches have also been proposed for estimating harmonics. In [12], a MLP is trained off-line with testing patterns generated with different random magnitude and phase angle properties that should represent possible power line distortions as inputs. The outputs are the corresponding magnitude and phase coefficient of the harmonics. This principle has also been applied with Radial Basis Functions (RBF) [13] and feed forward and recurrent networks [14].

In these studies, the neural approaches are not on-line self-adapting. The approach introduced thereafter is simple and compliant with real-time implementations.

# 3 A Linear MLP for Estimating Harmonic Terms

A linear MLP is proposed to fit Fourier series. This neural network takes synthetic sinusoidal signals as its inputs and uses the measured signal as a target output. The harmonics, as Fourier series parameters, are obtained from the weights and the biases at the end of the training process.

## 3.1 Fourier Analysis

According to Fourier, a periodic signal can be estimated by

$$f(k) = a_0 + \sum_{n=1}^{\infty} a_n \cos(n\omega k) + \sum_{n=1}^{\infty} b_n \sin(n\omega k) \quad (1)$$

where $a_0$ is the DC part and $n$ is called the $n$-th harmonic. Without loss of generalization, we only consider sampled signals. The time interval between two successive samples is $T_s = 1/f_s$ with a sampling frequency of $f_s$, $k$ is the time.

The sum of the terms $a_n \cos(n\omega k)$ is the even part and the sum of the terms $b_n \sin(n\omega k)$ is the odd part of the signal. If $T$ (scalar) is the period of the signal, $\omega = 2\pi/T$ is called the fundamental angular frequency. Thus, the term with $n = 1$ represents the fundamental term of the signal and terms with $n > 1$ represents its harmonics. Each harmonic component is defined by $a_n$ and $b_n$. Practically, generated harmonics are superposed to the fundamental term with an additional noise $\eta(k)$. Thus, periodic signals can be approximated by a limited sum (to $n = N$):

$$\hat{f}(k) = a_0 + \sum_{n=1}^{N} a_n \cos(n\omega k) + \sum_{n=1}^{N} b_n \sin(n\omega k) + \eta(k) \quad (2)$$

The objective is to estimate coefficients $a_0$, $a_n$ and $b_n$ and for this we propose a linear MLP.
<figure><img src="image_3.png" /><figcaption>Fig. 2. The linear MLP with 5 neurons in one hidden layer for harmonic estimation</figcaption></figure>

## 3.2 The linear MLP

A linear MLP consists of a feedforward MLP with three layers of neurons. Its inputs are the values of the sine and cosine terms of all harmonic terms to be identified. There is only one output neuron in the output layer. A desired output is used for a supervised learning. This reference is the measured signal whose harmonic content must be estimated. All neurons of the network are with a linear activation function, i.e., identity function. The MLP is therefore linear and nonlinearities are introduced by the input vector. This architecture is shown by Fig. 2.

$\hat{f}(k)$ is a weighted sum of sinusoidal terms and is therefore a linear relationship that can be fitted by a linear MLP taking sine and cosine terms with unit amplitude as its inputs. Thus,

$$ \hat{f}(k) = [a_0 \ b_1 \ a_2 \ b_3 \ ... \ b_N \ a_N]^T \mathbf{x}(k) \quad (3) $$

with

$$ \mathbf{x}(k) = [1 \sin(\omega k) \cos(\omega k) \ ... \ \sin(N\omega k) \cos(N\omega k)]^T \quad (4) $$

can be estimated by a linear MLP with only one hidden layer with $M$ neurons and with one output neuron. The linear MLP takes $R$ inputs, $R = 2N+1$, $N$ is the number of harmonics.

The output of the $i$-th hidden neuron $\hat{y}_i(k)$ ($i = 1, ..., M$) and the output of the network are respectively

$$ \hat{y}_i(k) = w_{i,1} \sin(\omega k) + w_{i,2} \cos(\omega k) + ... + w_{i,R-1} \sin(N\omega k) + w_{i,R} \cos(N\omega k) + b_i, \quad (5) $$
$$ \hat{y}(k) = \sum_{i=1}^{M} w_{o,i} \hat{y}_i(k) + b_o, \qquad (6) $$

with $w_{i,j}$ the weight of i-th hidden neuron connected to the j-th input, $w_{o,i}$ the weight of the output neuron connected to the i-th hidden neuron, $b_i$ the bias of the i-th hidden neuron and $b_o$ the bias of the output neuron.

The output $\hat{y}(k)$ of the linear MLP therefore writes:

$$ \begin{aligned} \hat{y}(k) = & \left( \sum_{i=1}^{M} w_{o,i} w_{i,1} \right) \sin(\omega k) + \left( \sum_{i=1}^{M} w_{o,i} w_{i,2} \right) \cos(\omega k) \\ & + \dots \\ & + \left( \sum_{i=1}^{M} w_{o,i} w_{i,R-1} \right) \sin(N\omega k) + \left( \sum_{i=1}^{M} w_{o,i} w_{i,R} \right) \cos(N\omega k) \\ & + \left( \sum_{i=1}^{M} w_{o,i} b_i \right) + b_o. \end{aligned} \qquad (7) $$

The output of the network can be expressed by (8) with $\mathbf{x}$ from (4) and with $\mathbf{c}_{weight}$ and $\mathbf{c}_{bias}$ introduced thereafter:

$$ \hat{y}(k) = \mathbf{c}_{weight}\mathbf{x}(k) + \mathbf{c}_{bias}. \qquad (8) $$

**Definition 1 (The weight combination).** The weight combination of the linear MLP is a row-vector (with R elements) that is a linear combination of the hidden weights with the output weights which writes:

$$ \mathbf{c}_{weight} = [c_{weight(1)} \dots c_{weight(R)}] = \mathbf{w}_{o}^{T} \cdot \mathbf{W}_{hidden} \qquad (9) $$

where $\mathbf{w}_o$ is the weight vector of the output neuron (with M elements) and $\mathbf{W}_{hidden}$ is a $M \times R$ weight matrix of all neurons of the hidden layer.

**Definition 2 (The bias combination).** The bias combination of the linear MLP, $\mathbf{c}_{bias}$, is a linear combination of all biases of hidden neurons with the weights of output neuron which writes:

$$ \mathbf{c}_{bias} = \mathbf{w}_{o}^{T} \cdot \mathbf{b}_{hidden} + b_o \qquad (10) $$

where $\mathbf{b}_{hidden} = [b_1 \dots b_M]^T$ is the bias vector of the hidden layer.

In order to update the weights, the output $\hat{y}(k)$ of the linear MLP is compared to the measured signal $y(k)$. After learning [1, 2], the weights $\mathbf{c}_{weight}$ and bias $\mathbf{c}_{bias}$ converge to their optimal values, respectively $\mathbf{c}_{weight}^*$ and $\mathbf{c}_{bias}^*$. Due to the linear characteristic of the expression, $\mathbf{c}_{weight}^*$ converges to:

$$ \mathbf{c}_{weight}^* \rightarrow [a_0 \ b_1 \ a_2 \ b_2 \dots b_N \ a_N]^T. \qquad (11) $$

The signal $y(k) = s(k)$ is thus estimated by the linear MLP with optimal values of $\mathbf{c}_{weight}^*$ and $\mathbf{c}_{bias}^*$. Furthermore, the amplitudes of the harmonic terms are obtained from the weight combination (11). After convergence, the coefficients come from the appropriate element of $\mathbf{c}_{weight}^*$, i.e., $a_0 = c_{weight(1)}^* + c_{bias}^*$ and the $a_n$ and $b_n$ from $c_{weight(j)}^*$ for $1 < j < R$:

$$ c_{weight(j)}^* = \sum_{i=1}^{M} (w_{o,i}^* \cdot w_{i,j}^*). \qquad (12) $$
Linear activation functions have been used for the neurons of the MLP so that the mathematical expression of the network's output looks like a sum of harmonic terms if sinusoidal terms have been provided as the inputs at the same time. Indeed, the output of the linear MLP has therefore the same expression than a Fourier series. As a consequence, the neural weights of the MLP have a physical representation: Combined according to the two previous definitions, they correspond to the amplitudes of the harmonic components.

# 4 Results in Estimating Harmonics of Biomedical Signals

The effectiveness of the linear MLP is illustrated in estimating the frequency content of ECG signals from the MIT-BIH Arrhythmia database [15]. A linear MLP with initial random weights is chosen. The fundamental frequency of the signal is on-line extracted from the ECG signal with a zero-crossing technique based on the derivative of the signal. Results are presented by Fig. 3 a). In this study, tracking the frequency is also used to detect abnormal heart activities. If the estimated frequency is within a specific and adaptive range, it means that the heard activity is normal. This range is represented on Fig. 3 b) by a red area. It is centered on the mean value of the estimated fundamental frequency. If the estimated frequency is not included in the range (corresponding to the orange squares on Fig. 3 b)), then the fundamental frequency is not updated and data will not be used for the learning of the linear MLP.

Based on the estimated main frequency, sinusoidal signals are generated to synthesize the input vector $\mathbf{x}_{1-20}$ to take into account harmonics of ranks 1 to 20 at each sampled time $k$. The desired output of the network is the digital ECG with a sampling period $T_s = 2.8$ ms. The Levenberg-Marquardt algorithm [2] with a learning rate of 0.7 is used to train the network and allows to compute the values of the coefficients $a_0, a_n$ and $b_n$ of (11). The amplitudes of the harmonic terms are obtained from the weights after convergence.

Results over three periods of time for the record 104 are shown on Fig. 4 with 3 hidden neurons and $\mathbf{x}_{1-20}$ for the input. The estimated signal is represented in Fig. 4 a) and its frequency content on Fig. 4 b). This figure provides comparisons to an Adaline (with the same input) and FFT calculated over the range 0-50 Hz. Harmonics obtained by the neural approaches are multiples of the fundamental frequency $f_o = 1.2107$ Hz while FFT calculates all frequencies directly. It can be seen that the estimation of the linear MLP is very close to the one obtained by the FFT.

The MSE (Mean Square Error) of the estimation is used as a measure of overall performance. The resulting MSE is less than $1.6 \ 10^{-3}$ with the linear MLP with 3 hidden neurons. The MSE represents $1.4 \ 10^{-3}$ with the FFT and $10.2 \ 10^{-3}$ with the Adaline. The estimated coefficients obtained with the linear MLP therefore perfectly represent the harmonic content of the ECG. Results are similar for other signals from the database. Additional results with an input vector $\mathbf{x}_{1-40}$ that takes into account harmonics of ranks 1 to 40 and with more hidden neurons are presented in Tab. 1. The linear MLP approach is the best
<figure><img src="image_4.png" /><figcaption>Fig. 3. On-line fundamental frequency tracking of an ECG.</figcaption></figure>
<figure><img src="image_5.png" /><figcaption>Fig. 4. Performances of a linear MLP with 3 hidden neurons, an Adaline and the FFT in identifying harmonics of an ECG.</figcaption></figure>

compromise in terms of performance and computational costs evaluated by the number of weights. The computing time required by a linear MLP with 3 hidden neurons is less than for the FFT.

The robustness against noise has been evaluated by adding noise to the signal. Even with a signal-to-noise ratio up to 10 dB, the harmonic content of the ECG is estimated by a linear MLP with 3 hidden neurons with a MSE less than 2 $10^{-3}$ compared to $4 \ 10^{-3}$ for the FFT and to $8 \ 10^{-3}$ for the Adaline.

The linear MLP has been applied to the other records of the MIT-BIH database for training and validation. The MSE calculated after the initial phase of learning is in all cases less than $2.5 \ 10^{-3}$ with 3 hidden neurons.

The linear MLP is a very generic approach that performs efficient frequency feature extraction even under noisy conditions. One byproduct of this approach is that it is capable to generically handle various types of signals. The benefits of using a hidden layer, i.e., using a linear MLP, is that it allows more degrees of freedom than a Adaline. For an Adaline, the degrees of freedom represent the amplitudes of the harmonics. The weight adaption has a direct influence on their values. The Adaline is therefore more sensitive to outliers and noise. On the other hand, with more neurons, the amplitudes come from a combination
<table><caption>**Table 1.** Performance comparison between the linear MLP, Adaline and conventional FFT in estimating the harmonic content of an ECG</caption><thead><tr><th>Harmonic estimator</th><th>Input vector</th><th>Nb of neurons</th><th>Nb of weights</th><th>MSE</th></tr></thead><tbody><tr><td>FFT</td><td>0 to 50 Hz</td><td>-</td><td>-</td><td>0.0014</td></tr><tr><td>linear MLP</td><td>x<sub>1-20</sub></td><td>3+1</td><td>127</td><td>0.0016</td></tr><tr><td>linear MLP</td><td>x<sub>1-40</sub></td><td>3+1</td><td>247</td><td>0.0016</td></tr><tr><td>linear MLP</td><td>x<sub>1-20</sub></td><td>6+1</td><td>253</td><td>0.0016</td></tr><tr><td>linear MLP</td><td>x<sub>1-40</sub></td><td>6+1</td><td>493</td><td>0.0016</td></tr><tr><td>Adaline</td><td>x<sub>1-20</sub></td><td>1</td><td>41</td><td>0.0102</td></tr><tr><td>Adaline</td><td>x<sub>1-40</sub></td><td>1</td><td>81</td><td>0.0105</td></tr></tbody></table>

of weights and are not the weights values. The estimation error is thus shared out over several neurons by the learning algorithm. This explains why the linear MLP works better than the Adaline in this particular application where signals are noisy and non-stationary.

## 5 Conclusion

This paper presents a linear Multi Layer Perceptron for estimating the frequency content of signals. Generated sinusoidal signals are taken for the inputs and a measured signal is used as a reference that is compared to its own output. The linear MLP uses only neurons with linear activation functions. This allows the neural structure to express the signal as a sum of harmonic terms, i.e., as a Fourier series. The learning algorithm determines the optimal values of the weights. Due to the architecture of the MLP, the amplitudes of the harmonics can be written as a combination of the weights after learning. The estimation of the frequency content is illustrated on ECG signals. Results show that the linear MLP is both efficient and accurate in characterizing sensory signals at a given time by frequency features. Furthermore, the linear MLP is able to adapt itself and to compensate for noisy conditions. With its simplicity and facility of implementation, it consists of a first step in order to handle various biomedical signals subject to diseases and abnormal rhythms.

## References

1. Haykin, S.: Neural Networks: A Comprehensive Foundation. 2nd edn. Prentice Hall (1999)

2. Bishop, C.M.: Neural Networks for Pattern Recognition. Oxford (1995)

3. Haykin, S., Widrow, B.: Least-Mean-Square Adaptive Filters. Wiley-Interscience (2003)

4. Rangayyan, R.: Biomedical Signal Analysis: A Case-Study Approach. Wiley-IEEE Press (2002)

5. Pan, J., Tompkins, W.: A real-time qrs detection algorithm. IEEE Transactions on Biomedical Engineering BME-32(3) (1985) 230-236
6. Moukadem, A., Dieterlen, A., Hueber, N., Brandt, C.: A robust heart sounds segmentation module based on s-transform. Biomedical Signal Processing and Control (2013)

7. Ould Abdeslam, D., Wira, P., Mercklé, J., Flieller, D., Chapuis, Y.A.: A unified artificial neural network architecture for active power filters. IEEE Trans. on Industrial Electronics 54(1) (2007) 61–76

8. Wira, P., Ould Abdeslam, D., Mercklé, J.: Learning and adaptive techniques for harmonics compensation in power supply networks. In: 14th IEEE Mediterranean Electrotechnical Conference, Ajaccio, France (2008) 719–725

9. Dash, P., Swain, D., Liew, A., Rahman, S.: An adaptive linear combiner for on-line tracking of power system harmonics. IEEE Trans. on Power Systems 11(4) (1996) 1730–1735

10. Vázquez, J.R., Salmerón, P., Alcantara, F.: Neural networks application to control an active power filter. In: 9th European Conference on Power Electronics and Applications, Graz, Austria (2001)

11. Wira, P., Nguyen, T.M.: Adaptive linear learning for on-line harmonic identification: An overview with study cases. In: International Joint Conference on Neural Networks (IJCNN 2013). (2013)

12. Lin, H.C.: Intelligent neural network based fast power system harmonic detection. IEEE Trans. on Industrial Electronics 54(1) (2007) 43–52

13. Chang, G., Chen, C.I., Teng, Y.F.: Radial-basis-function neural network for harmonic detection. IEEE Trans. on Industrial Electronics 57(6) (2010) 2171–2179

14. Temurtas, F., Gunturkun, R., Yumusak, N., Temurtas, H.: Harmonic detection using feed forward and recurrent neural networks for active filters. Electric Power Systems Research 72(1) (2004) 33–40

15. Moody, G.B., Mark, R.G.: A database to support development and evaluation of intelligent intensive care monitoring. Computers in Cardiology (1996) 657–660