Automatic respiratory phase detection for functional electrical stimulation synchronization

Introduction: People with cervical or high thoracic spinal cord injury usually have respiratory muscle weakness. When transcutaneous functional electrical stimulation (TFES) synchronized with the patient’s natural breathing is applied to respiratory muscles, their strength and resistance are increased. In this work, we propose a novel method to perform an automatic synchronization, composed of a signal acquisition system and an algorithm that recognizes both respiratory cycle phases during quiet breathing. Methods: The respiratory signal acquisition unit consists of a load cell attached to an elastic belt. The algorithm is based on statistical evaluation and linear approximation for detecting the beginning of both inhalation and exhalation phases. Ten volunteers remained steady, breathing quietly for one minute for signal acquisition. Results: The system’s automatic detection of inspiratory events reached 87.5% of true positives, 6.7% of false negatives and 5.8% of false positives. Both hit and error ratios obtained in the detection of expiratory events reached 94.3% true positives, 4.9% false positives and 0.8% false negatives. Conclusion: The developed algorithm can identify the respiratory phases properly and it can be used in future synchronized TFES applications whether the patient remains in a quasi-static position during treatment.


Introduction
Spinal cord injury (SCI) is a traumatic event that changes abruptly and radically a person's life.Trauma can happen in different situations such as vehicle accidents, gunshot wounds and falls, and it affects individual psychosocial and physical aspects (National..., 2015).Furthermore, there are many complications in this scenario, mainly in the respiratory system, that are common in people with cervical SCI and are the main causes of death (Gollee et al., 2007;Linder, 1993;National..., 2015).
SCI brings consequences to the respiratory system.Some of the main complications are pneumonia, atelectasis and respiratory failure (Cheng et al., 2006;Wong et al., 2012).Annually, the number of people who suffer with SCI is between 250,000 and 500,000 (Bickenbach et al., 2013).In 1950, the ratio of death due to respiratory failure in people with acute traumatic cervical SCI was 100% (Linder, 1993).Fortunately, this number has decreased.Between 1973 and2004, it occurred a 40% decline in the number of deaths (Bickenbach et al., 2013), but the problem has not been solved yet.According to National Spinal Cord Injury Statistical Center (USA), 5.8% of paraplegics and 20.5% of quadriplegics need mechanical ventilation assistance at the time of admission to rehab.At one year post-injury, these numbers reduce to 0.2% and 3.5%, respectively (National..., 2015).
Statistics indicate that some of these people may suffer with respiratory problems for a long time.One cause is the loss of muscle control below the injury level, which leads to muscle weakness (Wong et al., 2012).The spinal cord consists of 31 neurologic segments: 8 cervical, 12 thoracic, 5 lumbar, 5 sacral and 1 coccygeal.Phrenic motor neurons that provide innervation to the diaphragm are located at C3, C4 and C5 segments, and the abdominal muscle neurons lie in T7-T12 levels (Siegel and Sapru, 2011).Therefore, depending on the neurologic lesion level, the diaphragm (the main inspiratory muscle) and the abdominal muscles (which have an important participation in forced expiration) can be impaired.Thus, the maintenance of adequate oxygen levels and the ability to withdraw airway secretions through coughing are affected, allowing the occurrence of several diseases (Gollee et al., 2007;Wong et al., 2012).
Health professionals carry out maneuvers to improve the quality of life of people with SCI.As an example, secretions can be withdrawn from the airways by means of coughing assisted by a professional who forces a quick expiration pressuring the abdomen to expel mucus (Spivak et al., 2007), and also with the help of medicines like mucolytic (McCaughey et al., 2016).The lack of oxygen can be supplied with the support of a positive pressure device (Linder, 1993), among other techniques.The results obtained with these maneuvers can be improved with transcutaneous functional electrical stimulation (TFES) applied to totally or partially paralyzed respiratory muscles: diaphragm and abdomen (Gollee et al., 2007;Jorge, 2009;McCaughey et al., 2016).
TFES is a rehabilitation technique that has been used for many years to treat respiratory problems as respiratory failure and weaning (Ogurtsov et al., 1977).It is intended to increase muscular strength and endurance, thus improving breathing as a whole (Gollee et al., 2008).For individuals who have spontaneous respiration, TFES must be synchronized with his/her breathing for better application (Gollee et al., 2008;Santos, 2009).
The correct synchronization of TFES and respiratory cycling requires that diaphragmatic stimulation be applied in the beginning of air inhalation (Jorge, 2009), whereas stimulation of the abdominal muscles must be yielded in the beginning of exhalation phase (Gollee et al., 2007).That is the dynamics of synchronized TFES.
Although synchronized TFES has been used successfully, few scientific studies have been conducted in this area.In the next topic, we describe research projects on synchronized TFES applied to respiratory muscles, focusing on their synchronization algorithm.

Literature review and challenges
Since the respiration principle is based on gas exchange, the initial attempts to detect the respiratory events involved monitoring air flow.There are applications that used air flow sensors mounted on mouthpieces and nose clips to acquire respiratory signals (Gollee et al., 2007;Sorli et al., 1996).They used different algorithms that can extract features of interest from airflow signals and help determine the exact moment to apply synchronized TFES.One approach is to identify the triggering threshold of stimulation as a percent of minimum and/or maximum airflow values (Sorli et al., 1996).Another approach determines the onset of exhalation calculating the cross-correlation between the sensor signal and a predefined reference respiratory signal (Gollee et al., 2007).This combination helps to identify other patterns such as speaking to avoid the application of stimulation at these moments.
The stimulated muscle group has also changed.One focused on diaphragm stimulation (Nohama et al., 2012) whereas the other focused on the stimulation of abdominal muscles (Gollee et al., 2007), respectively, synchronizing inspiration and expiration phases.The former assisted air intake and the latter assisted coughing.
A different approach is to connect a temperature sensor with a face mask in order to synchronize TFES with the inhalation phase (Nohama et al., 2012).The algorithm determined the triggering threshold, both respiratory phases and timing to deliver synchronized TFES.The electrical stimulator was triggered during the inhalation phases because there was only one stimulation channel available.Also, the sensor time constant needs to be as small as possible to be able to be used with this algorithm.
Although effective solutions for TFES synchronization, using flow sensors and masks in the oral region hampers other activities turning its use impractical in normal conditions (Gollee et al., 2007).Masks are not comfortable and may cause claustrophobia and anxiety (Holanda et al., 2009).Some systems need to monitor a predefined number of respiratory cycles before getting maximum and minimum amplitude values and this task may be performed many times.If a patient's breathing pattern varies it can compromise system accuracy.The features can also change between different subjects.
Belt sensors were tried to avoid the limitations of face masks.TFES was synchronized with the diaphragm activity using a belt that had a fiber optic Bragg grating sensor (Wehrle et al., 2001) in patients with diaphragmatic impairment (Nohama et al., 2002).However, the fiber optic was fragile and broke many times being unsuitable for use in real circumstances.Also, two belts with embedded piezoelectric sensors were applied to generate respiratory signals that were classified, between quiet breathing and cough, in real time with an algorithm based on Support Vector Machines (SVMs), but the system does not synchronize diaphragmatic TFES (McCaughey et al., 2014).Yahya and Faezipour (2014) used a microphone for the detection of breathing phases.They could classify respiratory phases into inhalations and exhalations with a SVM, but this classification was not in real time, and the participants had to remain in a special noise-free room.
Other approach for respiratory signal phase detection is the use of thermal imaging analysis of respiratory activity (Deepika et al., 2016).This method requires a special climate room and thermal imaging camera, which is usually expensive, therefore impractical for the purpose of TFES synchronization.Another technique that requires using cameras is the respiratory motion tracking using Microsoft Kinect camera by Ernst and Saß (2015).They presented the possibility of using special marked shirts to track the respiratory motion around the chest in real time, but the system needs improvements and it is not clear whether it could be used for synchronized TFES.
In order to solve the aforementioned issues, we propose a method to identify both respiratory phases during quiet breathing.The goal of this study is to develop a non-obstructive sensor module and an algorithm able to automatically detect both inspiratory and expiratory phases during quiet breathing for a dual synchronization TFES system.This module is a part of a complete system under development for stimulating both respiratory muscles (diaphragm and abdomen), in order to contribute to a more efficient respiratory treatment.

Methods
The synchronized TFES system for respiratory rehabilitation proposed in this study should identify quiet breathing and send information to trigger both diaphragmatic TFES and abdominal TFES.
The system is composed of: (1) source of respiratory signals represented by a patient, (2) one respiratory sensor and (3) an algorithm for the detection of respiratory phases and events that will serve to trigger (4) the electrical stimulator channels.These modules are indicated in Figure 1.

Respiratory source (1)
Anyone who had suffered SCI and diaphragmatic and/or abdominal muscle weakness with no contraindications to undergo electrical stimulation (such as cardiac pacemaking or phrenic nerve lesion) may be a source of respiratory signals.

Respiratory sensor (2)
A non-invasive sensor is responsible for detecting the respiratory phases.The literature indicates that accelerometers (Drugman et al., 2007), air flow sensors (Gollee et al., 2007), etc., were already used as respiratory sensors.In this study, a strain-gage based load cell attached to a belt was used for the detection of both respiratory phases.
Sensors usually need conditioning and acquisition circuits.This study used INA126 instrumentation amplifier.The respiratory signal passband comprises the range 0.2-0.3Hz (12 to 20 rpm -respirations per minute).Therefore, active 5 th order Butterworth low-pass filter with cutoff frequency set to 4 Hz was implemented at the input circuit.The conditioned signal was then sent to a Renesas© RPBRX62N board to be processed by the synchronization software.This board contains the microcontroller RX62N which has up to 512 KB flash memory and 96 KB RAM, 10-bit analog to digital converter (A/D), 12-bit digital to analog converter (D/A), I/O pins, timers, and all circuitry required to build this project in a small unit (Renesas..., 2015).The sampling frequency was set to 1 kHz.
The operation principle of the sensor is the variation of the traction force exerted by the patient's rib cage on the load cell extremities (positioned on the last ribs) during the respiratory movement.When patients breathe, the load cell outstretches accordingly producing oscillating waveform signals that rise during inhalation phases and fall during exhalation phases, as illustrated in Figure 2.

Respiratory pattern identification system (3)
This module is responsible for detecting the current respiratory phase in real time and without training.An algorithm applies linear approximation calculus to short segments of signal determining their slopes.Figure 2 illustrates a respiratory signal and two examples of segments formed by a set of samples that can be fitted to straight line equations using the linear least squares method.The acquisition system feeds every consecutive chunk of 20 samples (corresponding to 20ms) into an array.The array size was defined according to the following experiment: starting with a window size of 5 samples, the response of the algorithm to one controlled respiratory cycle was recorded; the generated false positives and the respiratory cycle frequency were recorded; the window size was increased by 5 samples and the experiment was repeated until the algorithm generated only true positives.Figure 3 shows the curve for the different window sizes versus false positives.The 20 samples window size was the chosen one.
Each i th sample represents time value X i , and its corresponding amplitude value, Y i , so one can perform a linear regression.The β coefficient (Equation 1) indicates line inclination and direction.The linear correlation r coefficient (Equation 2) provides an indication whether vector samples may be assumed as a straight line.
The n value corresponds to the number of samples of the segment analyzed, which in this case is 20.
For each segment, the algorithm continuously analyzes β and r coefficients and verifies whether the signal is rising or falling, corresponding to inhalation or exhalation, as shown in Figure 4.The system throws a flag every time there is a valid phase shift.Only the segments that have β and r greater than a predefined value for inhalation or exhalation can be flagged.Throwing a valid flag immediately triggers the TFES application.In summary, the algorithm has the following behavior: 1. Every 20ms a set of 20 samples is buffered (1 kHz sampling frequency).These values are inserted into an array, and β and r coefficients are calculated; 2. If r ≤ -0.7 and β ≤ -0.5 and the previously detected event was an inhalation, then an exhalation phase is flagged.Previous event is considered to ensure that signalization happens only once; 3.If r ≥ +0.7 and β ≥ +0.5 and the previously detected event was an exhalation, then an inhalation phase is flagged; 4. If none of the previous conditions are fully satisfied, the system does not indicate any event.The algorithm in Figure 4 controls the synchronization module which is responsible for delivering electrical stimuli.When a patient begins inhaling, the electrical stimuli must be yielded on the diaphragm, and the abdominal muscles have to be stimulated in the beginning of the exhalation phase, as illustrated in Figure 5.

Electrical stimulator (4)
This module contains electronic circuits responsible for applying electrical current to patients through transcutaneous electrodes.There are two TFES channels, one for diaphragmatic and the other for abdominal stimulation.

In vivo tests
As this article focuses on respiratory signal acquisition, sensor operation and on synchronization algorithm, in vivo tests did not involve the application of electrical stimulation.The experimental protocol was approved by the Ethics Committee on Research in Humans Board of the Federal University of Technology, Paraná, Brazil (n.871679).All volunteers gave their informed consent prior to their inclusion in the study.
The process of recruiting volunteers utilized the following inclusion criteria: males or females with stable health condition, and 20-60 years old.The exclusion criteria involved the following: respiratory and/or postural problems, pregnancy, and dermatological problems in the abdominal region (at sensor belt site).Ten volunteers participated in this study.Age, weight, height, thoraco-abdominal circumference and body mass index (BMI) of participants are indicated in Table 1.
The load cell was placed on the abdomen, on the last rib region, and the belt was fastened.The volunteer was then instructed to lie down on a stretcher in a comfortable position and allowed to relax for 1 min.The volunteer was instructed to breathe quietly for 1 min.Therefore, an expert physiotherapist pressed a pushbutton at the beginning of each inhalation and exhalation phases as perceived by her visual observation of the expansion and relaxation of the rib cage.Respiratory signals and system generated flag signals were acquired and saved for later analysis.Inhalation and exhalation flags were compared with the reference signal produced by the physiotherapist.The true positives, false positives and false negatives of each respiratory event were counted.

Results
Figure 6 shows a superposition of the strain gage-based sensor signal (yellow -filtered respiratory signal), system generated flag signals (green -inspiratory phase; blue -expiratory phase), and the signal produced by the physiotherapist (pink -respiratory phases).

Discussion
The synchronization algorithm implemented in our system does not require the determination of minimum or maximum points, as observed in Nohama et al. (2012) and Sorli et al. (1996).There is no need for previous training and the linear approximation is calculated simultaneously with signal acquisition.Changes in amplitude do not interfere with respiratory phase identification.Adjustments in the parameters of linear correlation and angular coefficients change the sensitivity for the detection of inspiratory and expiratory events.The values of these parameters used in this study were determined empirically during in vivo tests.
In a preliminary analysis, signaling errors were identified due to physiotherapist misinterpretations while identifying the onsets of inspiratory and expiratory phases, as well as volunteer's body movements produced noise that was interpreted by the system as respiratory events.These facts can partially explain the hit rate differences between the inspiratory and expiratory events.Despise this, Santos (2009) compared two types of diaphragmatic TFES: (i) synchronized by a physiotherapist, and (ii) synchronized by a microcontroller system with a temperature sensor.Regarding blood oxygenation, and the breathing process improvement, the latter performed better (13.1% increase) than the former (0.7% increase).
Some studies wait a fixed time (1.5s) between subsequent detections to avoid incorrect stimuli triggering (Sorli et al., 1996).The drawback is the extra delay, compromising the detection of the next phase depending on the respiratory rate.This does not happen with the developed algorithm since a small 20 samples window favors the fast processing and can cope with different respiratory frequencies.Although our work did not involve adventitious events, these may complicate the scenario when using fixed stimulation rate.All in all, their system increased the average value of tidal volume about 65%, and average ventilation about 70% during expiration.However, greater number of samples implies less accuracy.The buffer size of 20 samples was chosen empirically for presenting the best trade off obtained.McCaughey et al. (2014) developed a Support Vector Machine based algorithm for real-time classification of respiratory activity, and synchronization of abdominal TFES at the start of exhalation during quiet breathing and cough, using the signal of two piezoelectric belts.They had to construct different Support Vector Machines for each participant, differently of the work we presented on this paper in which the same algorithm can be used for all participants.Another difference is the number of sensors used, McCaughey et al. (2014) used two belts for respiratory activity acquisition.With their method they achieved 96.1% of detection accuracy during quiet breathing, for 10 participants.In the work presented in this paper the inspiratory and expiratory events detection accuracy was, respectively, 87.5% and 94.3% for 10 volunteers.
Generally, due to sensor limitations, sensing the alterations in the thoraco-abdominal volume requires that patients remain still or almost still.In this condition, without movement artifacts, the synchronization module can satisfactorily detect the onset of inspiratory and expiratory phases.
In conclusion, the sensing method that analyzes the thoraco-abdominal volume variation by means of strain gauges encapsulated in a load cell can be used in the acquisition of respiratory signals with patients remaining in a quasi-static position during treatment.The algorithm based on the statistical analysis of the signal and a small sample size performed accordingly and satisfactorily.It also avoided long delays.The software and hardware operations were validated with tests performed in humans, obtaining 87.5% for inspiratory and 94.3% for expiratory event detection success rates.Thus, an innovative system combining a statistical based algorithm for automatic detection of quiet breathing and a strain-gage based sensor that can be employed to synchronize a TFES system has been successfully developed.

Figure 1 .
Figure 1.Block diagram of a dual synchronized TFES system with automatic respiratory phase detection.

Figure 2 .
Figure 2. Respiratory signal generated by the strain-gage based sensor.Identifying the slope (β) of successive linear approximations provides the time stamps that delimit both inhalation and exhalation phases.

Figure 4 .
Figure 4. Flowchart of the developed algorithm for dual TFES synchronization.

Figure 6 .
Figure 6.Respiratory signal detected for a 38 years old woman.Waveforms obtained with a digital oscilloscope: Yellow waveform represents the respiratory signal; Green pulses correspond to the inspiratory event start flag; Blue pulses represent the expiratory event start flag and the pink ones are the signals produced by the physiotherapist.

Table 1 .
Demographics of volunteers.

Table 2 .
Percentage of correctness after automatic event detector.

ID Inhalation detection Number of inhalations Exhalation detection Number of exhalations True positives a False positives b False negatives c True positives a False positives b
a True positives: 1 detection -1 event; b False positives: 1 detection -no event; c False negatives: No detection -1 event.