Respiration Analyzer
The Respiration Analyzer preprocesses and analyzes a chest or abdomen expansion signal.
Table of contents
Introduction
The Respiration Analyzer preprocesses a chest or abdomen expansion signal generated by a forcetransducer, and calculates basic descriptive statistics for inhalation, exhalation, and breath phases, per epoch.
The respiration module defines a single breath as an inhalation followed directly by an exhalation. Breaths cannot exist without both an inhalation and an exhalation phase. The current version does not classify a breathhold phase. Breaths, inhalations, and exhalations are timestamped at the end of their cycle.
User Corrections
The Respiration Analyzer module allows users to remove complete breath cycles by selecting a section in the main graph and selecting the ‘disregard’ option, which adds a ‘Respskip’ zone to the module. Any breath that overlaps any skip zones, even partially, are completely removed.
Processing and Analysis Pipeline
The data processing and analysis pipeline used by the Respiration module is described below. The method is based on the approach described by Lu et al. (2006)^{1}.
Step 1: Filtering the signal
The raw respiration transducer signal is fetched from the specified channel, and multiplied by the specified gain. If enabled, the signal is then low and/or high pass filtered at the specified cutoff frequencies.
Step 2: Generating the Moving Mean Signal
The article^{1} calculates a moving average signal from the respiration signal, then uses the locations of the intercepts between these signals to search for the inhalation and exhalation transitions. The article uses a Fast Fourier transform (FFT) to estimate the respiration period (T) of the signal, then uses this to dimension the moving average window, which they give a width of 2T. Since the Toolbox does not assume steady state freebreathing, the respiration rate is instead estimated using a halfoverlap moving window, across the whole signal, in order to take varying T values into account.
The signal is first resampled to 100 Hz, highpass filtered at 0.05 Hz, and split into windows of 60 seconds, with 15 second overlaps on each side. Then, using FFT, the T is estimated per window, and that window is filtered using a moving mean filter with a window length equal to T_multiplier times the estimated T of that window, with T_multiplier being a userspecifiable setting.
The windows are then reassembled into a single signal, smoothed using a 1second moving mean filter, and resampled to the original respiration signal frequency.
Step 2: Detecting the Intercepts
First, the Toolbox searches for the up and downintercepts of the moving mean signal produced by step 2, and the filtered respiration signal produced by step 1. Secondly, all upintercepts that do not follow a downintercept, and all downintercepts that do not follow upintercepts are iteratively deleted until the intercept series alternates between up and down intercepts.
Thirdly, all intercept intervals that are shorter than 100 ms are removed, with intercept intervals being defined as downintercepts times minus the corresponding upintercept times.
Step 3: Finding Inhalation and Exhalation Onsets
Inhalation onsets are detected by searching backwards from each upintercept, and looking for the first sample that features a positive gradient; i.e., searching for the start of the slope, on the filtered respiration signal, which intercepts the moving mean signal. The onset is then placed on the first sample after the start of the slope that features a gradient larger than the specified percentage of the maximum gradient of the slope. Note that the end of the slope is defined as the last sample with a positive gradient.
If the max/min method for inhalation/exhalation onset detection was chosen, the start and end of the slopes are instead defined as the minimum and maximum values of the filtered respiration signals between the downintercepts surrounding the upintercept in question.
The exhalations are detected in the same way, albeit in inverse.
The end of each inhalation and exhalation phase is defined as occurring on the sample before the next inhalation or exhalation start.
Step 4: Defining Breaths
Using the inhalation and exhalation onsets and offsets detected in step 3, breaths are defined as starting at an inhalation onset, and ending at the subsequent exhalation offset, with an inhalation/exhalation transaction in between.
Subsequently, inhalations with a duration shorter than the specified minimum threshold are detected and merged into the surrounding exhalation. Similarly, short exhalations are merged into the surrounding inhalations.
Inhalations with amplitudes that are smaller than the local moving mean minus a multiplier times the local moving standard deviation are then also merged into the surrounding exhalations. The moving mean and moving standard deviation are calculated using the userspecified window span, and the rejection threshold is calculated using the userspecified multiplier. Inhalation and exhalation amplitudes are defined as the value of the filtered respiration signal at the end of the phase, minus that at the start of the phase. Breaths that feature inhalations that are larger than the local moving mean plus the multitier times the local moving standard deviation are completely removed.
Next, the exhalation amplitude outliers are processed in the same way.
Breaths containing either inhalations or exhalation with durations that are larger than the specified maximum are then completely removed.
Next, breaths containing either inhalations or exhalation with durations that are larger than the local moving mean plus the multitier times the local moving standard deviation are also completely removed.
Lastly, all breaths that overlap the userspecified respskip zones are removed, even if they only partly overlap the skip zone.
Step 5: Generating the Smooth Breath Period Signal
A breath period is defined as the duration from the start of a breath to the end, with the breath being timestamped at the end of that breath. A smooth breath period signal is generated by smoothing the breath time series using the lowess method, with a span being the userspecified smoothing window width.
The smoothed breath period timeseries are then interpolated at 50 Hz using the pchip method to form the smooth continuous breath period signal.
Step 6: Data Analysis
When analyzing the data, the minimum, mean, median, maximum and standard deviation of the inhalation, exhalation and breath durations, and the breath amplitude, are calculated for each epoch. Inhalations, exhalations and breaths are only included inside an epoch if they start and end inside the epoch.
Additionally, the total number of full breaths, and the breath coverage—which is the sum of all breath durations as a percentage of the epoch duration—are calculated.
Settings
The autogenerated list below shows the settings available in the Respiration Analyzer module:

General Settings:
Name, source and epoch settings for this PhysioAnalyzer.
Analyzer prefix (tag):
The tag (name) of this PhysioAnalyzer. The tag must be unique and start with a letter, and may only contain alphanumeric characters. 
Channelnumber of signal:
The channel number (index) of the signal to be analyzed. 
Generate epochs from:
Specifies how epochs are generated.


Preprocessing Settings
Settings for processing the raw respiration signal. This module assumes that a force transducer was used to measure the chest or abdominal expansion, with upward slopes corresponding to inhalations.
Gain (signal multiplier) [x]:
The gain is the value with which the raw signal is multiplied before being further processed and analyzed. 
Lowpass filter [Hz]:
The lowpass filter and its cutoff frequency. 
Highpass filter [Hz]:
The highpass filter and its cutoff frequency.


Inhalation and Exhalation Detection:
The Toolbox detects inhalations and exhalations by analyzing the intercepts of the respiration signal and its moving mean. Inhalations or exhalations that violate duration or amplitude criteria are automatically rejected. The onset of each inhalation/exhalation can be detected by looking at the min/max of the signal, or the start of the slope, and corrected using a slope gradient threshold.
Movingmean multiplier []:
The moving mean is calculated using an adaptive moving window with a length equal to the local estimated respiration period times this multiplier. 
Min. & max. inhalation duration [s]:
Inhalations must have a duration between these limits. 
Min. & max. exhalation duration [s]:
Exhalations must have a duration between these limits. 
Outlier filter threshold and span [s]:
The std multiplier and window span, in seconds, of the moving mean std outlier rejection filter. 
Inhalation/Exhalation detection [ ]:
The start of the inhalation and exhalation can be detected by either looking for the minimum or maximum, or looking for the onset of the slopes. 
Slope gradient threshold [%]:
Each inhalation or exhalation starts when the absolute gradient exceeds the absolute maximum during the slope. 
Smoothing window width [s]:
The breath periods are smoothed using a lowess filter with this span, in seconds.

Metrics
The autogenerated table belows lists all the metrics produced by the Respiration Analyzer module.
Table 1: The metrics calculated by the Respiration Analyzer module.
Variable:  Unit:  Description: 

Min_inhalation_dur  s  The minimum inhalation duration, per epoch. 
Mean_inhalation_dur  s  The mean inhalation duration, per epoch. 
Median_inhalation_dur  s  The median inhalation duration, per epoch. 
Max_inhalation_dur  s  The maximum inhalation duration, per epoch. 
Std_inhalation_dur  s  The standard deviation of the inhalation durations, per epoch. 
Min_exhalation_dur  s  The minimum exhalation duration, per epoch. 
Mean_exhalation_dur  s  The mean exhalation duration, per epoch. 
Median_exhalation_dur  s  The median exhalation duration, per epoch. 
Max_exhalation_dur  s  The maximum exhalation duration, per epoch. 
Std_exhalation_dur  s  The standard deviation of the exhalation durations, per epoch. 
Min_breath_dur  s  The minimum breath duration, per epoch. 
Mean_breath_dur  s  The mean breath duration, per epoch. 
Median_breath_dur  s  The median breath duration, per epoch. 
Max_breath_dur  s  The maximum breath duration, per epoch. 
Std_breath_dur  s  The standard deviation of the breath durations, per epoch. 
Min_breath_amp  V  The minimum breath amplitude, per epoch. 
Mean_breath_amp  V  The mean breath amplitude, per epoch. 
Median_breath_amp  V  The median breath amplitude, per epoch. 
Max_breath_amp  V  The maximum breath amplitude, per epoch. 
Std_breath_amp  V  The standard deviation of the breath amplitudes, per epoch. 
fullBreathsCount    The number of complete breaths detected inside the epoch. 
breathCoverage  %  Percentage of the epoch covered by full breaths; i.e. the total breath duration over the epoch duration, multiplied by 100. 
mean_InterpBreathPeriod  s  The mean of the breath period, calculated as the mean of the smooth interpolated breath period (i.e. breath duration) signal, per epoch. 