skjerns / AutoSleepScorer

An open-source sleep stage classification Python package
GNU Affero General Public License v3.0
104 stars 22 forks source link

Consumer devices for recording requisite EDF file #5

Open mayeaux opened 6 years ago

mayeaux commented 6 years ago

Hi there, great project, I'm personally looking into whether any consumer electronics can create the EDF files that you would use in the algorithm, I have a Muse headband device and they seem to have all the requisite sensors but I'm not sure if access to raw data is available for anything but EEG. Any ideas on this front, thanks!

skjerns commented 6 years ago

@mayeaux theoretically no problem, technically currently not possible.

The data here is trained on different systems using different electrode positions. In theory it would be no problem to retrain data on Muse, but therefore you would need annotated data. Tweaking the network in a way to generalize to other input systems could also work, but would be a timely endeveour.

In practice I barely have time to develop the project further at all (unfortunately), it's stagnating at the moment.

mayeaux commented 6 years ago

Yeah, that's interesting, and thanks for the prompt response. I'm actually looking to do a little proof on whether yoga/meditation can mimic deep sleep brainwave patterns (which I have some preliminary data with using the Zeo headband).

Zeo has a really great algorithm for detecting sleep stages (which I'm guessing now based on your answer is created directly per the electrodes it has available) and shows me as being in deep sleep often during yoga, so my goldmine would be a general purpose open source algorithm for converting EEG data to a hypnogram, which as far as I can tell you're the closest to having created.

But don't worry I understand where you're coming from if you're too busy, I have lots of projects that are great but get paused because I have to move onto other things. I think I will just continue to use my Zeo in the meantime but since their company is now out of business and they don't have access to raw data, would be great if I could somehow pivot to using the Muse headband, I'll continue to think on it.

skjerns commented 6 years ago

Ah, the good old Zeo. Although it is a great device I would not base any assumptions on its output on non-sleep recordings. Algorithms are often very fragile and even slight differences in input can confuse the classifier.

For your interest I would recommend looking into the current research literature. There are indeed similarities between certain sleep stages and meditation, but the commonalities are not clear yer. Often an increased theta activation can be found while meditation [1], which is to some extend also found in REM, but also wake in general. On the other side an increase in (dorsolateral)-prefrontal activation has been reported after meditation practice [2]. This form of activation is not very common during sleep, except while lucid dreaming[3]. Others do also find increase in gamma and decrease in delta [4], which is exactly the opposite of what is happening during (deep) sleep.

PS: Why do you not have access to the RAW data? You just have to flash the decrypted firmware on it and then you can access the data RAW. Additionally you can also modify a USB cable that fits into the slot at the back of the ZEO and access data live via USB.

mayeaux commented 6 years ago

Thanks for pointing me towards this literature and I'll check it out. With my experience with using Zeo, I only found that I would get 'deep sleep' registered when I was doing restorative yoga (very relaxed positions, holding for longer periods) as opposed to meditation.

People often report higher energy levels after practicing yoga (or typically meditation as well), and essentially I'd like to ascertain whether there's some kind of physiological correlate between yoga/meditation and sleep, perhaps certain yoga practices can elicit a physiological state closer to deep sleep (if it's slow, restorative yoga), while other practices can elicit something more akin to light sleep or REM.

Also, there's a lot of literature to show that a yoga practice improves sleep across a variety of dimensions (sleep onset latency, sleep duration, decreased time to fall asleep during awakenings), so I think a strong medical case could be made for developing a yoga practice if it could be reasonably suggested that not only does yoga improve sleep outcomes after the practice, but that during the practice the body undergoes something physiologically similar to sleep as well. Anyways, those are my thoughts at the moment, I'm continuing to read some literature and think about my available options in the meantime, thanks for the informative responses!

skjerns commented 6 years ago

Just to add up on that: I don't think there are high similarities between deep sleep and Yoga. As said before, it's just an algorithm and it will misclassify your Yoga EEG to SWS, mainly because it has never seen 'Yoga-EEG' before. That yoga is good for sleep does not automatically mean that the activity during Yoga is similar to sleep activity. You would need to look at the RAW waves or the spectogram to look into more detail about that.