After a few nights of recording brainwaves from the MindWave and some advice from a cognitive scientist, I updated the plugin to also monitor the raw EEG data. I disabled the alpha, beta, delta, gamma and theta graphs by default, but they can be enabled from the plugin menu. I also added a first draft of the REM-detection algorithm – the audio track should now play after six blinks. And I renamed the plugin to ThinkGear EEG, as this covers both the MindSet, MindWave and ThinkGear compatible devices.
lucidcode
Lucid Scribe App lucid dreaming tools Lightened Dream journal for lucid dreamers Halographs dream detection devices Lucid Scribe biofeedback software Lucid Scribe Database open dream research Discord Server research & dev updatesPopular Posts
NeuroSky ThinkGear EEG 0.9.6 (53)
NeuroSky ThinkGear EEG 1.0.9 (35)
Lucid Scribe 1.3.7 (19)
Zeo 0.9.0 (19)
Categories
- Hacking (13)
- Security (3)
- Hardware (12)
- Halograph EEG (1)
- Halograph EOG (8)
- Halograph FM (1)
- Halovision INSPEC (4)
- Research (16)
- Software (279)
- Lightened Dream (28)
- Lucid Scribe (68)
- Lucid Scribe Android (9)
- FILD (4)
- Halovision (2)
- ThinkGear EEG (3)
- Lucid Scribe App (4)
- Lucid Scribe Plugins (173)
- BrainFlow (2)
- Emotiv EPOC (1)
- Halovision (47)
- Hypnodyne ZMax (1)
- InteraXon Muse EEG (6)
- Keyboard (3)
- LightStone IOM (12)
- lucidcode Halograph FM (6)
- Mattel Mindflex (5)
- Microphone (2)
- Milliseconds (3)
- Mouse FIELD (12)
- Muse (2)
- NeuroSky ThinkGear EEG (31)
- OCZ NIA (2)
- OpenBCI (2)
- OpenEEG (14)
- Ping (1)
- Pranayama (6)
- tACS (8)
- TCMP (8)
- tDCS (8)
- TI EZ430 Chronos (3)
- Zeo EEG (13)
- Lucid Scribe Plugouts (7)
- Arduino (1)
- Screen LED (1)
- Yocto PowerRelay (5)
- Hacking (13)
Hey my name is Pete and I am playing around with the Neurosky Mindwave to make some artworks. I use the Processing environment to use the data and have been only really working with the meditation and attention data and the alpha – gamma data as I am definitely no cognitive nor computer scientist. You mention that there is an REM algorithm you put into your software. Could you point me to any good resources so I can have a go at implementing these algorithms myself?
Many thanks,
Pete
Here is the source code: https://github.com/lucidcode/LucidScribe-ThinkGear-EEG/blob/master/ThinkGear%20EEG/PluginHandler.cs#L227-L334. It looks for a few blinks in a row, where the raw EEG value is above 800 for 1.2 seconds or less and then below 800 for between 2.8 and 8 seconds. You should be able to mimic it when running Lucid Scribe with the plugin and blinking your eyes. Download some of the logs from LSDBase and replay a minute where it played the audio track to get a better feel for the timing.
I’m trying to get REM detection to work with my TGAM. It works in general: Sometimes it detects a blink and the REM value rises. I can trigger it in waking state. But eye movements seem to be too low to trigger it. Instead it detects REM sometimes when I’m moving, also in sleep.
I’m wondering if it would help if I placed the electrodes differently, maybe directy left and right from the eyes, basically using it as an EOG. But I’d have to take my headband apart for this. So I’d like to ask first. What is the best electrode placement for this REM detection algorithm? Would it already help to have all electrodes or at least the ground electrode above the eyes/one eye instead of having ground and reference on the ear lobe?
It should work with the electrode(s) above the eyebrow(s) and the reference on the earlobe. If you look sharply to the left or the right while awake, without moving any muscles besides the eyeballs, it should count up the REM channel. And make sure the electrode contact is good, maybe use some conductive gel.
Thanks. I changed the position as you said. Now it doesn’t pick up movements as strongly as before, especially face movements (I can move my mouth without killing the signal for several seconds). I can now trigger REM detection more reliably while awake by blinking strongly. But eye movements are not enough to make it count up. I may take my MindFlex apart completely as a next step and try my own electrodes.
Great stuff. Try lowering the Threshold under Settings on COM port screen… Can you send me a screenshot of two strong blinks and then two sharp eye movements?
Sometimes the raw waves look very off and I don’t know why and how I can fix it. Kind of zoomed in in both dimensions, or 0 is shifted off the center. Three examples:



I can’t really show you how the spikes from blinking look when the waves are stretched like this. Sometimes it’s good or gets better after diabling and enabling channels or after restarting LS several times. But right now I don’t seem to have any luck with that.
The threshold setting has no effect. I’ve tried 600, 500 and 200, but Audio and Arduino always trigger at 900 (when they are enabled). And I noticed it always skips 700 and 800. It goes up 100 each time, and then from 600 streight to 900.
Try moving the slider on the current view to the left so that it only shows 10 seconds of data at a time… Moving the slider also zooms the data. Instead of restarting, you should get the same effect by just moving the slider a tick or two.
Enable the NeuroSky EEG channel – whenever it goes over the threshold, the REM should climb a step. When it has climbed six stairs (600) it jumps to (900) and triggers the plug-outs.
> Try moving the slider […]
Thanks. That helps in many cases, but not always. In the case of the following screenshots it was more off before I moved the slide. But it’s still shifted afterwards.
> When it has climbed six stairs (600) it jumps to (900) and triggers the plug-outs.
That’s right. But it does the same no matter what threshold I choose
2 blink examples:


2 eye movement examples:


For these I looked up. All other directions are not visible in the graph.
I’m still trying different electrode placements (one cm to the left or right makes a big difference) but this is the best I got so far regarding eye movements. One is above the right eye, the other above and slightly left of the right eye.
But no matter where exactly I will place them, REM detection would still trigger from body movement, wouldn’t it? The only trigger that happened last night was clearly when I changed sleeping position.
Can you try again with the NeuroSky EEG channel enabled and the slider at about 20%?
Sure. Thank you for looking into it.
Now you got it… just set the threshold to 450 and remain perfectly still, asleep even.
Thanks. Now I understand what the threshold means.
I thought of this before, but the fact that I misunderstood the threshold setting made me sure that Lucid Scribe needs (better) documentation. Are there any plans on that?
I’ve started something in an etherpad. I don’t have as much time to work on this as I want this year. So I’m just linking it as it is: http://pad.steeph.de/p/Lucid_Scribe
If you think it’s a good idea maybe you could post about it and others could help.
Elite. I have posted about it. Dankeschön!
Are you able to trigger it with just eye movements when the threshold is set to 450?
No, it didn’t work so far. But I want to test more, try different electrode placements, before I’ll say it doesn’t work. I think I’ll take some time next week for this.
Have you had another chance try it out with the lowered threshold value? Feel free to send me some logs and I will see if I can find anything in them.
Sorry, I have too much going on right now. I did try it, with no success so far. I will try again next year when I have more time. But so far it looks to me that body movement is always more likely to trigger REM detection than eye movement. Did you never have this problem? Maybe this could be prevented by turning REM detection off for a minute when very strong changes in the signal is detected. (The type that flatlines the signal for a few seconds.)
No worries. Thanks for your patience and persistence. I haven’t slept with the MindWave in a long time, but I have had this problem and have some code that should reset the eye movement count if the signal is above the threshold for 1.2 seconds (12 ticks), or below for 2.8 seconds. I just noticed that the ThinkGear EEG plugin was still using the hard-coded threshold of 800 – I have fixed it to use the configured value. Let me know if it works better next year, otherwise send me a screenshot or log where it flatlines and I will code in an exception for it.
That sounds great, thanks.