Skip to content

Instantly share code, notes, and snippets.

@raphaelvallat
Last active December 5, 2023 13:45
Show Gist options
  • Star 12 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save raphaelvallat/55624e2eb93064ae57098dd96f259611 to your computer and use it in GitHub Desktop.
Save raphaelvallat/55624e2eb93064ae57098dd96f259611 to your computer and use it in GitHub Desktop.
Extract respiration signal and respiratory rate from ECG using R-R interval.
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@RaviDurbha
Copy link

Hi Raphael,

I would like to use this algorithm to compute respiration rate from PPG signal. In this process, I would like to understand how the value of
up sampling frequency sf_up = 4 was chosen. Also is there any relation between the parameters sf, sf_ori and sf_up in the algorithm.

Thanks,
Ravi

@raphaelvallat
Copy link
Author

Hi @RaviDurbha,

A 4 Hz upsampling frequency is very common in HRV analysis, hence my choice. People have also used 2 Hz.

sf_up is not affected by sf or sf_orig. Actually you can discard the downsampling from 360 Hz to 100 Hz:

sf = sf_ori
ecg = filter_data(ecg, sf, 2, 30, verbose=0)

@RaviDurbha
Copy link

Hi @raphaelvallat,

Thanks for the clarification. Instead of RR interval from ECG signal, I can compute Inter-beat-interval from PPG signal and still use your algorithm to compute respiration rate.

Thanks,
Ravi

@raphaelvallat
Copy link
Author

Yes that should work too. Please note that this is a very simple algorithm and I'm sure there are better alternative out there.

@ArthurWangusyd
Copy link

Hi Raphael,
Thank you very much for sharing. I'm a bit confused about some of the parameters in the code, for example is sf short for sampling frequency and does start for 155 means starting at 155 ms?
Thanks
Arthur

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment