Skip to main content

Chronotype

Determine the chronotype of each sleep session.

Output column name

chronotype

Get last chronotype of the week

import vitalx.aggregation as va

va.select(
    va.Sleep.chronotype().latest()
).group_by(
    date_trunc(Sleep.index(), 1, "week")
)

Get chronotype

import vitalx.aggregation as va

va.select(va.Sleep.chronotype())

Sleep Score

Calculate a Sleep Score (0 to 100) for each sleep session.

Output column name

sleep_score

Get mean sleep score of the week

import vitalx.aggregation as va

va.select(
    va.Sleep.score().mean()
).group_by(
    date_trunc(Sleep.index(), 1, "week")
)

Get sleep score

import vitalx.aggregation as va

va.select(va.Sleep.score())

Awake At / Asleep At

Pinpoint when a user first fell asleep and when they became fully awake during each sleep session.

Output column names

asleep_at, awake_at
The asleep_at macro returns the bedtime start adjusted by the recorded sleep latency, while awake_at returns the bedtime start plus the offset of the final non-awake sleep segment.

Get Asleep At and Awake At

import vitalx.aggregation as va

va.select(
    va.Sleep.asleep_at(),
    va.Sleep.awake_at()
)