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

Hypno simulation #110

Merged
merged 22 commits into from
Dec 14, 2022
Merged

Conversation

remrama
Copy link
Collaborator

@remrama remrama commented Dec 6, 2022

Adds 2 new functions in the yasa.hypno module. See Issue #109.

  1. yasa.simulate_hypno - Simulate a hypnogram of arbitrary length. Epochs are generated using a Markov sequence based on probabilities from an epoch-to-epoch transition probability matrix. The transition probabilities can come from yasa.transition_matrix, but I think the real utility is leaving the default trans_probas=None and using a previously published probability matrix based on a large dataset of healthy hypnograms.
  2. yasa.hypno_consolidate_stages - This will take a hypnogram and drop it from a 5-stage scheme (W, 1, 2, 3, R) to one of the lower schemes (e.g., W, Light, Deep). Any scheme can be dropped to a lower scheme. This was really just added so that yasa.simulate_hypno could take an n_stages argument.

@raphaelvallat, I placed yasa.hypno_consolidate_stages in the yasa.hypno module for now just to get this merged, but I think it should ultimately be attached as a method to the new Hypnogram class instead.

@codecov-commenter
Copy link

codecov-commenter commented Dec 6, 2022

Codecov Report

Base: 91.41% // Head: 91.68% // Increases project coverage by +0.26% 🎉

Coverage data is based on head (7da9942) compared to base (b98a4c0).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #110      +/-   ##
==========================================
+ Coverage   91.41%   91.68%   +0.26%     
==========================================
  Files          22       22              
  Lines        2690     2777      +87     
==========================================
+ Hits         2459     2546      +87     
  Misses        231      231              
Impacted Files Coverage Δ
yasa/hypno.py 97.40% <100.00%> (+1.84%) ⬆️
yasa/tests/test_hypno.py 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@raphaelvallat raphaelvallat self-requested a review December 10, 2022 18:56
@raphaelvallat raphaelvallat added the enhancement 🚧 New feature or request label Dec 10, 2022
@raphaelvallat raphaelvallat linked an issue Dec 10, 2022 that may be closed by this pull request
Copy link
Owner

@raphaelvallat raphaelvallat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@remrama I am loving this so much! This is gonna be such a great addition to YASA 🚀 Added a few mostly-minor requests, but as usual great work!

yasa/hypno.py Show resolved Hide resolved
yasa/hypno.py Show resolved Hide resolved
yasa/hypno.py Outdated Show resolved Hide resolved
yasa/hypno.py Show resolved Hide resolved
yasa/hypno.py Outdated Show resolved Hide resolved
yasa/hypno.py Show resolved Hide resolved
yasa/tests/test_hypno.py Show resolved Hide resolved
@remrama
Copy link
Collaborator Author

remrama commented Dec 12, 2022

@raphaelvallat I think this should be good to go. I ended up merging with master, hope it doesn't mess things up (I rebased once and got into conflict hell, don't know why, but I restarted and was afraid to try that again).

@raphaelvallat
Copy link
Owner

Awesome work, merging now!

@raphaelvallat raphaelvallat merged commit c72c9fa into raphaelvallat:master Dec 14, 2022
@remrama remrama deleted the hypno_simulation branch December 22, 2022 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement 🚧 New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

hypnogram simulator as a useful tool
3 participants