neuropsychology / NeuroKit

NeuroKit2: The Python Toolbox for Neurophysiological Signal Processing
https://neuropsychology.github.io/NeuroKit
MIT License
1.58k stars 421 forks source link

Inconsistency RRV_DFA_alpha1/alpha2 definitions and implementation? #1038

Open michielmeys opened 1 month ago

michielmeys commented 1 month ago

The implementation of when RRV_DFA_alpha1 and RRV_DFA_alpha2 are computed (within neurokit2/rsp/rsp_rrv.py; lines 224 to 241) appears inconsistent with their definitions within the documentation/this function's docstring. Currently, the long-term fluctuation value is computed before even the threshold of the short-term value is reached, for more than 65 cycles, rather than 640.

Could this be verified?

welcome[bot] commented 1 month ago

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

DominiqueMakowski commented 1 month ago

Could you clarify what you mean? And could you help letting us know what you would change (in the docs or the code)

michielmeys commented 1 month ago

Sorry for the lack of clarity. It just appears that DFA_alpha2 can currently be computed for breathing recordings that are too short (too few breathing cycles) according to this measure's definition (there should be at least 640). To be consistent with the docs, I think it would suffice to change line 234 from if len(bbi) > 65: to if len(bbi) > 640: (or to if len(bbi) / 10 > 64:, similar to how it is written for DFA_alpha1 in line 225, for a reason I don't really understand).

I was hesitant to suggest a concrete change since I'm not really familiar with these measures and I am just raising this point based on what I noticed. Apologies for that, and please let me know if I'm still not clear.