Comparison of signal smoothing techniques for use in ...

2 downloads 1008 Views 402KB Size Report
This way, considering a 5-point smooth width, the formula of the triangular filter is: (2) ... established metrics, the result was used to select a technique and apply it to a signal collected by the. Ozomat (real ..... Isignal.Html. Accessed in: 25/07/12.
Applied Mechanics and Materials Vols. 448-453 (2014) pp 1679-1688 © (2014) Trans Tech Publications, Switzerland doi:10.4028/www.scientific.net/AMM.448-453.1679

Comparison of signal smoothing techniques for use in embedded system for monitoring and determining the quality of biofuels Dalton Cézane Gomes Valadares*, Rute Cardoso Drebes, Elmar Uwe Kurt Melcher*, Sérgio de Brito Espínola*, Joseana Macêdo Fechine Régis de Araújo* * Members of the GASIS Project (GASes Intelligent Sensing)1 Laboratório de Pesquisas em BioEnergia, Arquiteturas Dedicadas e Inteligência Artificial (BELADIA) Unidade Acadêmica de Sistemas e Computação Centro de Engenharia Elétrica e Informática Universidade Federal de Campina Grande Campina Grande, Paraíba, Brazil [email protected] [email protected] elmar@ computacao.ufcg.edu.br [email protected] [email protected]

Abstract This paper presents the study of signal smoothing techniques, in order to select the best for use in a specific type of problem: determination of oxidative stability, by the computational calculation of the induction period. The oxidative stability is one of the major quality parameters of biofuels. According to some established hypotheses and metrics, the results of the study are presented, culminating in the identification of best available techniques related to each metric. This work also contains a case study presenting real use of the smoothing techniques in a signal collected by Ozomat (equipment for determining the oxidative stability). Introduction One of the key metrics used in the evaluation process of the quality of biofuels is the oxidative stability, which expresses the susceptibility to oxidation of the fuel. This metric is defined through the induction period, which is the time measured between the start of the analysis and the sudden increase in the degree of oxidation. A new method was developed for measuring the oxidative stability, in order to obtain faster analysis than those obtained with the main methods used in the industry [3, 16, 17]. This new method, for purposes of this work, will be called Ozomat. The idea of the Ozomat consists in the use of the Ozone as a catalyst for the oxidation reaction of biofuel, thereby accelerating the oxidation process, obtaining a shorter induction period. The Ozomat has a microfluidic measuring cell, which is responsible for reading resistances values for calculating the induction period. Such automatic calculation is defined as the maximum point of the second derivative of the conductivity curve (inverse of the resistance)[4]. Since there is no analytical expression for the conductivity function, the temporal second derivative of this function must be calculated numerically. The use of analytical measurement equipment for small computers in order to obtain real-time data is becoming standard practice in laboratories and industries. Moreover, it is now easier to acquire data quickly in digital format, making use of low cost microcomputers and widely available. File All rights reserved. No part of contents of this paper may be reproduced or transmitted in any form or by any means without the written permission of TTP, www.ttp.net. (ID: 150.165.63.86-21/10/13,14:06:47)

1680

Renewable Energy and Environmental Technology

storage and retrieval/exhibition of information are just some of the advantages of digital data acquisition. In the process of obtaining and transmitting information, it is common that the signal contain some distortion because of the mechanical and electrical means. Among the main causes of the distortion, can be mentioned tracking errors, crosstalk, thermal noise and poor characteristics of pickup (equipment). If the distortion has random statistical characteristics, it is called noise. Due to imperfections in the measurement process (signals acquisition) the signal σ (t) tends to be noisy. This problem also happens in Ozomat, because of some electronic components and due to intrinsic imperfections of the oxidation process. With the noise in the signal conductivity, the numerical derivative is markedly impaired. The noise tends to be "amplified" in the chart of the derivative and this effect is proportional to the derivative order, i.e. to the second derivative the problem is greater [10, 6]. As a result, the read values need a treatment, in order to obtain the second derivative of the generated/estimated curve accurately. With the second derivative of the curve, it is found the global maximum point to determine the induction period. Thus, to measure the oxidative stability it is needed to obtain the global maximum through the second derivative of the generated curve by the read resistances (values). There are a great number of numerical methods that can be used to reduce noise, to increase resolution of overlapping peaks, optimize measuring strategies, diagnose measurement problems and decompose complex signals into their component parts. These techniques can often make it easier some measurements difficult, through of extraction of more information from the available data. Many of them are based on laborious mathematical procedures, which were not practical before the advent of computerized instrumentation. As the computers are faster and have become widely available, the use of the techniques is becoming increasingly common, and therefore, it is important to understand the characteristics and limitations of each signal smoothing technique. The operation of removing the noise, which is often necessary to retrieve information or obtain it accurately, is called filtering (smoothing techniques). It is not so simple to determine how much noise must be separated from the information contained in the signal. There are cases where a gross filter has performance similar to a filter extremely complicated and there are cases in which a good result depends on a well elaborated filter, with some idiosyncrasies [8]. An example of a filtering operation is showed in the Figure 1. This way, to accurately use the signals obtained by the Ozomat, it is needed to pass some smoothing technique at the signal. In this work, four smoothing techniques are compared and a case study is presented, with some signals collected by Ozomat. This problem can be seen as:

Figure 1: The left half of this signal has a noisy peak, while the right half has a peak after the execution of an algorithm for smoothing (filtering) [9].

Applied Mechanics and Materials Vols. 448-453

1681

 Business Problem: deliver filtered datasets of the best way (without significant losses), so that it is possible to calculate the second derivative of the estimated curve.  Technical Problem: study and compare techniques for filtering signals and define the best among them.

As seen, the main aim of this work is determine the better signal smoothing technique, between the four studied, for subsequent processing of an algorithm for determining the induction period, thus identifying the oxidative stability of biofuel. Techniques for Signal Smoothing As seen, thanks to the increasing use of computer technology for data acquisition, various techniques are studied and have been used for filtering of various types of signals. This work has the purpose of compare four techniques: Rectangular, Triangular, Pseudo-Gaussian and SavitzkyGolay. Before starting the study with the four techniques mentioned, some studies were read and they showed different techniques with different approaches to filtering signals. Among the techniques discussed in these papers, some of them are based on Taylor Series, differentiation, differentiation with optimizations, recursive implementations of finite impulse response, differentiators for low frequencies, etc [1, 2, 5, 7, 13 and 14]. The Rectangular or Unweighted Sliding-Average Smooth is the simplest smoothing technique. It works replacing each point of the signal with the average of m adjacent points, being m a positive integer usually called as smooth width. For a 3-point smooth width, the formula is:

(1) In this case, j varies from 2 to n-1 (n is the total number of points in the signal), Sj the jth point in the smoothed signal and Yj the jth point in the original signal. If the noise is "white noise" (evenly distributed over all frequencies) standard deviation sd, then the standard deviation of the noise remaining in the signal after one pass of the rectangular smoothing technique (filter) will be approximately sd divided by the square root of m (m is the smooth width): sd/sqrt(m). The difference between the rectangular and the triangular filters is that the triangular implements a weighted smoothing function, i.e., each point of the original signal has a weight. This way, considering a 5-point smooth width, the formula of the triangular filter is:

(2) The parameters of this formula are similar to that in the rectangular filter (j now varies from 3 to n2). The triangular filter is equivalent to two passes of the rectangular filter with 3-point smooth width. It is more effective than the rectangular in the reduction of high frequency noise. The smooth coefficients are symmetrically balanced around the central point. The Pseudo-Gaussian smoothing technique is equivalent to three passes of the rectangular technique. This technique has coefficients with features similar to a Gaussian distribution.

1682

Renewable Energy and Environmental Technology

The Savitsky-Golay smoothing technique is based on the least-squares fitting of polynomials to segments of the data. Compared to the three other smoothing techniques mentioned (Rectangular, Triangular and Pseudo-Gaussian), the Savitsky-Golay is less effective at reducing noise and its algorithm is more complex. However, it is better at retaining the shape of the original signal, which is a behavior desirable in many applications of chemical analysis. The general formula of the Savitsky-Golay technique is [6, 12]:

(3) The greater the width of the filter (number of signal points used in each iteration), the greater is the noise reduction and the greater is the possibility of signal distortion due to the operation of smoothing (filtering). The more points are used for the size of the filter, the lower is the amplitude of the filtered signal, as shown in Figure 2. If keeping the shape of the peak is more important than optimizing the signal-noise relation, the Savitzky-Golay method has advantages over the other techniques, because this filter has the characteristic of reducing the noise while maintaining the shape and the height of the peak wave [9, 12]. Thanks to this property, some researchers consider Savitzky-Golay attractive to the use in electrocardiogram processing [12].

Figure 2: The red curves are noisy signals. The three green curvers (both in the left and in the right) are three smoothed signals with triangular filter of width (from top to bottom): 7, 25 e 51 points. Experiment to Compare the Techniques This Section presents how this study was performed, mentioning the hypotheses and what was performed to judge them, explaining all the process as well the defined metrics to this analyses. Methodology To perform this work, some clean signals were generated and to these some noisy signals were added. This way, the result after the pass of one smoothing technique could be compared to ideal result, which would be the clean signal. The generated clean signals are: sinusoidal, quadratic, cubic and exponential. With these signals (clean and noisy), the four smoothing techniques mentioned were applied to each case (sinusoidal, quadratic, cubic and exponential). To judge which technique is better, the following metrics were analyzed:  Implementation complexity (number and type of arithmetic operations);  Accuracy in obtaining the results;  Robustness regarding noise interference. After determining which of the four signal smoothing techniques is better, according to the established metrics, the result was used to select a technique and apply it to a signal collected by the Ozomat (real application). The application of the techniques is accomplished through a library

Applied Mechanics and Materials Vols. 448-453

1683

developed for Matlab, called iSignal [11], which has the four filters implemented (objects of this paper). Such library receives a signal as input, calculates the filtered signal and generates the graphic using the smoothing techniques and derivatives up to 4th order. The elaborated hypotheses are presented in the next subsection. To evaluate the four signal smoothing techniques cited in this work, some questions were established to facilitate the analysis of the hypotheses: Q1. Is there difference between the implementation complexity of the filters Rectangular, Triangular, Pseudo-Gaussian and Savitzky-Golay? Q2. Is there difference between the accuracy of the result of applying of the filters rectangular, triangular, and pseudo-Gaussian Savitzky-Golay? Q3. Is there difference between the robustness to noise by applying the filters Rectangular, Triangular, Pseudo-Gaussian and Savitzky-Golay? The independent variables are defined as the following factors:  Technique used (Rectangular, Triangular, Pseudo-Gaussian or Savitzky-Golay);  Dataset with signals for which are applied the techniques (4 signals). The response variables (dependent), according to exposed metrics, are:  Representative number of the amount of arithmetic operations in accordance with their types (e.g. division with weight X and multiplication with weight Y; if a technique have four multiplications and two divisions, the representative value for this metric will be 2X + 4Y);  Root mean squared error (RMSE) at the end of the application of the technique (how inaccurate the result becomes);  Ratio between the filtered signal and noisy signal: signal-noise ratio (SNR). The required instrumentation for this experiment involves: Ozomat, Personal Computer, Matlab Software, iSignal Library and some Biofuels Samples. Hypotheses The hypotheses that helped to perform the experiment and to define what to investigate for determining the better technique were the following (with the respective questions): Q1 - Is there difference between the implementation complexity of the filters Rectangular, Triangular, Pseudo-Gaussian and Savitzky-Golay? H1-0: There is not difference between the implementation complexity of the filters Rectangular, Triangular, Pseudo-Gaussian and Savitzky-Golay; H1-1: There is difference between the implementation complexity of the filters Rectangular, Triangular, Pseudo-Gaussian and Savitzky-Golay. Q2 - Is there difference between the accuracy of the result of applying of the filters rectangular, triangular, and pseudo-Gaussian Savitzky-Golay? H2-0: There is no difference between the accuracy of the result of applying of the filters rectangular, triangular, and pseudo-Gaussian Savitzky-Golay; H2-1: There is difference between the accuracy of the result of applying of the filters rectangular, triangular, and pseudo-Gaussian Savitzky-Golay. Q3 - Is there difference between the robustness to noise by applying the filters Rectangular, Triangular, Pseudo-Gaussian and Savitzky-Golay? H3-0: There is no difference between the robustness to noise by applying the filters Rectangular, Triangular, Pseudo-Gaussian and Savitzky-Golay; H3-1: There is difference between the robustness to noise by applying the filters Rectangular, Triangular, Pseudo-Gaussian and Savitzky-Golay.

1684

Renewable Energy and Environmental Technology

For each question, if the null hypothesis is rejected, i.e. the alternative hypothesis is accepted, the experiment must determine which technique is better according to the respective metrics (Implementation complexity, Accuracy of the results and Robustness regarding noise interference). Results and Short Discussion This Section contains the obtained results according to evaluation of the created hypotheses during the study. The analysis about the hypotheses, according to the three defined metrics, is discussed. The clean signals (Figure 3) were generated through the following functions (‘t’ varying from 0 to 4, step of 0.05, obtaining 81 samples):  Sinusoidal  f1 = sin(2.π.t);  Quadratic  f2 = (t – 1).(t – 2);  Cubic  f3 = t3 – 6t2 + 11t – 6;  Exponential  f4 = e(-t).sin(3.π).

Figure 3: Clean signals. After that, some noises were added for each clean signal and the evaluation of the hypotheses was performed. The noises applied here were of the type Gaussian (they were randomly generated). The noisy signals (clean signals with noise added) are like showed in Figure 4.

Figure 4: Noisy signals. The first question answered (Q1) refers to the implementation complexity of the signal smoothing techniques. To evaluate the implementation complexity of the techniques, the following weights were considered for each arithmetic operation: Sum - 1, Subtraction - 2, Multiplication - 3, Division - 4. In addition, it was considered that the width of the filter (technique) to be used is five points (the width of the filter means the number of points used for a "pass" of it). The formulas of each technique, considered for obtain this metric, were afore mentioned.

Applied Mechanics and Materials Vols. 448-453

1685

Thus, the following resulting values were obtained for each technique:  Rectangular filter: 4 sums (weight 1) + 1 division (weight 4), resulting in the value 8 (4x1 + 1x4 = 8);  Triangular filter: (considered as two passes of the rectangular filter): 4 sums (weight 1) + 3 multiplications (weight 3) + 1 division (weight 4), resulting in the value 17 (4x1 + 3x3 + 1x4 = 17);  Pseudo-Gaussian (considered as three passes of the rectangular filter): to simplify the calculations, it was used an approximation by the result of the rectangular filter, i.e., 3 x 8 (result of the rectangular filter) = 24;  Savitzky-Golay filter: 10 multiplications (weight 3) + 18 sums (weight 1) + 1 division (weight 4) = 49. From the above results, it is concluded that the H1-0 is rejected, because the filters do not have the same implementation complexity. The best filter is the one with lower resulting value, i.e. lower implementation complexity. Thus, for this metric, the best filter is the rectangular filter. To answer the other questions, it must be considered the 4 clean signals plotted in the Figure 3. As already explained, some noise was added to these signals and, after, they were filtered with the 4 smoothing techniques implemented in the iSignal library [11] for Matlab. With the original and filtered signals it was possible to perform a comparison between these techniques, evaluating, of this way, the precision and the robustness of them, and analyzing the hypotheses. The second question answered (Q2) is related to the precision of the techniques. This metric was evaluated by the calculation of the root-mean-squared errors (or root-mean-squared deviation). The root-mean-squared error (RMSE) is used to measure the differences between the predicted values by a model and the really observed values. This kind of measure is an easily interpreted statistic and is directly interpretable in terms of measurement units, being considered a good measure for accuracy/precision. Table 1: RMSE values (evaluation of the smoothing techniques precision). Average of RMSE values according to different noises, signals and techniques Signals/Techniques Rectangular Triangular Pseudo-Gaussian Savitzky-Golay 0.2779948 0.2156021 0.2932493 Sinusoidal 0.1969619 0.7434332 0.7476434 0.7682145 Quadratic 0.2954570 0.9451742 0.9665742 0.9927753 Cubic 0.2993203 0.2838564 0.2205670 0.2954570 Exponential 0.1875844

As the RMSE calculated for each case (noisy signal + smoothing technique, varying noise and smoothing techniques for every signal specified: sinusoidal, quadratic, cubic, exponential) had different values, the hypothesis H2-0 was rejected. Thus, with H2-1 accepted, it was necessary to define the best technique with respect to this metric (precision). In this case, the best technique is the one with the smallest RMSE value. As can be seen in the Table 1, the lowest RMSE values are in bold and underlined. There is not a technique that is best for all situations, i.e., for each kind of signal, one technique excels:  For sinusoidal signals, the best smoothing technique is the Pseudo-Gaussian;  For quadratic signals, the best smoothing technique is the Savitzky-Golay;  For cubic signals, the best smoothing technique is the Savitzky-Golay;  For exponential signals, the best smoothing technique is the Pseudo-Gaussian. The last question of interest (Q3) raised for this study concerns to the robustness to noise of the investigated techniques. The robustness of the techniques was measured according to the SignalNoise Ratio (SNR). The SNR usually is used to compare the level of a desired signal to the level of

1686

Renewable Energy and Environmental Technology

background noise and it is defined as the ratio of signal power to the noise power. Thus, it is a good measure for determining the robustness to noise. Table 2: SNR values (evaluation of the smoothing techniques robustness) Average of SNR values according to different noises, signals and techniques Signals/Techniques Rectangular Triangular Pseudo-Gaussian Savitzky-Golay 0.5724482 0.8507831 0.5057102 Sinusoidal 1.1481832 1.6299388 2.2044140 1.2793203 Quadratic 2.6967976 1.7661211 3.1331958 1.0727437 Cubic 4.5105400 9.1516129 e-32 1.4662886 e-31 7.7801395 e-32 Exponential 1.8284285 e-31

Through the calculated values, it was concluded that the H3-0 is rejected and then is needed to determine which of the four techniques is better (H3-1 accepted), considering the robustness. The Table 2 contains the average of SNR values, for each signal and technique. The higher the SNR value is, the better is the robustness of the technique. Thus, as can be seen in Table 2, the PseudoGaussian technique is the best for this metric. Case study: application of smoothing technique in noisy signal for determination of the oxidative stability After the experiment, evaluating each technique according to defined metrics, a signal collected by the Ozomat was used to verify which technique should show better results for this case, that is a real need. The determination of the oxidative stability, as already mentioned in this paper, is given by calculating the second derivative of the signal, followed by obtaining its maximum point. Therefore, an ideal signal (clean) was used to determine what would be its maximum of the second derivative, and then, techniques of this study were applied in the noisy signal, obtained by the Ozomat, for subsequent determination of the maximum point of the second derivative in this signal. Thus, it was possible to compare the results of the real signal with the ideal result and determine which technique presents better behavior. At the graphs below (Figure 5), the Conductivity (x-axis) is represented in (Ω-m)-1 and the Time (y-axis) is in seconds (s).

Figure 5: Application of the Pseudo-Gaussian smoothing technique in a ‘real’ signal for the calculation of the oxidative stability. The point of abrupt growth of the left signal (clean) was found at about 2185s. After that, the smoothing techniques studied here, together with the second derivative, were applied in the right signal and the technique which found the better result was the Pseudo-Gaussian, as can be seen in the Figure 5. Thus, to this case the oxidative stability determined was also 2185s.

Applied Mechanics and Materials Vols. 448-453

1687

Conclusion and Future Work In this work, a study was made with four signal smoothing techniques, in order to determine the best of them according to some criteria (metrics). It was noticed that, depending on the metrics evaluated, the best result for a particular technique depends on the type of signal in which this technique is applied (e.g. sinusoidal, quadratic, etc.). With these results, it was possible to select the most suitable technique for filtering the data collected by Ozomat, allowing to establish the correct value of the oxidative stability by the computational calculation of the induction period. As a future work, another study can be done investigating other smoothing techniques, different of the four presented here. Some other questions can also be done, stimulating the thought to new metrics. These questions can be like:  What is the technique that allows working with the longest period of sampling without loss of quality of the result?  Which technique requires less capacity of data storage? Thus, this can be performed in the future for a more complete work. Another future work is the implementation of the better technique, identified here, for the embedded system of the Ozomat. REFERENCES [1] AL-ALAOUI, M. A. Novel digital integrator and differentiator. Electronics Letters. Vol. 29, Issue: 4, Pages: 376-378, 1993. [2] AL-ALAOUI, M. A. A Class of Second-Order Integrators and Low-Pass Differentiators. IEEE Transactions On Circuits And Systems I Fundamental Theory And Applications. Vol. 42, Issue: 4, Pages: 220-223, 1995. [3] CUNHA, H. do N., MELCHER, E. U. K., VASCONCELOS NETO, W. R., SILVA, F. L. A. J., NEFF, F. H. “Determinação da estabilidade oxidativa de óleos e combustíveis utilizando oxidação acelerada com Ozônio (Patente PI1002057 - Número de depósito),” U.S. Patent PI1002057 – Number of deposit, 2011. [4] EN14112, “Fat and Oil Derivatives – Fatty Acid Methyl Esters (FAME) – Determination of oxidation stability (accelerated oxidation test).” 2003. [5] KHAN, Ishtiaq Rasool and OHBA, Ryoji. Digital Differentiators Based on Taylor Series. IEICE TRANS. FUNDAMENTALS - vol. E-82-A - nº 12, December, 1999. [6] KITAMURA, K.; HOZUMI, K. “Effect of savitzky—golay smoothing on second-derivative spectra,” Analytica Chimica Acta, vol. 201, pp. 301-304, 1987. [7] KUMAR, B., DUTTA ROY, S. C. Design of Digital Differentiators for low Frequencies. Proceedings of the IEEE. Vol. 76, Issue: 3, Pages: 287-289, 1988. [8] NOHEL, J. A.; SATTINGE, D. H.; ROTA, G. Selected Papers Of Norman Levinson. Birkhäuser, 1st Edition, 1997. [9] O’HAVER, T. Smoothing Algorithms. Available in: Http://Terpconnect.Umd.Edu/~ Toh/Spec Trum/Smoothing.Html#Algorithms. Accessed in: 05/08/2012a. [10] O’HAVER, T. “An Introduction to Signal Processing in Chemical Analysis,” 2012. [Online]. Available: Http://Terpconnect.Umd.Edu/~Toh/Spectrum/Differentiation.Html. Accessed in: 25/07/2012b. [11] O’HAVER, T. iSignal. Available In: Http://Terpconnect.Umd.Edu/~Toh/Spectrum/ Isignal.Html. Accessed in: 25/07/12. [12] SCHAFER, R. W. “What is a Savitzky-Golay Filter?” Vol. 28 (4), P. 111-117 (2011). [13] SUNDER, S., SU, Y., ANTONIOU, A., LU, W. S. Design of digital differentiators satisfying prescribed specifications using optimization techniques. ISCAS, IEEE. CH2692-2/89/0000-1652, 1989. [14] VAINIO, O., RENFORS, M., SARAMALU, T. Recursive implementation of fir differentiators with optimum noise attenuation. IEEE TRANSACTIONS ON INSTRUMENTATION AND MEASUREMENT, VOL. 46, Nº 5, OCTOBER, 1997.

1688

Renewable Energy and Environmental Technology

[15] VALADARES, D. C. G.; VITORINO, B. A. F.; NASCIMENTO NETA, M. L.; BATISTA, E. S.; SANTOS, M. V. D.; NEFF, F. H.; MELCHER, E. U. K.; BARROS, E. N. System for Analysis of the Biodiesel Quality. In: Rio Oil & Gas Expo and Conference 2012 Proceedings. 2012a, Rio de Janeiro, RJ, Brazil. [16] VALADARES, D. C. V, VITORINO, B. A. F., NEFF, F. H., LIMA, A. M. N., MELCHER, E. U. K. Monitoramento da Qualidade de Biocombustíveis e Medição Automática da Estabilidade Oxidativa. In: 16º Congresso Internacional de Automação, Sistemas e Instrumentação, Brazil Automation ISA 2012, 2012b, São Paulo, SP, Brazil. [17] VITORINO, B. A. F., NEFF, F. H., MELCHER, E. U. K., LIMA, A. M. N. Equipamento para Medição Automática da Estabilidade Oxidativa do Biodiesel. In: XIX Congresso Brasileiro de Automática, CBA 2012. Campina Grande, PB, Brazil.