Design of a Respiration Pattern Detecting Device based on Thoracic Motion Tracking with Complementary Filtering

The respiration pattern represents the volume of air in the lungs as a function of time during human respiration process. Abnormal changes in this pattern can be signs of several diseases or conditions. There exit several respiration pattern detection methods. Among them, an easy technique relies on sensing the movements of thoracic and (or) abdominal regions. In this study, a device based on thoracic motion tracking with complementary filtering has been developed to detect the respiration pattern. The device is equipped with a motion sensor placed in a flexible belt housing a three-axis accelerometer and a three-axis gyroscope and a UART-to-USB converter providing computer connectivity. The device is operated by a microcontroller that controls the operation of the motion sensor, applies complementary filtering to the motion data acquired and transfers the results to a personal computer. The device is powered from the computer it is connected to. Experiments with using the device during continues inhaling and exhaling, deep inhaling followed by breath-hold and deep exhaling followed by breath-hold respiration activities in standing, lying and seated postures show that thoracic motion tracking with complementary filtering may provide quite well respiration pattern detections.


Introduction
The human respiratory system is responsible for passing into oxygen from air to blood and removing carbon dioxide from the lungs.While inhalation, diaphragm contracts downwards and forms a vacuum which transmits a clean air into the lungs quickly.During exhalation, diaphragm relaxes and moves on upwards and then deflation occurs in the lungs.Respiration pattern can be obtained from plots of the volume of air in the lungs as a function of time.On such a plot, upward lines denote inhalation process while downward lines indicate exhalation process.Horizontal lines denote automatic pause that may occur as a result of relaxation of respiration muscles.Number of inhalation-exhalation-pause cycles per minute determined from a respiration pattern gives the respiration rate [1].Any abnormal change in this rate may be a sign of several diseases or conditions such as apnea.Inhaled or exhaled volume of air in a single breath measured from a respiration pattern is the tidal volume.Any abnormal change in this volume may also be a sign of several diseases or conditions such as stress [2].There are several techniques proposed to detect respiration pattern indirectly based on the lung sounds, the thoracic and (or) the abdominal region movements during respiration cycle mostly [3].
Lung sounds recorded from the chest using aircoupled electret-condenser microphones or piezoelectric contact sensors have greater intensity during inhalation than during exhalation for a typical respiration cycle [4,5].Multi-channel recordings and recording of the ambient noise by an air-coupled microphone placed near the patient are performed preferably to minimize the noise on the sounds however heart sound interference is still an unaddressed problem [6,7].The technique usually requires a well-performed pre-calibration step and suffers from difficult to implement complex signal processing tasks such as accurate identification of the sound segments, application of autoregressive modelling to the segments and extraction of linear frequency cepstral coefficients [8][9][10].
Respiration motions lead to the movements of thoracic and (or) the abdominal regions that can detected using several techniques.Stain gauge embedded to a chest belt gives response to variation in its length by changing its electrical resistance due to respiration cycle [11].During inhalation, it extends resulting in an increase in resistance while the resistance decreases to its nominal value during exhalation.Although this technique may give good outputs, it suffers from mechanical limitation: user should make an effort in respiration in order to extend the gauge.An advanced type of conventional strain gauge is the mercury-in-rubber strain gauge that has less mechanical limitation on respiration.However, since the gauge houses toxic material, its use is quite restricted requiring careful supervision.In addition to this, stabilization of mercury-in-rubber strain gauge in long term measurements is ineffective due to noise formation [12].Respiratory inductance plethysmography is an alternative to strain gauge based techniques.Here, an alternating current is transmitted through a flexible belt equipped with a circled wire that creates a magnetic field [13,14].
During inhalation, the area of coil increases and during exhalation it decreases resulting in generation of a linear time-varying signal beneficial for monitoring respiration pattern especially in intensive care units [12].However, this technique requires a careful calibration step: Frequency of alternating current should be adjusted to twice as much of the actual respiratory frequency to get appropriate sampling.An easy way in respiration pattern measurement is provided by air filled capsules [15].The pressure of the air in the capsule increases or decreases with respect to respiration movement.This change is sensed by a pressure transducer attached through a flexible tube.Although this technique is quite simple, user may need to make an effort in respiration in order to extend the capsule.
A beneficial technique for respiration pattern detection relies on motion sensing using accelerometers [16,17].An accelerometer placed on a flexible belt rotates during inhalation and exhalation and enables thoracic motion estimations.However, acceleration data can be quite noisy making estimations error prone.Better estimations are achievable by performing Kalman filtering on the data.However, this filtering method suffers from mathematical complexity that leads to long computational time and dedicated hardware requirements [18].An easy-to-perform alternative may be complementary filtering.In this study, a device based on thoracic motion tracking with complementary filtering has been developed to detect the respiration pattern.The details of the device are as explained below.

Material and Method
The physical appearance of the device developed is seen in Figure 1.The device is equipped with a motion sensor placed in a flexible belt and connected to the device via a four-wire silicone flexible cable, and a UART-to-USB converter module connected to the device via a standard five-wire UTP cable.Within the device, there is a microcontroller that operates the device and controls the green status indicating LED. Figure 2 shows the block diagram of the device.

Motion sensor
The motion sensor houses a voltage regulator circuitry and appropriate resistors and capacitors to get six degrees of freedom motion tracking unit MPU6050 (InvenSense Inc., California, USA, [19]) functioning.This unit contains a three-axis accelerometer and a three-axis gyroscope, six sixteen-bit analogue to digital convertor to get digital accelerometer and gyroscope readings, a signal conditioning circuitry and a digital motion processor to handle the digitized data, and a serial interface to perform inter-integrated circuit (I2C) communication with microcontrollers.Its run-time calibration firmware eliminates complex system level integrations delivering optimal performance.Its low power consumption makes it suitable for portable devices (while operating, current drawn by the gyroscope and the accelerometer is only 3.6mA and 500µA, respectively).
Different selectable scale ranges are provided both for the accelerometer and for the gyroscope.In this study, ±2g scale range providing 16384 LSB/g sensitivity for the accelerometer and ±250°/s scale range providing 131 LSB/°/s for the gyroscope have been selected [19].

Microcontroller
The core of the device developed during this study is the microcontroller PIC18F2550 (Microchip Technology, Arizona, USA, [20]).This microcontroller is widely used in biomedical devices due to its low cost, good performance and ease of availability.It is equipped with a 32KB FLASH program memory, 2048 bytes random access data memory.It has forty pins in total but thirty-three of these pins can be programmed for digital input/output use.Two of the digital pins (SDA and SCL) are dedicated to I2C communications and another two (RX and TX) are dedicated to serial universal asynchronous receive/transmit (UART) operations.In the device developed, those pins provide connections to motion tracking and USB-UART converter modules and the microcontroller is run on 48MHz oscillator frequency.

Figure 3. Flowchart of the microcontroller program
During this study, a microcontroller program has been developed using Proton Development Suit with Proton BASIC compiler that manages the operation of the motion tracking module to get accelerometer and gyroscope readings and that performs mathematical calculations on the readings to estimate rotations.Figure 3 shows the flowchart of the program.

Rotation estimation using complementary filtering
Let   ,   and   be the readings of the accelerometer in x, y and z-axis, respectively and  = [      ].Also let   ,   and   be the readings of the gyroscope in x, y and z-axis, respectively and  =       .Considering the sensitivities set during this study, acceleration and angular velocity estimates are obtained by Raw rotation estimates can be directly computed from the acceleration data using Here α is a weighting factor and   is the sampling rate.In this study,  = 0.98 and   =20ms (these values were selected through extensive experimentation).

UART-to-USB converter
The device is equipped with an inexpensive and easy to use PL2303HX USB-UART convertor (Prolific Technology Inc., Taipei, Taiwan, [22]) to provide connectivity between the device and a personal computer.The convertor has five pins, namely GND (Ground), TXD (Transmit Data), RXD (Receive data), +3.3V dc power pin and +5V dc power pin capable of providing 500mA maximum from the USB port of the connected computer.+5V dc power pin and GND pin provide power and ground connection to the device developed.RXD and TXD pins are connected to the dedicated TX and RX pins of the microcontroller in the device to ensure proper data transfers.The schematic of the device developed showing these connections is seen in Figure 4. Once the device developed is connected to a personal computer via its USB-UART convertor, at first, a user interface software with serial communication functionality should be run and setup appropriately to allow data transfers (i.e. the port should be selected by the user with a speed of 9600baud, byte size of 8, no parity, 1 stop bit).In this study, the user interface software is the serial communicator software embedded into Proton Development Suit.Next, the device performs motion measurements and sends the results to the user interface software simultaneously.The values received can be copied and pasted into Microsoft Excel for further analyses.

Results
The device developed was experimented on a healthy male volunteer while he was in standing, lying and seated postures as illustrated in Figure 5.For each posture, motion measurements were captured during three different respiration activities: continues inhaling and exhaling (In-Ex), deep inhaling followed by breath-hold (In-H) and deep exhaling followed by breath-hold (Ex-H).The measurements were performed for fifteen seconds intervals and repeated in twenty different time periods.During all measurements, the same reference positionings for the x, y and z axis were assigned by the motion tracking module.
Rotation estimates by the device were imported into Microsoft Excel and analyzed to determine the best rotation estimate to represent the respiration pattern.The mean and the standard deviation of rotation estimates with respect to each posture position are as presented in Tables 1-3.  ) is found to be the most valuable "feature" in detection of respiration pattern for all postures.Plots for this feature obtained during each respiration activity and posture are presented in Figures 6-8.

Discussion and Conclusion
The device developed is easy to use and quite functional in detection of respiration pattern from thoracic motion.Complementary filtering combines accelerometer readings with gyroscope readings and considers the previous filtered rotation estimates with some weighting therefore provides improved estimates of rotation than calculated directly using the accelerometer data alone.
We are willing to use the developed device to track the continuity of breathing in sleep apnea patients at home.Aiming this, we have some future work to improve the device developed.The motion sensor experiences very limited and ignorable general body movement since the human participant performs only a pre-defined posture and no any physical activities during the measurements.An additional sensor may be required to differentiate general body movement from respiratory movement when the device is intended for daily-use.Movement of chest due to heartbeat may rarely have an undesirable impact on respiration pattern detections by the device.To minimize the interference, a heartbeat detection circuitry can be embedded into the device.The developed device transfers data to personal computer via a five-wire cable that may sometimes lead to user discomfort.Cable-less data transfers can be performed using a wireless technology such as ZigBee that may provide high performance with very low power consumption and efficient connectivity.The developed device transfers data to personal computer via a five-wire cable that may sometimes lead to user discomfort.Cable-less data transfers can be performed using a wireless technology such as ZigBee that may provide high performance with very low power consumption and efficient connectivity.Using any serial communicator software, outputs of the device developed can be easily transferred to a personal computer and can be processed using any electronic spreadsheet software such as Microsoft Excel.However, a dedicated software with a user friendly interface can be developed to facilitate data transfer, data storage and data processing tasks.
On the other hand, we plan to perform some comparison studies.Filtering techniques implementable by our device may be tested for possible improvements in obtaining rotation estimates.Simultaneous air flow measurements can be performed by integrating an airflow sensor to our device to assess the performance of airflow sensing in comparison with motion sensing.

Figure 1 .
Figure 1.Physical appearance of the device

Figure 4 .
Figure 4. Electronic schematic of the device developed

Figure 5 .
Healthy volunteer in different postures: (a) standing, (b) lying down and (c) seated

Figure 6 .
Figure 6.Plots of    during respiration activities in "standing" posture

Figure 7 .
Figure 7. Plots of    during respiration activities in "lying down" posture.

Figure 8 .
Figure 8. Plots of    during respiration activities in "seating" posture

Table 2 .
Rotations estimated for "lying down" posture

Table 3 :
Rotations estimated for "seating" postureTo detect inhalation and exhalation activity illustrating the respiration pattern, the rotation estimate with the highest standard deviation is considered.Bearing this in mind, rotation estimate around z-axis (i.e.