-
Notifications
You must be signed in to change notification settings - Fork 115
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
evaluation module #130
evaluation module #130
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #130 +/- ##
==========================================
- Coverage 92.53% 83.90% -8.64%
==========================================
Files 23 24 +1
Lines 3108 3498 +390
==========================================
+ Hits 2876 2935 +59
- Misses 232 563 +331 ☔ View full report in Codecov by Sentry. |
Just scrolled through the new files very quickly, this looks incredible!! Can't wait to try it and review in details in the next few days. To answer your questions:
|
Agreed 👍
Agreed. Some more questions, and then I'll just leave any more for the real review:
|
Yep sounds good
Appropriate! I would only add the
I actually wanted to tell you that this should be the responsibility of the users. I wouldn't trim at all, just return an error/warning if the hypnogram length and index do not match, especially if the index of the Hypnogram is a
Nope. I think it's easy enough for the users to regenerate a new Hypnogram after using |
@raphaelvallat I'm still in draft mode! I've been making major changes the last few days. Please wait until I leave draft mode before a review, otherwise I'm afraid this will be waste of your time. Although if you're in a rush to merge this, then also let me know and I'll take quicker steps. Otherwise I except to have the PR finalized and ready for review by tomorrow end of day. |
Oh shoot sorry about that! I'll be travelling for the next two days and unable to review but I can review later this week. No rush at all on the PR though! |
No worries! It would just suck if you put in lots of effort on old code. No time wasted so far though, your current comments are still useful and relevant so I'll incorporate them. Thanks! 👍 |
@raphaelvallat, I just pushed some old (and some new) commits. I'm catching up and getting it ready for review. The EpochByEpoch part is done but still working out the SleepStats class, the latter of which is not functional right now. A few more commits and it should be ready for review. I'm with you in publishing the next YASA version over winter break 👍 |
Hi @remrama ! Unfortunately I was sick for my entire week of vacation during the winter break and did not have a chance to work on the open-source libraries at all (and work has been crazy ever since I got back) 😞 Are you still planning on adding more commits soon? |
Can you please rebase to the latest |
Same situation for me @raphaelvallat -- out sick for the end of break and then lots of stuff going on at work upon return. But yes, more commits coming soon. I will try to rebase as well. |
docstrings examples plot_hypnogram lw --> linekwargs heatmap colorbar label pass kwargs through to all pingouin calls docstrings examples update setting attrs, docstrings, var name changes SleepStatsEval takes 2 dataframes as input, reshaping is done internally EpochByEpoch accepts sequences of Hypnograms for group evaluation EpochByEpoch gets sleep stats SleepStats move statistical tests to __init__() better plotting flexibility and baked-in sleepstats_order
use hyp integers instead of strings for big skm agreement speed improvements (~2s) fmt quick comment addresses mad typo pd.crosstab --> skm.confusion_matrix
minor normality bug black fmt makes my pandas chains lonnggggg diff_data --> discrepancies trailing not leading _kwargs
class methods alphabetical order
@raphaelvallat this is available to review at your convenience. There are still some things to do, but the core structure is done so I think we could move forward. After review, I'll still need to:
|
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.
What an absolute beast of a PR @remrama ! I read through the entire code and was really impressed by its quality, efficiency and extensive documentation. I have not yet tried to run the full pipeline but I trust that it is working as expected. I think that we should merge this PR now for the sake of simplicity, and then you and I can work on finishing the tasks that you listed in the PR description and adding an extensive tutorial in future PRs.
Once these are done, I think you need to publicize this amazing work (and get some recognition for it!), e.g. as a Twitter thread and/or as a blog post on the NSRR website.
I've included minor comments but none of these are blockers for merging the current PR.
Thanks again, really appreciate all this work. This is going to be a huge contribution to the sleep research/data science ecosystem.
PS: Can you please have a look into the conflicts on plotting.py
?
PS2: Please run black . -l 100
with black>=24.1.1
Merci beaucoup @raphaelvallat, the compliments are really appreciated. I like your plan of merging and then working on the last bits in separate PR(s). I think it's safest to open up one issue that has all the tasks that must happen before There's one other thing I'd like to get nailed down before merging this: module name. We started with |
@remrama I have no strong preference between
Sounds great 👍 |
I'm not sure where the conflict started, but I needed to be able to pass |
This PR adds a new
yasa.evaluation
module to YASA. The purpose of the module is to offer convenience methods for evaluating/comparing sleep-staging from multiple devices or raters. See Issue #78 for more detail.Major additions:
yasa.evaluation.EpochByEpochEvaluation
class. This class takes in two YASA Hypnograms and returns an instance where agreement scores and comparison plots can be returned. Suggested use is from theevaluate
Hypnogram method:ebe = hyp_a.evaluate(hyp_b)
.yasa.evaluation.SleepStatsEvaluation
class. This class takes in a pandas DataFrame that includes sleep statistics calculated from two different raters/devices, for multiple subjects/sessions.Minor changes:
pingouin>=0.5.3
requirement. Pingouin is used for a lot of the underlying statistics, and0.5.3
is required becauseSleepStatsEvaluation.plot_blandaltman
uses a feature frompingouin.plot_blandaltman
that was introduced in0.5.3
.yasa.plot_hypnogram
to help accommodateEpochByEpochEvaluation.plot_hypnograms
. Most notably, the explicitlw
keyword argument was removed and replaced with**kwargs
, which can includelw
but also other parameters controlling line aesthetics (e.g.,ls
,alpha
). Note that becauselw
is still accepted, this will not break previous code.Future additions (things to consider but will not be implemented in the current PR):
jitter
the overlaid hypnogram line (to avoid direct overlap when they are the same, which can be confusing). This is tricky now with the way that y-values are derived inyasa.plot_hypnogram
, so avoiding for now.@raphaelvallat I'm posting this still in draft state, not ready for review yet. A few questions to address before finalizing:
yasa.evaluation
classes. Previously, I've been arguing for keeping all plotting code and imports to be isolated inyasa.plotting
. So I'm planning to port it over there, but I want to check this is the right approach before I do this. Am I right in thinking they should stay separate or am I overthinking that? And if all the plotting code is isolated inyasa.plotting
, it seems like those functions should have leading underscores and be removed from the API docs (the docs would in the class methods instead). This could be how the evaluation plots start, andyasa.plot_hypnogram
could be converted toyasa._plot_hypnogram
later inv0.8
. But again, I'd like a second opinion on whether this is best.test
vsreference
(ref
) devices?true
vspred
is more consistent with scikit-learn, but "true" is a bit of a misnomer in the sleep staging case. Could also just bea
vsb
. Probably overthinking it, I just know we're kinda locked in to whatever we start with.