Empirical Investigation of Noise Reduction Filter for a Flow-Based Spirometer Accuracy Improvement

A turbine spirometer with an IR rotary encoder is designed and fabricated for performing Respiratory Function Tests (RFT). The system includes a hardware for gathering breath inspiratory flow rate and a user software which represents analysed data of patients' breath flow and volume parameters in real-time. The purpose of the paper is evaluating the efficiency of three different types of digital noise reduction filters in term of increasing the accuracy of system in calculation of air volume passing through the spirometer turbine by use of data obtained by a flow sensor. Three distinct kinds of flow waves are experimented and the most sufficient filter for corresponding respiratory function tests are reported.


Introduction
Spirometer is an electronic or mechanical device routinely used to perform pulmonary function test to measure the amount and speed of air that a person can inhale or exhale. Pulmonary function tests (PFTS) are invaluable clinical investigations performed with the purpose of diagnosis, monitoring the treatment and guiding decisions regarding further treatment and intervention for the patients with suspected or previously diagnosed respiratory disease. (Ranu et al. 2011) As the most common procedure in performing pulmonary function tests, Spirometry is the process of obtaining parameters relating to lungs and respiratory function by means of measuring flow and/or volume of the exhaled and inhaled air. Inspired and expired lung volumes measured by spirometry are useful for detecting, characterizing and quantifying the severity of lung disease. (Quajer et al. 2011) The medical doctor may use these data for diagnosis, treatment or monitoring therapy process or abnormalities developments for a wide variety of respiratory system related diseases. (Rebuck et al. 1996) The device used in this process is called Spirometer. Spirometer devices are divided into two categories with respect to their measuring method, volume-based and flow-based spirometers. Volume-based spirometer are less expensive and yet easier to calibrate and use, but they are incapable of measuring flow parameters of pulmonary test, such as Peak Expiratory Flow(PEF). (Wanger et al. 2005) Nowadays digital flow-based spirometers are more common due to their precision, portability and the capability of measuring both flow and volume parameters for PFT. There are different types of flow-based spirometers that use various techniques in measuring the respiratory flow such as ultrasonic sensor, hot wire anemometer, venture sensor and turbine. Turbine spirometers are the most common types due to their ease of operation, adequate precision, light weight, cost efficiency and the capability to remove and change parts in contact with breathing gasses of patients to prevent disease transmission. (Rebuck et al. 1996) One of the main challenges in achieving desirable precision of measurements in design of flow-based and in particular turbine spirometers is the process of measuring lung volumes such as residual volume (RV), functional residual capacity (FRC) and total lung capacity (TLC). Estimation of lung volumes using flow rate may lead to huge calculation errors and this might limit flow-based spirometers applicability in clinical practice. (Wanger et al. 2005) In this study a digital turbine spirometer was designed and fabricated and flow sensing was calibrated. With the help of a cylinder with known volume, the device was tested with applying different types of digital noise reduction filters on flow-time curves to investigate how the calculation error of volume can be reduced.

Spirometer Design and Fabrication
Turbine spirometer used in this study main parts are turbine cylinder, processing circuit and user software. Breathing air flows through turbine cylinder causing the propeller to spin. Two pairs of infrared sensors are set on sides of the two-blades propeller of turbine in radial direction and eccentric to center axis of cylinder. Each time the rotating blade intercepts infrared waves of an IR emitter a signal is sent to processing unit. Analog signals of voltage are converted to digital signals in microprocessor. Using those signals and time period between interception both rotational speed and direction are calculated in processing unit.
Processed data of rotational speed, timings and rotational direction are sent to user software which implements a program which uses a conversion curve of rotational speed to air flow and represent the flow-time curve to user.

Volume Approximation
The main challenge in designing and calibrating the flow-based spirometers is the complications in volume calculation using flow rate data. Theoretically the area under a Flow-Time curve represents the volume. ly (1) In practice, the minor errors and unwanted disturbance in measurement of flow or any noise in flow signal might lead to huge miscalculations of total volume and subsequent misdiagnosis in RFT. The final value calculated for passed volume using this method will not be exact but an approximation and its accuracy will determine the quality and reliability of the spirometer.

Noise Reduction Filters
In reducing noise, filters are used to preprocess the data. The term "noise" here is used in a general sense and includes any corruption to the signal that hinders the pattern recognition or state estimation or leads to false artifacts being observed during visualization. Traditionally, smoothing methods used are "moving averages" and "exponential smoothing". (DePold et al. 1999) The moving average is a special case of the finite impulse response (FIR) filter, and the exponential average is a special case of the infinite impulse response (IIR) filter. These filters will be explained later.
However, both the FIR and IIR filters are linear filters and remove noise while blurring the edges in the signal. Substantial research has been conducted in the field of signal processing in order to find appropriate alternatives to linear filters that are robust or resistant in the presence of impulsive noise. Among these works, the approach that has received the most attention is that of "median filters". Median filters are a well-known and helpful class of nonlinear filters. They are useful for removing noise while preserving fine details in the signal (Weighted median filter). (Schroeder et al. 1998) A wide variety of noise reduction filters have been introduced so far and they have been used in myriad signal analysis systems in different fields of industry. The proper and suitable filter for each system should be defined individually in order to meet specific needs of users.
In turbine spirometers signal noises may be caused by different sources such as turbine blade rotational inertia, electrical noise caused by infrared wave reflections, circuit electrical noise, etc. These noises have to be reduced to improve the volume calculation accuracy.
In this paper three introduced noise reduction filtering systems are compared and investigated to find the most accurate one with respect to calculation of passing volume through the spirometer turbine in three modes of flow wave produced by calibration cylinder which is designed to mimic lung function.

FIR
The finite impulse response (FIR) filter can be represented as: pr (2) Where x(k) is the kth input measurement and y(k) is the kth output. N is the filter length and {b(i)} is the sequence of weighting coefficients which define the characteristics of the filter and sum to unity. When all the weights {b(i)} are equal, the FIR filter reduces to the special case of the mean or average filter which is widely used for data smoothing. For example, the 10-point moving average has the form: g. mp , po ng ge Each of the 10 weights for this filter is equal to 1/10. (Litwin et al. 2000) 3.2 IIR The infinite impulse response (IIR) filter can be represented as: po (I ) pr (4) Where x(k) is the kth input measurement and y(k) is the kth output. N and M are the filter lengths, {a(j)}  Vol.10, No.5, 2019 and {b(i)} are the sequences of weighting coefficients, which define the characteristics of the filter.
Exponentially Weighted Moving Average (EWMA) is a popular IIR filter that smooth a measured data point x(k) by exponentially averaging it with all previous measurements y(k−1): ag g pr (5) The parameter is an adjustable smoothing parameter between 0 and 1 with values such as 0.15 and 0.25 being routinely used in applications (Schroeder et al. 1998). The exponential average filter has memory since it retains the entire time history by using the output of the last point. While linear filters are often used to smooth data before fault diagnosis, they can also smooth out important signal features. This problem is alleviated by the use of nonlinear filters such as the median filter. (Yin et al. 1996)

Median
Standard median (SM) filters are a popular and useful class of nonlinear filters. The success of median filters is based on two properties: edge preservation an d noise reduction with robustness against impulsive type noise. Neither property can be achieved by traditional linear filtering without using time-consuming and often ad hoc data manipulation. The median filter having length or window of N=2K + 1 can be represented as: ip ng gt ep (6) Where x(k) and y(k) are the kth sample of the input and output sequences, respectively. To compute the output of a median filter, an odd number of sample values are sorted and the median value is used as the filter output. The median filter thus uses both past and future values of x(k) for predicting the current output point. (Yin et al. 1996)

Test Method
For the device calibration and performing filtration tests a 3-liter cylinder was fabricated on the basis of article "Standardisation of Spirometry" published by American Thoracic Society. Cylinder has the radius and height of 125mm and 250mm, respectively and its piston can be controlled either by hand or an electro-motor for constant or variable speed movement.
Three flow waves were designed to simulate lung function in FEV, constant blow, impulsive blow and pulse blowing to compare the filters effectiveness in calculating more accurate total volume of cylinders. The three used piston movements are shown in Figure 3.
Each respiratory flow sample test was performed 20 times (total of 60 tests). 10 of each experiment were used as training sets in finding optimal constant values of reduction filter equations and 10 more test was performed to be used in final comparison with other filters efficiency. The average volume and error are reported for each sample wave and reduction filter.
Each noise reduction filter introduced in previous sections have a constant value known as window length. Window length is a parameter that shows how many input data points are used to determine each output signal data point. This value has to be optimized for each system depending on data points and frequency range of noises and has to be found experimentally to optimize filter functionality. In this paper values of window length parameter are found separately for each reduction filter and each sample noise. A range of rational values for window length were used in filtering each curve and the optimum value was found with respect to the least error in volume calculation.
An example of optimal value for median noise reduction filter in three types of flow waves are shown in Figure 3.
Finding optimal value for window length parameter was performed for each filter and the results were used to compare filters capabilities at their best performance. Results are shown at Table 1.
As it is shown impulse wave shows better results with less window length. Using too much data points in averaging specially for IIR and FIR filters increases the effect of peak point and high values of curve in calculation of more output data points and so that spreads the error of turbine inertia noise among other data points.

Results and Discussion
After finding the proper values of window length for each NRF and flow wave, their efficiencies in reduction of volume calculation error were compared using second sets of experimental data points.
An example on a raw data set of an impulse flow wave in comparison to proceed data curves is shown in Figure 5.
In case of impulse flow wave, 9 out of 10 experiments result, the raw data showed higher volume than cylinder volume of 3 liters. The main source of the noise causing this error are mechanical and inertial causes by the rotational acceleration of turbine which leads to calculation of higher and longer curve peak than actual flow rate.  Vol.10, No.5, 2019 All three experimented filters have smoothened and reduced the peak value properly, but for IIR and FIR methods although the peak values are damped, their value presence in formulation leads to a faulty increment in other data points value while it is observed that there is no significant error in raw data of flow rate on post-peak segment. Although, the error of turbine inertia is removed, small amounts of error on all other data points lead to a bigger overall error in calculation of total volume.
In contrary, the median filter effect on inertial noise remove not only fades the peak of the curve but also does not take those faulty data points values into account while processing other output data points. This is why the output data points are mostly in coincident with input data points except those regarded as noise.
In this case the median filter results show better reduction in the volume error from average of 12.3% for raw data to average of 6.4% in processed data. These results are shown in Table2. The other two NRFs has no significant effect on volume calculation error.
The same process for finding proper filter for a sinuous wave form was used. Figure 6 shows the result of a sample test for sinuous waveform. As it was seen in impulse wave test results, all three filters are capable of removing faulty peak values. But in this test, there is also another error caused by turbine inertia which happens on downhill segments of curve. On the resting phase of calibration system piston, the turbine does not fully stop because of the blade inertia, which causes another error in volume calculation.
The results of 10 test show that although there are two causes of inertial error in this test, the error values are less than the previous test. This is because the error caused by a sudden flow incensement and peak value error is not as extreme as the one on the impact wave test.
The results which are shown in Table III represent that in comparison to FIR filter that has a negative effect on improving system accuracy, using IIR and Median cause more reduction in volume calculation error and show better overall result.
For the last test the three cases where tested on an almost constant flow. In contrast to two previous tests the piston movement was powered by an electric rotor and a ball-screw system to increase the repeatability of test in comparison to a hand driven piston test.
The result shows that the raw data error for this test is lower in comparison to previous tests, but using noise reduction systems improve the accuracy significantly.
The example of a flow curve on this case and effect of each filter is shown in Figure 7. Volume calculation error for raw data in comparison to filtered data is shown in Table IV.
Three filters show sufficient effect on error reduction for constant flow wave and that's because noisy data points amplitude in this form of flow are not as extreme as other forms of flow, where noises are mostly caused by mechanical and inertial causes and propeller behavior, compared to a constant flow rate where noises are mostly caused by sensing system defects.

Conclusion
The purpose of this paper was comparing three well-known noise reduction filter systems of FIR, IIR and Median to investigate effectiveness of each one for a flow-based turbine spirometer to improve its accuracy on calculation of lung volumes and reliability of performed Pulmonary Function Tests using this device.
Three modes of flow waves produced by an impulsive, a sinus and a constant movement of the cylinder's piston were investigated separately and the effectiveness of each NRF system was compared to find the most suitable filter to be permanently used on spirometer data processing software. Final results represent that Median filtration system do greater error reduction in comparison with FIR and IIR system in various types of flow patterns.