phuselab / pyVHR

Python framework for Virtual Heart Rate
http://phuselab.di.unimi.it/
GNU General Public License v3.0
453 stars 127 forks source link

Can I get HRV from this repo ? #46

Closed robert-go closed 1 year ago

robert-go commented 2 years ago

This repo is amazing It helped me a lot I read its code and was able to get HR(bpm) But can I get HRV? Can I get R peaks or RR intervals? Should I start from the BVP list? Do you have any suggestions? I can contribute to this project.

aledamelio commented 2 years ago

Hi @robert-go, thanks for your interest in this project. Yes, you should start from the BVP list and perform some peak detection algorithm on the predicted rPPG signal. I guess biosppy (which is already in the pyVHR dependencies) probably does something like that.

Cheers, Alessandro

robert-go commented 2 years ago

Thanks for the suggestion @aledamelio I'm trying to add biosppy to calculate bvps list like that https://github.com/robert-go/pyVHR/commit/f03829f863ff9eb88dd7f11c00d433e015d8b455 But I faced the problem.

Processing Video: /Users/minhdrminh/Downloads/IMG_1988.MOV
INFO: Created TensorFlow Lite XNNPACK delegate for CPU.

BVP extraction with method: cpu_POS

BPM estimation with: welch
Traceback (most recent call last):
  File "/Users/minhdrminh/Projects/pyVHR/main.py", line 7, in <module>
    time, BPM, uncertainty = pipe.run_on_video(
  File "/Users/minhdrminh/Projects/pyVHR/pyVHR/analysis/pipeline.py", line 165, in run_on_video
    new_result = biosppy.signals.bvp.bvp(bvps)
  File "/opt/miniconda3/envs/pyvhr/lib/python3.9/site-packages/biosppy/signals/bvp.py", line 76, in bvp
    onsets,_ = ppg.find_onsets_elgendi2013(signal=filtered, sampling_rate=sampling_rate)
  File "/opt/miniconda3/envs/pyvhr/lib/python3.9/site-packages/biosppy/signals/ppg.py", line 169, in find_onsets_elgendi2013
    ma_peak, _ = st.smoother(squared_signal, kernel="boxcar", size=ma_peak_kernel)
  File "/opt/miniconda3/envs/pyvhr/lib/python3.9/site-packages/biosppy/signals/tools.py", line 612, in smoother
    (signal[0] * np.ones(size), signal, signal[-1] * np.ones(size)))
ValueError: operands could not be broadcast together with shapes (100,180) (6,) 

I think I did not use the correct data type, do you have any further suggestions?

danteblink commented 1 year ago

@robert-go Did u have any success with biosppy?

robert-go commented 1 year ago

@robert-go Did u have any success with biosppy?

No, I didn't I tried but really I don't have much experience So maybe I'll turn this into a feature request

danteblink commented 1 year ago

thanks!, I will try with other packages