Fitbit Sleep API has level summary fields for stages like deep, rem, light, wake where we can see the count, minutes, and thirtyDayAvgMinutes. If the total second count for a specific stage does not equates to a full minute, what type of rounding algorithm is used to calculate the total minutes of that stage. From data I am seeing sometimes round up and round down.
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
Hi @diptopol
Check out this chapter in our documentation. It goes into more details about how to interpret the sleep data.
Best AnswerHi @Gordon-C
I have went through the documentation. In the documentation there was a small example where the summary ends up with rem = 120 seconds with count = 2, light = 60 seconds with count = 1, and wake = 60 seconds with count = 1. My actual question was what if rem ends up with rem = 150 seconds, then how fitbit is rounding seconds into nearest minutes? I have seen sleep summary data where the total seconds count for a stage does not equates to full minutes. Please let me know if you need any additional information.
Best AnswerHi @Gordon-C
I have an additional question. As I was going through the interpreting sleep stage and short data document, one thing in the example I have found odd. The example was
"levels": {
"data": [
{
"dateTime": "20XX-XX-XXT01:43:30.000",
"level": "rem",
"seconds": 180
},
{
"dateTime": "20XX-XX-XXT01:46:30.000",
"level": "light",
"seconds": 60
},
],
"shortData": [
{
"dateTime": "20XX-XX-XXT01:44:30.000",
"level": "wake",
"seconds": 60
}
]So I assumed that the short wake period started at T01:44:30.000 and lasted for 60 seconds. So, according to me
First rem start: T01:43:30.000 --- T01:44:30.000 (60 seconds)
Wake start: T01:44:30.000 --- T01:45:30.000 (60 seconds)
Second rem start: T01:45:30.000 --- T01:46:30.000 (60 seconds)
However, in the documentation the breakdown is written like
{
"dateTime": "20XX-XX-XXT01:43:30.000",
"level": "rem",
"seconds": 90
},
{
"dateTime": "20XX-XX-XXT01:45:00.000",
"level": "wake",
"seconds": 60
}
{
"dateTime": "20XX-XX-XXT01:46:00.000",
"level": "rem",
"seconds": 30
},
{
"dateTime": "20XX-XX-XXT01:46:30.000",
"level": "light",
"seconds": 60
}I am sorry if its a silly question. I think I am missing something with the breakdown.
Best AnswerHi @Gordon-C it would be really helpful for us if you can explain the discrepancy on the document "interpret the sleep data" that I have mentioned in the above comment.
Best Answer
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
Let me see if I can clarify. There is no rounding of data. Instead, the short wake periods overlap the sleep stages in the "data" section and those short wake periods need to be factored into the main sleep stages data. So, you can't just add up the the values in the response to get the same summary totals, because the short wake period are not considered.
Looking at the example in the documentation
"levels": {
"data": [
{
"dateTime": "20XX-XX-XXT01:43:30.000",
"level": "rem",
"seconds": 180
},
{
"dateTime": "20XX-XX-XXT01:46:30.000",
"level": "light",
"seconds": 60
},
],
"shortData": [
{
"dateTime": "20XX-XX-XXT01:44:30.000",
"level": "wake",
"seconds": 60
}
]
The short wake period is in the middle of the rem sleep stage, and replaces 60 seconds of the rem stage. When you factor in the short wake, the rem stage is actually 120 seconds, or 180 (rem) - 60 (short wake). That's what the second example is trying to demonstrate when you include the short wake periods in with main sleep stages.
It does look like the timestamps in the second example is wrong, and I'll fix it. The second example should be
{
"dateTime": "2020-01-30T01:43:30.000",
"level": "rem",
"seconds": 60
},
{
"dateTime": "2020-01-30T01:44:30.000",
"level": "wake",
"seconds": 60
}
{
"dateTime": "2020-01-30T01:45:30.000",
"level": "rem",
"seconds": 60
},
{
"dateTime": "2020-01-30T01:46:30.000",
"level": "light",
"seconds": 60
}
Does that help?
Best Answer