-
Notifications
You must be signed in to change notification settings - Fork 110
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
Hypnogram plot_hypnogram method #124
Hypnogram plot_hypnogram method #124
Conversation
Codecov ReportBase: 92.53% // Head: 92.57% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #124 +/- ##
==========================================
+ Coverage 92.53% 92.57% +0.04%
==========================================
Files 23 23
Lines 3106 3112 +6
==========================================
+ Hits 2874 2881 +7
+ Misses 232 231 -1
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. |
Here's pngs of the new examples under Example 1from yasa import Hypnogram
import matplotlib.pyplot as plt
values = 4 * ["W", "N1", "N2", "N3", "REM"] + ["ART", "N2", "REM", "W", "UNS"]
hyp = Hypnogram(values, freq="24min").upsample("30s")
ax = hyp.plot_hypnogram(lw=2, highlight="REM", fill_color="thistle")
plt.tight_layout() Example 2from yasa import simulate_hypno
fig, axes = plt.subplots(nrows=2, figsize=(6, 4), constrained_layout=True)
hyp_a = simulate_hypno(tib=90, n_stages=3, seed=99)
hyp_b = simulate_hypno(tib=90, n_stages=3, seed=99, start="2022-01-31 23:30:00")
hyp_a.plot_hypnogram(fill_color="whitesmoke", ax=axes[0])
hyp_b.plot_hypnogram(fill_color="whitesmoke", ax=axes[1]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just an incredible amount of work @remrama. This is 🔥
- Please rebase and force-push to master. You can do it directly from GitHub.
- My major comment concerns the input of plot_spectrogram and more generally the behavior of
yasa.Hypnogram.upsample_to_data
. See comment for more details.
@raphaelvallat all set! Take a look, probably the only thing is the If you're satisfied with the changes, go ahead and merge or give me the go-ahead to do so. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @remrama! Approved and merged 👏
This PR brings
yasa.plot_hypnogram
up to speed with the newyasa.Hypnogram
class (Issue #116). See Issue #122 for more details.Main changes:
yasa.plot_hypnogram
does not accept int/str sequence hypnograms anymore. Input must be a Hypnogram instance.yasa.plot_hypnogram
still exists, but should mostly be considered a utility function at this point. The user should always plot withyasa.Hypnogram.plot_hypnogram
plot_hypnogram
handles any validn_stages
plot_hypnogram
takes ahighlight
parameter where any valid stage label can be passed for a red highlight (this used to be automatic to REM, but with variablen_stages
options this might differ among use-cases).start
value.yasa.plot_spectrogram
now accepts an optionalhyp
Hypnogram, as opposed to an optionalhypno
array.I didn't update any Jupyter notebooks. That feels like it would be easier to do all at once after all the new functions properly handle Hypnogram objects? Maybe as a final step?
Sidenote: Currently,
yasa.Hypnogram.upsample_to_data
returns an array butyasa.Hypnogram.upsample
returns another Hypnogram instance. Is that intended? It seems like they should both return another Hypnogram instance and then user can get the integer array as-needed. But maybe you have some other logic behind this.btw,
yasa.Hypnogram.mapping
is awesome! Sorry @raphaelvallat when I originally reviewed #116 I wasn't familiar with Python setters and so didn't realize how powerful and simple this is.