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

Heart rate data #199

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

Heart rate data #199

wants to merge 10 commits into from

Conversation

MashRiza
Copy link

I have introduced Changes to the SleepECG package, primarily focusing on enabling sleep stage classification using heart rate data when EEG signals are not available. Key features of this update include:

Heart Rate to R-Interval Conversion:

Implemented an algorithm to convert heart rate data into R-intervals. This crucial development allows the use of heart rate data, which is more readily available in many scenarios, for sleep stage classification. Handling Data Gaps:

Added robustness to the system by integrating code that effectively handles scenarios where data might be missing for extended periods. This ensures more reliable performance and resilience in real-world applications. Web-Based and Local Application:

Originally developed for a web-based project, these enhancements are equally applicable for local deployments, thereby broadening the usability scope of the SleepECG package.

@cbrnr
Copy link
Owner

cbrnr commented Dec 4, 2023

Thank you for your PR. Could you please explain what you added that wasn't available in SleepECG before? We already compute RRI, and based on that, we have implemented many different features (see https://sleepecg.readthedocs.io/en/stable/feature_extraction/).

Regarding robustness, there is an ongoing discussion in #14, maybe you want to chime in there?

@MashRiza
Copy link
Author

MashRiza commented Dec 5, 2023

Thanks for taking the time to review my pull request. In this update, I focused on enhancing the SleepECG package's capability to classify sleep stages using heart rate data (a heart rate with corresponding timestamp )when EEG signals are unavailable.
example data :
data = [
{'TimeStamp': '1690409900', 'HeartRate': '55'},
{'TimeStamp': '1690410000', 'HeartRate': '60'},
{'TimeStamp': '1690410120', 'HeartRate': '65'} ...]
Specifically, I introduced an algorithm to convert heart rate data into R-intervals, providing a valuable addition to the existing features. While I acknowledge that RRI computation is already part of SleepECG, my contribution lies in showcasing a practical example in the example folder. This example illustrates how to calculate R-intervals from heart rate and perform subsequent sleep stage classification, catering to scenarios where only heart rate data is accessible.

Additionally, I addressed the robustness of the system by implementing code to handle missing data for extended periods. This improvement aims to ensure more reliable performance in real-world applications.

Considering the ongoing discussion in #14 about robustness, I'll certainly try my best to chime in to contribute to the discourse and provide further insights into the implemented changes.

Moreover, these enhancements were initially developed for a web-based project, but I made sure they are equally applicable for local deployments, thereby expanding the SleepECG package's usability scope .

@cbrnr
Copy link
Owner

cbrnr commented Dec 13, 2023

It looks like the main addition is an option to convert RRI back to time stamps, correct? I think this could be quite useful, but in order to integrate it into SleepECG, you should put it into a dedicated function. I'm not sure if it belongs to the heartbeats or feature_extraction module, probably in the former. The function should receive an array of RRIs and return an array of heart beats.

Please remove your changes from README.md. Also, the example needs to be adapted in order to use the dedicated function. We can decide later how to best create an example (currently I think it is too long).

@hofaflo WDYT?

@hofaflo
Copy link
Collaborator

hofaflo commented Dec 16, 2023

If I understand correctly, the input data would not be RR intervals, but an irregularly sampled heart rate. But I generally agree, a function which takes heart rate and corresponding timestamps as input and produces (estimated) heartbeat times which can then be used as input to the existing feature extraction functions would be a useful addition!

@cbrnr
Copy link
Owner

cbrnr commented Dec 16, 2023

Definitely! RRI is the inverse of the HR, so the function would support both measures.

@MashRiza
Copy link
Author

Definitely! RRI is the inverse of the HR, so the function would support both measures.

The idea for this usage came up as I was working on a current project. I analyze heart rate data gathered from smart bands, and I need to deploy it on the web using JSON files as input. Thanks for your review; I will make the changes you mentioned earlier (wrap it in dedicated function and delete changes in README.md) and ask for more help if it's possible. I also recommend checking a competition on Kaggle, which has a relatively useful topic.
kaggle.com/competitions/child-mind-institute-detect-sleep-states

@MashRiza
Copy link
Author

Definitely! RRI is the inverse of the HR, so the function would support both measures.

The idea for this usage came up as I was working on a current project. I analyze heart rate data gathered from smart bands, and I need to deploy it on the web using JSON files as input. Thanks for your review; I will make the changes you mentioned earlier (wrap it in dedicated function and delete changes in README.md) and ask for more help if it's possible. I also recommend checking a competition on Kaggle, which has a relatively useful topic. kaggle.com/competitions/child-mind-institute-detect-sleep-states

i have added HeartRateSleep function as last function in feature_extraction.py .
the function also has some codes for handling missing intervals as it is common in smart band/watch .
i would love to read your reviews

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

Successfully merging this pull request may close these issues.

3 participants