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

Fix boundary condition for start date after noon. Thanks @BernieVA #52

Merged
merged 1 commit into from
Jul 16, 2024

Conversation

angerhang
Copy link
Member

When the start time on the first day is after noon, the first interval will be empty, as the current implementation moves the internal start to 24 hours prior.

This fix makes sure that when this happens, the first day should start from the same day.

Test plan:

python asleep/get_sleep.py ../data/sample.cwa

Output:

Total sample count : 7200
12it [03:46, 18.86s/it]
Save predictions to outputs/sample/y_pred.npy
Save prediction probs to outputs/sample/pred_prob.npy
Time used 227.81667113304138
predictions_df shape: (16841, 4)
                     time sleep_wake sleep_stage  raw_label
0 2014-05-07 13:29:50.430       wake        wake          0
1 2014-05-07 13:30:20.430       wake        wake          0
2 2014-05-07 13:30:50.430       wake        wake          0
3 2014-05-07 13:31:20.430       wake        wake          0
4 2014-05-07 13:31:50.430       wake        wake          0
Predictions saved to: outputs/sample/predictions.csv
                    start                           end      interval_start        interval_end  wear_duration_H  is_longest_block
0 2014-05-07 20:08:20.430 2014-05-07 20:55:50.430000000 2014-05-07 12:00:00 2014-05-08 11:59:59        22.508333             False
1 2014-05-07 21:48:50.430 2014-05-08 08:44:20.430000000 2014-05-07 12:00:00 2014-05-08 11:59:59        22.508333              True
2 2014-05-08 17:06:20.430 2014-05-08 17:59:20.430000000 2014-05-08 12:00:00 2014-05-09 11:59:59        24.000000             False
3 2014-05-09 00:38:20.430 2014-05-09 09:24:50.429999999 2014-05-08 12:00:00 2014-05-09 11:59:59        24.000000              True
4 2014-05-09 19:33:50.430 2014-05-09 20:09:20.430000000 2014-05-09 12:00:00 2014-05-10 11:59:59        24.000000             False
Sleep block saved to: outputs/sample/sleep_block.csv
Summary saved to: outputs/sample/summary.json

@angerhang angerhang merged commit 949236d into main Jul 16, 2024
9 checks passed
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.

1 participant