Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HRV Frequency metrics different from Kubios output #1069

Open
alkaest2002 opened this issue Feb 4, 2025 · 2 comments
Open

HRV Frequency metrics different from Kubios output #1069

alkaest2002 opened this issue Feb 4, 2025 · 2 comments

Comments

@alkaest2002
Copy link

Describe the bug
I am trying to compare neurokit2 HRV frequency analysis with Kubios Frequency Domain output.

How To Reproduce

  1. These are my RR-intervals taken from Kubios output (~6 min. of recordings)
rri_values = [ 863.,  857.,  855.,  882.,  918., 1000.,  978.,  933.,  877.,
        850.,  838.,  836.,  830.,  850.,  842.,  841.,  866.,  939.,
        950.,  925.,  882.,  872.,  878.,  890.,  885.,  903.,  898.,
        912.,  948.,  881.,  804.,  798.,  810.,  968., 1017.,  973.,
        936.,  910.,  903.,  916.,  910.,  910.,  911.,  916.,  899.,
        870.,  853.,  869.,  942., 1022.,  937.,  941.,  911.,  920.,
        894.,  930.,  938.,  934.,  925.,  879.,  840.,  822.,  786.,
        809.,  833.,  910.,  984.,  999.,  998.,  913.,  857.,  831.,
        850.,  937., 1018., 1010.,  986.,  979.,  951.,  934.,  933.,
        925.,  923.,  928.,  930.,  943.,  915.,  905.,  914.,  929.,
        951.,  950.,  980.,  988.,  964.,  948.,  945.,  934.,  925.,
        923.,  897.,  857.,  869.,  897.,  927.,  968.,  988.,  955.,
        944.,  925.,  914.,  911.,  888.,  854.,  860.,  878.,  921.,
        967., 1010., 1019.,  988.,  947.,  911.,  886.,  873.,  869.,
        882.,  897.,  911.,  940.,  974., 1009., 1013., 1031., 1025.,
       1025., 1029.,  995.,  971.,  947.,  938.,  939.,  939.,  925.,
        893.,  893.,  903.,  915.,  947.,  980.,  967.,  945.,  928.,
        917.,  908.,  899.,  895.,  848.,  864.,  917.,  980., 1042.,
       1034., 1004.,  990.,  975.,  955.,  931.,  852.,  827.,  782.,
        946.,  933.,  978.,  980.,  972.,  966.,  945.,  928.,  912.,
        906.,  869.,  859.,  879.,  923.,  956.,  982., 1013.,  983.,
        956.,  923.,  903.,  916.,  909.,  917.,  916.,  912.,  920.,
        935.,  884.,  875.,  892.,  912.,  943.,  973., 1007.,  974.,
        935.,  918.,  900.,  884.,  875.,  840.,  857.,  881.,  921.,
        951.,  976., 1002., 1016.,  977.,  949.,  926.,  908.,  895.,
        900.,  896.,  873.,  855.,  867.,  896.,  923.,  946.,  971.,
        946.,  925.,  916.,  908.,  892.,  879.,  867.,  851.,  861.,
        896.,  923.,  941.,  968., 1005.,  983.,  959.,  940.,  926.,
        914.,  904.,  859.,  853.,  862.,  876.,  903.,  921.,  942.,
        970.,  946.,  915.,  897.,  890.,  878.,  875.,  873.,  878.,
        876.,  882.,  883.,  854.,  859.,  876.,  891.,  912.,  922.,
        934.,  957.,  942.,  922.,  909.,  891.,  880.,  874.,  872.,
        880.,  896.,  895.,  904.,  884.,  884.,  895.,  902.,  929.,
        939.,  923.,  923.,  913.,  907.,  907.,  898.,  898.,  866.,
        863.,  885.,  914.,  936.,  968.,  954.,  938.,  917.,  909.,
        903.,  897.,  904.,  908.,  893.,  900.,  918.,  930.,  942.,
        943.,  921.,  908., 1005.,  971.,  935.,  917.,  911.,  904.,
        896.,  884.,  850.,  837.,  844.,  870.,  901.,  910.,  923.,
        930.,  907.,  883.,  874.,  868.,  863.,  879.,  881.,  893.,
        849.,  853.,  875.,  904.,  913.,  928.,  938.,  916.,  887.,
        880.,  860.,  850.,  830.,  813.,  787.,  803.,  862.,  950.,
        945.,  948.,  967.,  969.,  948.,  917.,  898.,  865.,  848.,
        842.,  815.,  822.,  873.,  900.,  926.,  928.,  962.,  983.,
        976.,  951.,  938.,  930.,  912.,  900.]
  1. Frequency Analysis
# sanitize
rri, rri_time,_ = intervals_utils._intervals_sanitize(rri_values)

# interpolate
rri_interpolated, rri_time_interpolated, sampling_rate = intervals_process(
        rri, rri_time, interpolate=True, interpolation_rate=4, detrend=None
    )

# analyze
nk.hrv_frequency(
    dict(RRI=rri_interpolated, RRI_Time=rri_time_interpolated), 
    sampling_rate=130, 
    interpolation_rate=None,
    ulf=(0, 0.003), vlf=(0.003, 0.04), lf=(0.04, 0.15), hf=(0.15, 0.4), vhf=(0.4, 0.5),
    normalize=False).T.dropna()
  1. Output
metric values
HRV_VLF 163.568
HRV_LF 1453.49
HRV_HF 166.478
HRV_VHF 10.0453
HRV_TP 1793.58
HRV_LFHF 8.73083
HRV_LFn 0.810385
HRV_HFn 0.0928187
HRV_LnHF 5.11486

Expected behaviour
I would expect roughly the same values for VLF, LF and HF

Screenshots

Kubios Frequency Analysis
Image

Kubios Settings - Input and data processing
Image

Kubios Settings - frequency-domain
Image

Honestly, I am not sure whether to change Window width (300) to match the recording time (in my case ~6 min., ~360).
Even changing such parameter, neurokit2 HRV frequency analysis metrics are somewhat different from Kubios output

System Specifications

- OS: Darwin (Mach-O 64bit) 
- Python: 3.13.1 
- NeuroKit2: 0.2.10 
- NumPy: 2.2.2 
- Pandas: 2.2.3 
- SciPy: 1.15.1 
- sklearn: 1.6.1 
- matplotlib: 3.10.0

And copy paste the output.

Copy link

welcome bot commented Feb 4, 2025

Hi 👋 Thanks for reaching out and opening your first issue here! We'll try to come back to you as soon as possible. ❤️ kenobi

@alkaest2002
Copy link
Author

Just to add another observation: initially, I thought the problem was related to the artifact removal performed by Kubios on the RR intervals. However, this is not the case. Even after disabling cleaning of RR intervals, the issue persists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant