Repository navigation
MRG: Trimming Sleep Physionet recordings to avoid W imbalance - #8179
Conversation
larsoner
left a comment
There was a problem hiding this comment.
Just a final thought, I wonder if the mintime default of equalize_event_counts would get you this for free without requiring any of these manual gymnastics, and also have the benefit of taking into account events that actually get dropped (assuming you use the original events and preload=True or epochs.drop_bad)...
| # keep last 30-min wake events before sleep and first 30-min wake events after | ||
| # sleep | ||
| sleep_stage_inds = np.where(events_train[:, 2] > 1)[0] | ||
| offset = int((30 * 60) / 30) |
There was a problem hiding this comment.
The units here / reasons for the given numbers are difficult to parse. The 60 makes sense because it's sec/min, the first 30 makes sense because it's min, but then the last 30 is ... ? Probably making use of some informative variable names above (possibly having to do with the time between samples?) and reusing them here could fix this problem.
Also int(x_int / y_int) is less clean than x_int // y_int
|
good to go from my end. @larsoner merge if happy |
Much nicer solution, thanks! |
|
Precision and recall for all classes other than Wake are better on this PR. It would be nice if there were some overall metric that would go up with this PR compared to master, instead of some going up and some going down. @agramfort I'll let you add the right one someday when you're bored :) |
…ysionet * upstream/master: ENH: Add message (mne-tools#8193) ENH: Allow writing BEM in H5 format (mne-tools#8191) ENH: Add ori on MRI slices (mne-tools#8188) Ricoh new files (mne-tools#8187) MRG: Split _timeviewer.py into multiple files (mne-tools#8181) ENH: Better memory efficiency (mne-tools#8185) MRG: Trimming Sleep Physionet recordings to avoid W imbalance (mne-tools#8179) MRG, BUG: Fix montage plotting, deduplication, and preload check (mne-tools#8178) Test PSD topomap works with NIRS epochs (mne-tools#8180) MRG, MAINT: Tweak CI versions (mne-tools#8174)
…ols#8179) * cutting recordings to keep only 5 minutes of W before and after sleep * changing to 30-min before and after sleep based on Supratak et al. 2017 * use annot crop * typo Co-authored-by: Alexandre Gramfort <[email protected]>
In the example for the Sleep Physionet dataset, there is a large class imbalance in favour of wake (W). This is because the recordings in this dataset were collected over longer periods of time and thus there are long periods of awake time before and after the night. It is common practice in the literature to trim the beginning and end parts of the recordings of this dataset to reduce class imbalance (e.g., https://arxiv.org/abs/1703.04046, https://arxiv.org/abs/1610.01683, https://arxiv.org/abs/1710.00633).
Following discussion with @agramfort, this PR modifies the example to only keep the last 30 minutes before the first sleep event and the first 30 minutes after the last sleep event when building the training and testing sets.