Skip to content

Commit

Permalink
Change the time gap from 1 hour to 30 mins
Browse files Browse the repository at this point in the history
  • Loading branch information
angerhang committed Apr 17, 2024
1 parent 98916f4 commit 5ba8794
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ dependencies = [ # Optional
"transforms3d",
"stepcount",
"hydra-core",
"matplotlib"
]

# List additional groups of dependencies here (e.g. development
Expand Down
5 changes: 3 additions & 2 deletions src/asleep/sleep_windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,17 @@ def fill_sleep_block_gaps(sleep_block_idxes, counter):

def count_sleep_block_gap(sleep_block_idxes, counter, epoch_length=30):
# epoch_length sec
# find the gap between sleep blocks that are less than 30 mins apart
gap2fill = []
if len(sleep_block_idxes) > 1:
first_block = counter[sleep_block_idxes[0]]
end_of_block_idx = first_block[IDX_POS] + first_block[LEN_POS]
min_one_hour_block_diff = 60 * 60 / epoch_length
min_30_mins_block_diff = 30 * 60 / epoch_length
i = 1
while i < len(sleep_block_idxes):
current_block = counter[sleep_block_idxes[i]]
dist2pre_block = current_block[IDX_POS] - end_of_block_idx
if dist2pre_block <= min_one_hour_block_diff:
if dist2pre_block <= min_30_mins_block_diff:
gap2fill.append(i - 1)
end_of_block_idx = current_block[IDX_POS] + current_block[LEN_POS]
i += 1
Expand Down
4 changes: 2 additions & 2 deletions src/asleep/visu_sleep.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ def main():
ax.axis('off')
legend_patches = [mlines.Line2D([], [], color='k', label='acceleration')]

labels = ['sleep', 'wake', 'non_wear']
colors = ['#785EF0', '#FE6100', 'gray']
labels = ['sleep', 'wake', 'non_wear', 'time_in_bed']
colors = ['#785EF0', '#FE6100', 'gray', 'yellow']

for label, color in zip(labels, colors):
legend_patches.append(mpatches.Patch(color=color, label=label))
Expand Down

0 comments on commit 5ba8794

Please sign in to comment.