Skip to main content Link Search Menu Expand Document (external link)

Respiration Analyzer

The Respiration Analyzer preprocesses and analyzes a chest or abdomen expansion signal.

Table of contents
  1. Introduction
  2. User Corrections
  3. Processing and Analysis Pipeline
    1. Step 1: Filtering the signal
    2. Step 2: Generating the Moving Mean Signal
    3. Step 2: Detecting the Intercepts
    4. Step 3: Finding Inhalation and Exhalation Onsets
    5. Step 4: Defining Breaths
    6. Step 5: Generating the Smooth Breath Period Signal
    7. Step 6: Data Analysis
  4. Settings
  5. Metrics
  6. References


The Respiration Analyzer preprocesses a chest or abdomen expansion signal generated by a force-transducer, 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 breath-hold phase. Breaths, inhalations, and exhalations are timestamped at the end of their cycle.

Respiration Analyzer
Figure 1: The Respiration Module GUI.

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 ‘Resp-skip’ 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 article1 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 free-breathing, the respiration rate is instead estimated using a half-overlap moving window, across the whole signal, in order to take varying T values into account.

The signal is first resampled to 100 Hz, high-pass 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 user-specifiable setting.

The windows are then reassembled into a single signal, smoothed using a 1-second moving mean filter, and resampled to the original respiration signal frequency.

Step 2: Detecting the Intercepts

First, the Toolbox searches for the up and down-intercepts of the moving mean signal produced by step 2, and the filtered respiration signal produced by step 1. Secondly, all up-intercepts that do not follow a down-intercept, and all down-intercepts that do not follow up-intercepts 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 down-intercepts times minus the corresponding up-intercept times.

Step 3: Finding Inhalation and Exhalation Onsets

Inhalation onsets are detected by searching backwards from each up-intercept, 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 down-intercepts surrounding the up-intercept 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 user-specified window span, and the rejection threshold is calculated using the user-specified 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 user-specified resp-skip 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 user-specified smoothing window width.

The smoothed breath period time-series 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.


The auto-generated 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.

    • Channel-number 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 low-pass filter and its cutoff frequency.

    • Highpass filter [Hz]:
      The high-pass 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.

    • Moving-mean 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.


The auto-generated 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.


  1. Lu, W., Nystrom, M. M., Parikh, P. J., Fooshee, D. R., Hubenschmidt, J. P., Bradley, J.D., & Low, D. A. (2006). A semi-automatic method for peak and valley detection in free-breathing respiratory waveforms. Medical Physics, 33, 3634-3636.  2

© Copyright Leiden University, 2022.