• Lucid Dreaming - Dream Views




    Results 1 to 12 of 12
    Like Tree6Likes
    • 3 Post By Venryx
    • 1 Post By Venryx
    • 1 Post By Venryx
    • 1 Post By Venryx

    Thread: Muse S headband (for REM-detection in custom LD-induction app)

    1. #1
      Member Achievements:
      Created Dream Journal 1000 Hall Points Referrer Bronze Made Friends on DV Veteran First Class
      Venryx's Avatar
      Join Date
      Dec 2012
      LD Count
      250+
      Gender
      Location
      Seattle, WA
      Posts
      358
      Likes
      173
      DJ Entries
      86

      Muse S headband (for REM-detection in custom LD-induction app)

      A few years ago, I made this thread about using the original Muse headband to detect REM-sleep and trigger sound/light effects: https://www.dreamviews.com/lucid-aid...etty-good.html

      However, I eventually stopped working on it, mainly because the original Muse headband was not very comfortable (or stable) to wear for extended periods (eg. overnight).

      Fast forward to the start of this year, and Muse has released a new device which is much more suitable for overnight use: the Muse S. (Commercial links aren't allowed, but you can find info on it by searching for "Muse S".)

      Excited by this new version, I purchased one, and have been working for a couple weeks on producing a system which can reliably detect REM-sleep from the device's EEG data.

      Here is my roadmap:
      1) I spent a good week or so researching the field of machine learning. This took longer than I expected, because there are tons of different machine-learning algorithms and approaches out there -- and having no experience in the field, it took a long time to find the appropriate ones to use for this use-case.
      2) I then spent a couple days recording raw EEG data of sessions with different eye-movement amounts (none, micro, and macro), and storing that data with those labels, for training the machine-learning model.
      3) I trained the machine-learning model, fiddling with its parameters until I seemed to be getting reliable matching between the model's predictions (for each raw eeg-data "session") and the sessions' labels/"targets". (with splitting between training and testing data, to mitigate over-fitting)
      4) I then spent some time getting the (outdated) Muse SDK to work with their latest Muse S device.
      5) To-do: Finish hooking up the live-streaming EEG data with the machine-learning model.
      6) To-do: Experiment with when and how to use the detected eye-movement to trigger the various alarms in my app (sound, wifi light, and bed-shaker alarm).
      7) To-do: Once I get things working nicely for me, clean up the app's user-interface, and get it all packaged and released on the Play store so others can also try it.

      So far, I've only been posting about my work on the French lucid dreaming forum "Attrape Songes", due to their having a more active geek/"hacker" subforum atm: Le coin des Geeks
      (early testing: [Test] SmartLucider banner)
      (mirror of this thread: here)

      However, today I've decided to start posting here on DreamViews as well, since it's getting close to the point where I'll be using it nightly to try to induce lucid dreams.

      Speaking of which, what is the general approach I'm going to try for lucid-dream inductions? Basically, my idea is to have eye-movements (for longer than a few seconds) gradually increase the intensity of various alarms. Eventually, the alarms will become intense enough to wake me (especially the bed-shaker alarm -- that one works quite well). However, the alarms are set to instantly stop as soon as the eye-movements stop.

      So the idea is that as soon as I awake, I'll stop moving my eyes -- causing instant alarm shutoff. And because I just noticed the alarms be disabled, I can know for sure that I had been dreaming just seconds earlier -- and at the start of REM -- so I'm then in the prime time to perform DEILD and/or WILD attempts. Because the turning off of the alarm was instant and automatic, the hope is that I'll still be close enough to the boundary of sleep, to relatively-easily slip back into the dream, with my awareness intact.

      I've heard of some people who have had success with this sort of approach, but I don't yet know how effective it is in general. But hopefully by using a commercially-available headset like this, we can have multiple people attempt it -- without having to rely on guesswork as to when the REM segments are occurring, as for some timer-based approaches in the past. (however, I wouldn't recommend buying the Muse S until I've done substantial testing with this approach myself -- as the device is fairly expensive and I don't want you wasting money until I can see if (and how much) it actually helps )

      As this gives a good summary of the project, I'll end this first post here -- filling in more details in the responses to come.

      Wish me luck!
      -Venryx

      P.S. By the way, shout-out to Sebastii for his email to me a few weeks ago! I wouldn't have started this project reboot (this early anyway) if he hadn't messaged me, prompting me to take a closer look at the Muse S, and reigniting my interest in the subject.
      Last edited by Venryx; 05-24-2020 at 05:41 PM.
      Sebastiii, fogelbise and Voldmer like this.

    2. #2
      Member
      Join Date
      Apr 2020
      LD Count
      5
      Gender
      Posts
      7
      Likes
      1
      Really great and thank you too
      You have an amazing idea and worth a big thanks.
      Good luck too and I will be present about your progress and all

    3. #3
      Dream Guide - DVA Teacher Achievements:
      Made lots of Friends on DV Tagger First Class Vivid Dream Journal Populated Wall 5000 Hall Points Veteran First Class
      fogelbise's Avatar
      Join Date
      Mar 2013
      LD Count
      1042sinceFeb'13
      Gender
      Location
      'Toto, I've a feeling we're not in Kansas anymore.'
      Posts
      2,414
      Likes
      2939
      DJ Entries
      180
      Good luck!

      Your planned DEILD approach with "auto off alarm" sounds promising.

      Does anyone know if LaBerge's REM detection mask also had a way to turn off the light flashes using a pre-arranged set of eyes movements you could do while still asleep and dreaming?

    4. #4
      Member Achievements:
      Created Dream Journal 1000 Hall Points Referrer Bronze Made Friends on DV Veteran First Class
      Venryx's Avatar
      Join Date
      Dec 2012
      LD Count
      250+
      Gender
      Location
      Seattle, WA
      Posts
      358
      Likes
      173
      DJ Entries
      86
      I've got step 5 completed, but the annoying "no edit past 24-hours" rule on DreamViews is preventing me from updating my original post.

      Anyway, I've got the live EEG data from the Muse headband streaming to my new app, which feeds it into the machine-learning model to pattern-match to the various eye-movement states (none, micro, macro).

      However, doing so I found that, while the ML model correctly detects between "none" and "macro", it does not currently do well for detecting "micro" eye movements.

      Here's a screenshot:


      The UI's pretty rough atm, but basically the white and gray lines are showing the raw EEG values, and the red, green, and blue are showing "how far the pattern is from matching" for each of the three eye-movement states.

      So where the red line is at 0, it means the model thinks the red "eye-movement: none" state is most likely, and where the blue line is at 0, it thinks the blue "eye-movement: macro" state is most likely.

      Though note:
      1) The eye-movement predicted/estimated states are delayed by a couple seconds due to the 3-second "window size" that the ML model/classifier uses.
      2) The graph only shows 1/10th of all EEG samples. The raw sample rate is 256 samples per second (per channel), but the UI only shows 25 (10%) of that. This is to keep performance acceptable for the visualization, and does not impact the detail level of data sent into the machine-learning model, since that runs on the Java side. (not sure if the bottleneck is in the rendering code or the Java->Javascript transmission; that said, the graphed detail is plenty enough for my current purposes, so I'm not gonna worry about it right now)

      Anyway, moving forward, this means that I need to do additional work to improve the machine-learning model. What's the main way you improve ML models? By feeding it a lot more data, in a wider variety of states.

      But how do you efficiently collect tons of EEG data in various states? Well, long-term I would like to enable users to fully train their own models, for cases where the built-in model (trained on me) does not translate well to their particular body or environment.

      So, I'm going to build a streamlined system by which you can just set the "labels" for a session within the Android app, then use the "volume up" and "volume down" side-keys to start and stop recording of EEG segments. These segments will then be uploaded to the database, which can then be sent to the machine-learning system to create a new model specifically for your own recorded data. (at first this'll require manual downloading and running of the Python machine-learning scripts, but it would be nice to eventually automate this in the cloud or something)

      Anyway, this will take a fair amount of work to set up and streamline, but once it's done I think it'll enable me in the future to "move quickly" whenever I want to improve or change the ML models, as well as making it possible for end-users to create personalized models that work best for their setup. And having segments started and stopped on one's phone, with simple physical-volume-key presses, enables users to record lots of segments without having to be near a particular computer (the one with the machine-learning scripts), and without having to even open their eyes (since you don't need to use the touchscreen).

      Anyway, next steps:
      1) Set up the UI and volume-key system for the "Training" page in the app.
      2) Add code to transmit those segments to the database.
      3) Add code to the desktop version of the app to transfer those segments into the machine-learning scripts. (to then be re-executed manually for now)
      4) Add more data, and tweak the model, until it can reliably detect the "micro eye movement" state. (it already does well for the current recorded data, but apparently that initial data was not varied enough)

    5. #5
      Lurker Achievements:
      1 year registered

      Join Date
      Dec 2018
      Posts
      1
      Likes
      0
      Thank you for these effort. When do you expect this app would release?

    6. #6
      Member Achievements:
      Created Dream Journal 1000 Hall Points Referrer Bronze Made Friends on DV Veteran First Class
      Venryx's Avatar
      Join Date
      Dec 2012
      LD Count
      250+
      Gender
      Location
      Seattle, WA
      Posts
      358
      Likes
      173
      DJ Entries
      86
      I'd guess a few months from now, as I suspect it will take time for me to experiment with (and fine-tune) till I find an approach that works well.

      By the way, sorry about the lack of updates. There were some distractions a week ago, and then the last few days, my motivation has been sapped due to a hardware issue with my Muse S (the wire to one of the sensors appears to have had a defect which has led to the sensor's signal greatly degrading; I'm in the process of attempting a warranty replacement).

      I'm still working on the app a bit, but until I get a fixed Muse S back, my work goes slowly. (it's hard to get oneself to work on the app if you can't actually use it at night)
      Sebastiii likes this.

    7. #7
      Member Achievements:
      Created Dream Journal 1000 Hall Points Referrer Bronze Made Friends on DV Veteran First Class
      Venryx's Avatar
      Join Date
      Dec 2012
      LD Count
      250+
      Gender
      Location
      Seattle, WA
      Posts
      358
      Likes
      173
      DJ Entries
      86
      My warranty/RMA request was accepted, and now I'm just waiting for the replacement.

      In the meantime, I've been working a bit on getting my infrared camera hooked up to my program for motion-detection recording, so that once I resume my Muse S experiment, I'll have the video data from each night to compare the data to. (for more efficient optimization and debugging)

      The motion-detection recording system is not quite complete yet, but I've gotten the camera-connection code working, the rendering of the data into the user-interface, and the processing to determine the pixel-delta/motion-level in each frame.

      Screenshot: (white line showing the pixel-delta/motion-level)
      Sebastiii likes this.

    8. #8
      Member
      Join Date
      Apr 2020
      LD Count
      5
      Gender
      Posts
      7
      Likes
      1
      This is a great job mate
      This look really nice

    9. #9
      Member Achievements:
      Created Dream Journal 1000 Hall Points Referrer Bronze Made Friends on DV Veteran First Class
      Venryx's Avatar
      Join Date
      Dec 2012
      LD Count
      250+
      Gender
      Location
      Seattle, WA
      Posts
      358
      Likes
      173
      DJ Entries
      86
      Still waiting for my Muse S warranty replacement, but I've gotten the first version of my motion-triggered recording system coded. Haven't yet used it for an actual night's sleep, so tonight will be my first attempt.

      It's worth noting that I'll probably hit some sort of issue during the night, since I haven't yet confirmed that the code is stable (eg. free of memory leaks) when running for hours, and because I've yet to put in place any sort of system for detecting and correcting disconnects between the ip-camera and my laptop.

      That said, it's still fun just to know a motion-recorder system is in place, and ready for my nightly testing, bug-fixing, and improving!

      The below is a screenshot of the UI for the first iteration: (well, half of it -- the camera ip, resolution, framerate, etc. settings are in another panel)

    10. #10
      Member Achievements:
      Created Dream Journal 1000 Hall Points Referrer Bronze Made Friends on DV Veteran First Class
      Venryx's Avatar
      Join Date
      Dec 2012
      LD Count
      250+
      Gender
      Location
      Seattle, WA
      Posts
      358
      Likes
      173
      DJ Entries
      86
      As I thought might happen, the program did indeed crash last night -- I'm assuming due to a memory leak somewhere. I've since cleaned up some areas of the code, and will give it another shot tonight.

    11. #11
      Member Achievements:
      Created Dream Journal 1000 Hall Points Referrer Bronze Made Friends on DV Veteran First Class
      Venryx's Avatar
      Join Date
      Dec 2012
      LD Count
      250+
      Gender
      Location
      Seattle, WA
      Posts
      358
      Likes
      173
      DJ Entries
      86
      My motion-recording system survives through the night now. It uses a lot of memory, but I've tamed the memory growth enough that it doesn't crash now at least. ^_^

      Note that there were actually three separate memory leaks in the program. Two of them I've fixed, but the last cannot really be fixed without ditching the browser api's used for video recording. (I'll probably do this eventually anyway, but I've sunk enough time into it, I'm content with it just working for now)

      Also, all three of the memory leaks were due to flaws in Chrome/Electron! More precisely, all three of the memory leaks were due to the building up of memory usage for objects that I removed all references (and functional connections) to (which means they should be getting garbage-collected). The objects involved were either never getting garbage-collected (eg. MediaRecorder instances), or were requiring a "shutdown" call beyond just removing all references (eg. MediaStream.tracks[*].stop()). So basically, the memory leaks were in the lower-level browser api's, but I managed to find some ways to "work round" the leaks enough that at least it no longer crashes.

      In other news, I've grown very impatient waiting for my Muse S replacement, so I've sent another email asking for the tracking number on the return. It has been two weeks now since my package to them was received, and not a peep since. :/ (I'm hoping it is just due to coronavirus under-staffing, or a mistake or something, rather than general sluggishness of their return service)

      Anyway, their email responses earlier were pretty quick, so hopefully I'll have an answer on Monday.
      Last edited by Venryx; 06-28-2020 at 06:57 AM.
      fogelbise likes this.

    12. #12
      Member Achievements:
      Created Dream Journal 1000 Hall Points Referrer Bronze Made Friends on DV Veteran First Class
      Venryx's Avatar
      Join Date
      Dec 2012
      LD Count
      250+
      Gender
      Location
      Seattle, WA
      Posts
      358
      Likes
      173
      DJ Entries
      86
      Indeed, they responded to my follow-up email quickly.

      Hi Stephen,

      Thank you for sending your old Muse back. Our sincere apologies for the delay on your replacement Muse S.

      We have created a shipment for your replacement Muse S. You should receive an automated confirmation email providing the order details, followed by another email with tracking information as soon as your replacement Muse ships from our warehouse. I have ensured this will be shipped using a FedEx 2-day shipment method.

      Please let me know if you have any questions.

      Enjoy your day!

      Best Regards,
      Lauren

    Similar Threads

    1. Replies: 24
      Last Post: 04-11-2019, 02:34 PM
    2. Replies: 3
      Last Post: 01-27-2019, 02:41 AM
    3. Non-Eye Movement REM detection
      By ethan_hines in forum Lucid Aids
      Replies: 1
      Last Post: 06-29-2009, 02:26 AM
    4. Electro-Magnetic detection
      By What is Real in forum Dream Control
      Replies: 2
      Last Post: 05-30-2008, 09:06 AM

    Bookmarks

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •