11-23-2024, 06:10 AM
(This post was last modified: 11-23-2024, 06:29 AM by PjotterHasApn.)
Import Apple Sleep stages into OSCAR with this script
Sharing is caring, right?
I'm currently too busy to build it right into OSCAR, but here is the Python script to convert your Apple Watch hypnograms to Dreem headband files:
Apple2Dreem
You can import the result in OSCAR using
Data->Import Dreem Data
Try it if you understand how to use it, if you don't then probably leave it alone..
RE: Import Apple Sleep stages into OSCAR with this script
Wow - that is a WONDERFUL job you have done! This functionality has been needed for a long time. I have downloaded your excellent script and used it, but I do have some concerns:
1. The REAME on GitHub is really hard to follow. I assume it screwed up all the lovely formatting you had prepared it with - removing your own newlines and adding its own, somewhat at random! .....Ah, I just thought to download the "README.md" file and that one is formatted almost perfectly.
2. The Sleep Stage chart in OSCAR matches that in my iPhone perfectly - in places! Every night seems to start off well but then, at some point in the night where it rightly switches up to AWAKE mode, it just stays there for the rest of the night. Any idea what is causing this?
11-24-2024, 07:55 AM
(This post was last modified: 11-24-2024, 09:25 AM by PjotterHasApn.)
RE: Import Apple Sleep stages into OSCAR with this script
Thanks for the feedback.
Send the HealthAutoExport*.json to me, and a screenshot of your Apple hypnogram, then I’ll look at it. (You can PM me your email address).
By the way, each morning I manually add “Time in bed” to the sleep stats on my iPhone. For that start Health on your phone, then Sleep, then Add Data (in the upper right corner) -> In Bed
Since iOS 18.0 it isn’t added anymore automatically. I recommend to do this, since it is needed for proper sleep efficiency, Sleep latency onset etc.
(I’ll have a look at the readme later).
I also have scripts to create hypnograms of it. Which I will share also later.
Here is an example in which I compare PSG level EEG sleep staging (using OpenBCI+Yasa) with the Apple Watch Ultra.
11-26-2024, 01:41 AM
(This post was last modified: 11-26-2024, 01:43 AM by PjotterHasApn.)
RE: Import Apple Sleep stages into OSCAR with this script
@
BigWing As a follow up, since I haven’t heard from you yet:
For me it works perfectly for a while now. So I assume your HealthAutoExport*.json had the wrong information to begin with. Remember this script converts those files, so if they aren’t okay, than the output of my script will also not be okay.
RE: Import Apple Sleep stages into OSCAR with this script
Thanks for doing this, when I import the start time seems to be offset by around 4 hours ie should start at around 9pm but starts at 1 am - any ideas ?
11-29-2024, 01:26 AM
(This post was last modified: 11-29-2024, 01:28 AM by PjotterHasApn.)
RE: Import Apple Sleep stages into OSCAR with this script
Your welcome. Seems like a time zone issue. Can you send me your HealthAutoExport, screenshot of your hypnogram, and the Apple2Dreem.csv? Then I’ll look at it. You can send me your email address via PM if you like.
RE: Import Apple Sleep stages into OSCAR with this script
Thanks will do I’m based in Australia if that helps
RE: Import Apple Sleep stages into OSCAR with this script
This looks cool, I’m going to try this out soon.
Will it work for all sleep data from Apple Health, or only sleep data from an Apple Watch? I own an Apple Watch but don’t wear it while sleeping, but I do wear an Oura ring, which imports its sleep data into Apple Health.
11-30-2024, 03:42 PM
(This post was last modified: 11-30-2024, 04:30 PM by PjotterHasApn.)
RE: Import Apple Sleep stages into OSCAR with this script
I actually don’t know. Could work. It uses Apple Health. Please tell us after you’ve tried.
RE: Import Apple Sleep stages into OSCAR with this script
Since Dreem is no longer sold and the company went bankrupt - any idea what the best consumer eeg available is at the moment?