biopsykit.signals.rsp package

Module for Respiration data analysis and visualization.

class biopsykit.signals.rsp.RspProcessor(data, sampling_rate=None, time_intervals=None, include_start=False)[source]

Bases: biopsykit.signals._base._BaseProcessor

Initialize an RspProcessor instance.

You can either pass a data dictionary ‘data_dict’ containing Respiration data or dataframe containing Respiration data. For the latter, you can additionally supply time information via time_intervals parameter to automatically split the data into single phases.

Parameters
  • data (DataFrame or dict) – dataframe (or dict of such) with Respiration data

  • sampling_rate (float, optional) – sampling rate of recorded data

  • time_intervals (dict or Series, optional) – time intervals indicating how data should be split. Can either be a Series with the start times of the single phases (the phase names are then derived from the index) or a dictionary with tuples indicating start and end times of phases (the phase names are then derived from the dict keys). Default: None (data is not split further)

  • include_start (bool, optional) – True to include the data from the beginning of the recording to the first time interval as the first phase (then named Start), False otherwise. Default: False

classmethod rsp_compute_rate(rsp_signal, sampling_rate=256.0)[source]

Compute respiration rate for given interval from respiration signal.

Parameters
  • rsp_signal (DataFrame) – Raw respiration signal (1D). Can be a ‘true’ respiration signal (e.g. from bioimpedance or Radar) or an ‘estimated’ respiration signal (e.g. from ECG-derived respiration)

  • sampling_rate (float, optional) – Sampling rate of recorded data

Returns

Respiration rate during the given interval in bpm (breaths per minute)

Return type

float

References

Schäfer, A., & Kratky, K. W. (2008). Estimation of Breathing Rate from Respiratory Sinus Arrhythmia: Comparison of Various Methods. Annals of Biomedical Engineering, 36(3), 476-485. https://doi.org/10.1007/s10439-007-9428-1

Examples

>>> from biopsykit.signals.ecg import EcgProcessor
>>> # initialize EcgProcessor instance
>>> ecg_processor = EcgProcessor(...)
>>> # Extract respiration signal estimated from ECG using the 'peak_trough_diff' method
>>> rsp_signal = ecg_processor.ecg_estimate_rsp(ecg_processor, key="Data", edr_type='peak_trough_diff')
>>> # Compute respiration rate from respiration signal
>>> rsp_rate = ecg_processor.rsp_compute_rate(rsp_signal)