Josh Haas's Web Log

New toy… building a meditation feedback loop!

with 5 comments

I have a little side project right now, which is: use a brainwave monitoring device to make an automated meditation trainer.

I bought one of these:

NeuroSky Mindwave

NeuroSky Mindwave

It’s a Neurosky Mindwave — it sits on your forehead and reads your EEGs. Here are some really scary stock photos of people wearing it — I hope I don’t look like any of these guys!!

scary1 scary2 scary3

 

Anyway, it’s actually super comfortable to wear and, at least as far as I can tell, doesn’t give you creepy stock photo model staring syndrome.

The headset connects over bluetooth to either your laptop or your smartphone, and there are a number of apps you can buy that go along with it: games that you can control with your thoughts, various brain “training” apps, etc. My main interest is writing my own software for it, so although I experimented with some of the apps to see what’s out there and what’s possible, I’ve been mostly writing my own code in Python.

I’m interested in this from two angles: the technology itself, and applications to meditation. I’m interested in the technology because I think brain-computer interfaces are going to become a big deal in the next few decades, and there’s lots of exciting possibilities… if you can control computers directly with your mind, communicating them might become way more fluid than the relatively clumsy mediums of touch / typing / mice. And I’m interested in meditation; I’ve been practicing various forms of it off and on for the last eight years, and I think it’s a tremendously valuable tool for living a good and happy life. I might go more into why I care about meditation in a later post, but a really good resource for learning about it is Full Catastrophe Living by Jon Kabat-Zinn, who was one of the pioneers of using meditation in an evidence-based clinical setting.

Here’s the theory behind my project:

  • Meditation is a learnable skill that leads to specific outcomes (improved emotional control and mental clarity)
  • Like all learnable skills, the way to mastery is practice-with-feedback
  • Unlike most skills, it is hard for an expert to give feedback, since she can’t observe the pupil’s efforts directly
  • Therefore, meditation is uniquely challenging to learn
  • …and therefore, a mechanism that actually gives clear feedback could lead to a revolutionary increase of ease-of-learning!

So that’s the goal: make it orders-of-magnitude easier to become skilled at meditation. Right now, becoming good at meditation is quite hard; it takes a pretty big investment of willpower and time, there are a lot of dead ends, you have to be careful about what teachers you listen to, and you can go for years without really knowing if you’re making forward progress. I think this is sad, because I think meditation is a skill that would make the world profoundly better if more people had, so making it significantly easier to learn would be a big win!

Side note: I should acknowledge that I’m discussing meditation in a highly instrumental way — as a means for improving the quality of life / thinking. Arguably the entire practice of meditation is about not thinking instrumentally, but rather it being an end in itself. This is a larger discussion that I’ll save for some other time — suffice it to say that I know what I’m saying about the value of meditation might be construed by practitioners as totally missing the point… I agree and think the “end in itself” perspective is highly important to what meditation is, but for now let’s pretend that it’s valuable purely as a life-improvement tool.

Anyway, for my project to be successful, a few things have to be true:

  1. Meditation needs to be detectable via EEG patterns
  2. Those patterns need to be sufficiently course-grained that cheap consumer products like the Mindwave can pick them up
  3. The easiest path to generating those patterns needs to be genuine meditation

There’s a lot of research confirming point 1 — I don’t think that’s controversial. After playing with the Mindwave for a week, I’m fairly sure point 2 is true as well. Point 3 is more of a question — point 3 gets to whether or not you can fool the feedback mechanism. To be useful, I don’t think the feedback has to be perfect, but it can’t be systematically biasing you to some kind of mental activity that’s not meditation. Point 3 I’m less sure about and I’m not sure I’ll be able to tell until the experiment continues for a while.

My python script monitors the level of meditation using the proprietary “meditation” metric developed by the Mindwave people. The Mindwave reports a raw feed of eight different brainwave frequencies, and two derivative metrics, meditation and concentration. I don’t know what the sauce is that goes into the meditation metric… I could probably reverse engineer it by tracking how it compares over time to the eight raw inputs, but I haven’t gotten around to it yet.

For now, I’ve decided to go with the “meditation” metric on the grounds that reproducing Mindwave’s work would take a lot of time, so I might as well use their work on isolating “meditation” as a starting point. If I start to feel like it’s not quite right as a metric (ie, subjectively, through repeated meditation sessions, I feel like it’s giving me bad feedback), I may revisit this decision. For now, I feel like the feedback is pretty good, but I’m out of practice meditating so I’m still at pretty shallow levels… the real test is once I’m getting into deeper meditations whether the feedback still feels useful or if it feels off-track.

The way my python script works is that it plays a tone if the measured level of meditation is above a certain threshold. The tone gets louder the further above the threshold you are. Each time you run the script, you have a goal for the number of seconds above the threshold, and a time limit to do it in. The session ends when you hit the time goal or the time limit, and if you hit the time goal, it increases all three numbers — the time goal, the threshold, and the time limit for next time. It starts easy — you have a six minute time limit to meditate at a 40/100 level for at least two minutes — and it’s geared so that after 60 successful sessions, you have a 60 minute time limit, a 90/100 threshold, and 45 minute time goal. Ie, I roughly want it to take about three months (assuming you do one session a day and achieve the goal two thirds of the time) to develop an extremely deep daily meditation habit — which seems aggressive but achievable.

I’ve tweaked the formula a bit over the last week, but I now think it’s stable enough that I’m resetting myself to the first session and working my way through it. So far I’m enjoying it — it’s much easier for me to meditate regularly with feedback than it is when I’m just going for a preset amount of time or listening to a guided meditation. The real test will be if I’m able to keep achieving the increasingly-difficult goals, and whether that achievement corresponds with increasingly deep meditations.

The source code is a little messy right now, but if there’s interest in it I can clean it up and put it on github. I’m currently building on top of https://github.com/BarkleyUS/mindwave-python to communicate with the headset. (Technically, the hardest part of this whole thing was figuring out how to generate the variable sound tones… that’s a blog post for another day!)

I’m very interested in feedback from other people who are familiar with this problem space — has anyone tried to do something similar? What’s worked / what hasn’t worked?

Written by jphaas

October 14th, 2013 at 1:12 am

Posted in Uncategorized