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

More HRV-Features #97

Open
skjerns opened this issue Sep 27, 2022 · 3 comments
Open

More HRV-Features #97

skjerns opened this issue Sep 27, 2022 · 3 comments
Labels
enhancement 🚧 New feature or request question 🙋 Further information is requested

Comments

@skjerns
Copy link

skjerns commented Sep 27, 2022

As sleepecg already offers many different HRV features I was wondering if it would make sense to give access to all of them via yasa?

Btw: Many thanks for including sleepecg in yasa, I think the 'collaboration' is a great addition! In fact we are using it right now for one of our studies exploratory analysis :)

@raphaelvallat raphaelvallat added the question 🙋 Further information is requested label Sep 27, 2022
@raphaelvallat
Copy link
Owner

You're welcome! Yeah I think they really did a great job, the ECG heartbeat detection has now become by go-to method. As for more HRV features, we could certainly add them easily. My rationale for not including them was based on two reasons:

  1. Avoid having to reply to numerous emails about issues with, and interpretation of, the HRV features 😅
  2. Some of these features requires some parameterization (i.e. frequency-domain: PSD method, frequency band, etc). I wanted to avoid adding many extra arguments to the yasa.hrv_stage function, and instead keep the API simple.

All these features can however be calculated manually through the rpeaks output of the yasa.hrv_stage function.

@skjerns
Copy link
Author

skjerns commented Sep 28, 2022

  1. Avoid having to reply to numerous emails about issues with, and interpretation of, the HRV features 😅
  2. Some of these features requires some parameterization (i.e. frequency-domain: PSD method, frequency band, etc). I wanted to avoid adding many extra arguments to the yasa.hrv_stage function, and instead keep the API simple.

that makes total sense!

Maybe one compromise would be to allow giving a lambda as a kwarg, so that custom functions can be passed to hrv_stage? e.g. additional_features=[lambda x:x, lambda y:y] (or maybe even better, as {'name': lambda x:x}). This way all results would be in the same format and nicely separated by sleep stage in the resulting data frame.

All these features can however be calculated manually through the rpeaks output of the yasa.hrv_stage function.

Thanks, I'll check it out, I didn't know if I could simply pass the rpeaks directly to the sleepecg package. If I have time I might write a short tutorial on how to make further use of the rpeaks that is returned by the function, or would you also rather avoid having that in this repo?

@raphaelvallat
Copy link
Owner

If I have time I might write a short tutorial on how to make further use of the rpeaks that is returned by the function.

That'd be great! One possibility is to add the tutorial directly to the associated notebook: https://github.com/raphaelvallat/yasa/blob/master/notebooks/16_EEG-HRV_coupling.ipynb

I didn't know if I could simply pass the rpeaks directly to the sleepecg package

I have actually never tried myself but I think it should be pretty straightforward. It will require setting up a for loop on the epochs though.

One compromise would be to allow giving a lambda as a kwarg

Also a great idea. I have no time to work on this now, but will leave this issue open as a reminder for my future self. Or, feel free to submit a PR 👍

@raphaelvallat raphaelvallat added the enhancement 🚧 New feature or request label Sep 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement 🚧 New feature or request question 🙋 Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants