Hello Guest, Welcome to Apnea Board !
As a guest, you are limited to certain areas of the board and there are some features you can't use.
To post a message, you must create a free account using a valid email address.

or Create an Account


New Posts   Today's Posts

Fitbit import to OSCAR
#1
Fitbit import to OSCAR
Hello everyone,

Let me share a little bit about myself first. My apnea treatment started with a blast, but after adjusting my settings I couldn't get as good sleep as during my first night with CPAP. Since my AHI was all ok, I started to look into O2 saturation monitoring.

I have tried O2 Ring, but after it's battery didn't last even 2h during my sleep I developed distrust on Viatom suppliers in my country. My doctor suggested that I don't need very accurate device right now, so I should take a look into some kind of fitband. That was exactly what I did and I find some youtube channel that suggested that fitbit has pretty accurate sleep phases detection. Since I couldn't find any data about SpO2 accuracy, this information along with ability to export data through Google Takeout made me buy Fitbit Inspire 3.

I have made an account here specifically to share with you my python script, that I have worked on last week to transform Fitbit data into Viatom SpO2+HR and Dreem sleep phases files. Now with all data in OSCAR I find it easier to adjust my CPAP settings. Maybe someone will find it useful, I have shared it on my gDrive: https://drive.google.com/file/d/12bb0a_nW6s0hrm2cIdUw5FuvZW-SLT17/view?usp=drive_link


Since I am a C++ programmer myself, would you accept change that adds Fitbit import directly in OSCAR? For my use it is easier to use script than OSCAR fork, but it there is a possibility that it would go into official release, then it is worth an effort Wink


Attached Files Thumbnail(s)
   
Post Reply Post Reply
#2
RE: Fitbit import to OSCAR
Hi ExtremeDeepSleep !  -  Welcome

The OSCAR Team is always looking for additions.  Please feel free to submit new code.  Since I don't have the administrative rights to add you as contributor to the code, please email or PM me regarding your submission.  The code is configured to compile with Qt v5.15.  

- Red
Crimson Nape
Apnea Board Moderator
Project Manager for OSCAR - Open Source CPAP Analysis Reporter
www.ApneaBoard.com
___________________________________
Useful Links -or- When All Else Fails:
The Guide to Understanding OSCAR
OSCAR Chart Organization
Attaching Images and Files on Apnea Board
Apnea Helpful Tips

INFORMATION ON APNEA BOARD FORUMS OR ON APNEABOARD.COM SHOULD NOT BE CONSIDERED AS MEDICAL ADVICE. ALWAYS SEEK THE ADVICE OF A PHYSICIAN BEFORE SEEKING TREATMENT FOR MEDICAL CONDITIONS, INCLUDING SLEEP APNEA. INFORMATION POSTED ON THE APNEA BOARD WEB SITE AND FORUMS ARE PERSONAL OPINION ONLY AND NOT NECESSARILY A STATEMENT OF FACT.
Post Reply Post Reply
#3
RE: Fitbit import to OSCAR
Thanks Red!
When I'll get something useful I'll let you know Smile
Post Reply Post Reply
#4
RE: Fitbit import to OSCAR
I have have a fitbit also.
How do you get the the chart data from the fitbit to the PC.
LoudSnorer
Post Reply Post Reply
#5
RE: Fitbit import to OSCAR
If you login to fitbit with google account, you can use https://takeout.google.com/ to export your raw data. Click "Deselect all" and check "Fitbit data" and you can download it or add to cloud (gDrive, Dropbox, OneDrive or Box). It says it could take hours, but for me it is usually 1-2 minutes if I only export Fitbit.

I am not sure how data is structured if downloaded from Fitbit account (but I think it is possible to download as well).


Once downloaded and extracted you can use script to convert data to Dreem CSV (sleep phases) and Viatom binary files (SpO2 and heart rate). You need to install python for that and execute script from console giving folder with data as and argument (it will be named like this: takeout-20240407T093621Z-001 and it will contain Takeout/Fitbit directory with data).

If you are on Windows you can have drag&drop and avoid executing from console. Use this scripts https ://drive.google.com/file/d/1o4Nv5Bs0HdBnmxVs9HLCdhuWAIBxBjeC/view?usp=sharing - archive contains two files: fitbit_convert.bat and fitbit_convert.py. Those two needs to be in same directory.
Now just drag takeout directory on fitbit_convert.bat and it should convert data for you. I attach screenshot of my output to give you a reference.


PS. In this new link I updated script to not use any additional python packages. Original script requires additional pytz package and installing it requires some technical knowledge.

PPS. Because of Viatom file format, script will not generate spo2 file if heart rate data is incomplete. I noticed that google attaches detailed heart rate data for each finished day, so your latest sleep will lack of heart rate data. Therefore only sleep phases will be visible for that day.


Attached Files Thumbnail(s)
   
Post Reply Post Reply
#6
RE: Fitbit import to OSCAR
Thanks for this script, it works well.
I did have to add an extra check for the export sleep function:
if (item["type"] != "stages"):
continue

Perhaps this is only a pixel watch feature, but it has other types of sleep records that are 'mainsleep=false', 'type=classic' and a different set of levels:

"data" : [{
"dateTime" : "2024-04-10T05:57:30.000",
"level" : "asleep",
"seconds" : 3660
},{
"dateTime" : "2024-04-10T06:58:30.000",
"level" : "awake",
"seconds" : 60
},{
"dateTime" : "2024-04-10T06:59:30.000",
"level" : "restless",
"seconds" : 120
},{
"dateTime" : "2024-04-10T07:01:30.000",
"level" : "asleep",
"seconds" : 180
},{
Post Reply Post Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  O2 import DST > ST 1:14am happened twice dgconder 5 217 11-03-2024, 08:55 PM
Last Post: dgconder
  Oscar Crash to desktop on SP02 import WallyPepper 7 656 11-01-2024, 09:36 PM
Last Post: Crimson Nape
  Trouble understanding how to import O2 ring info into Oscar katbrat 6 479 10-26-2024, 08:25 PM
Last Post: katbrat
  OSCAR: Questions regarding a potential import for Garmin data littleyoda 2 257 10-19-2024, 10:37 AM
Last Post: littleyoda
Idea Generic import to OSCAR? Oscer? I Ardly Know Er 1 411 10-19-2024, 03:48 AM
Last Post: littleyoda
  OSCAR SpO2 CSV import ST Dog 29 5,820 09-11-2024, 05:36 PM
Last Post: Toolworker
  Encore Basic Data Import juan8474 1 532 08-16-2024, 10:07 AM
Last Post: Irish7281


New Posts   Today's Posts


About Apnea Board

Apnea Board is an educational web site designed to empower Sleep Apnea patients.