Close
0%
0%

Train Your Brain with NeuroFeedback

Brain hacking!!! Improve your focus and concentration by training your brain using NeuroFeedback.

Similar projects worth following
The goal of this project, is to provide an inexpensive Neurofeedback device and software platform to make it easier for others to experiment with and use this expanding technology.
A major barrier to many who could benefit from Neurofeedback is the cost of therapy. Sessions for Neurofeedback generally cost, in the neighborhood of, $100 each. In general, 10 sessions are needed to see if it is effective.
Thankfully it is now possible to capture and record EEG data using inexpensive hardware available in some toys, games and wearable's. The hardware parts from these devices are fairly easy to adapt to make a single channel EEG sensor that sends data over Bluetooth.

Goal:

  • Develop an inexpensive hardware and software platform to make Neurofeedback accessible to all that need or could benefit from it.
  • Make this platform completely Open Source. Develop Java application that is usable in multiple environments.
  • Make it as open as possible in terms of hardware. The central EEG processing board is the TGAM1 board made by Neurosky and is the only piece of proprietary hardware used in this project. These boards are easily salvaged from children's gamest (last I checked they aren't available from Neurosky except in commercial quantities.

This project has taken a number of different turns and dead ends, but is currently progressing quite well. Hardware is all done, java application is taking a bit longer (due to having to learn java - which I am doing).

Quick Links

  • Configuring Serial Bluetooth Board

thinkgear_connector_development_guide.pdf

Adobe Portable Document Format - 331.64 kB - 06/05/2016 at 04:01

Preview

ThinkGearSerialStreamGuide.pdf

Adobe Portable Document Format - 195.25 kB - 06/05/2016 at 04:01

Preview

TGAM Datasheet.pdf

Single channel EEG module.

Adobe Portable Document Format - 4.33 MB - 06/05/2016 at 03:59

Preview

TrainYourBrain-Enclosures - PowerModuleTop.stl

Top/cover of power module

sla - 138.66 kB - 05/21/2016 at 03:07

Download

TrainYourBrain-Enclosures - PowerModuleBody.stl

Power Module enclosure - holds: 3xAAA batteries, LDO 3.3v Regulator with filter caps, indicator LED, SPDT slide switch, space for cable going out to SenseTransmit Module (ending in mono male jack)

sla - 107.50 kB - 05/21/2016 at 03:07

Download

View all 7 files

  • 1 × TGAM1 board main board from Mindwave Trainer
  • 1 × Bluetooth Breakout Board (HC-06) Slave HC-05 Bluetooth board on backplane
  • 1 × Bluetooth USB connector (not needed if already present) needs to support Seriasl Profile
  • 1 × 10k 1/8watt resistor
  • 1 × 0.1" 90 degree header pins (1 row of 4)

View all 10 components

  • Configuring the TGAM1 Board for 57600 baud (raw data)

    Tom Meehan10/03/2016 at 04:12 0 comments

    Need .png of top of board with white background

    Configuring the TGAM1 board for raw EEG data (57600 baud) - using the Hardware method

    • The default output baud rate for TGAM1 boards (at least the ones taken out of Mindflex and Force Trainer headsets) is 9600 baud (this only allows you to capture data for the default frequency bands once per second).
    • To use these cheap headsets with apps made to work with "Think Gear" headsets - we need to change the communication rate to 57600 baud. There are 2 methods to achieve this:
      1. One way involves programming the TGAM1 board over Bluetooth - if you look through the links at the end of this post you'll find ways of doing this. I did not do it this way, instead I chose the second method.
      2. The second way involves removing a single SMD (surface mount) resistor (pull-down resistor) and adding a different resistor going from the same area and then over to positive connection of the power supply on the TGAM1 board (pull-up resistor).
        • To do this you'll only need:
          1. Basic soldering iron
          2. 1 x 10k 1/8th watt resistor
          3. Heat shrink tubing to insulate the resistor
    • Step 1: Remove SMD Resistor (surface mount resistor, it a little rectangle on the top of the board.
      • The SMD resistor can be removed by heating up the pad with a soldering iron and pulling it off with tweezers (or, if you are brave - snap it off with needle nose pliers).
    • Step 2 - Solder in the 10k through hole -(meaning is has wires) resistor.
      • the 10k resistor goes from the spot marked B1 on the board and goes over to the positive power connection (refer to the labeled picture at the top of this post)

  • Configuring the HC-06 Bluetooth Serial Module

    Tom Meehan10/03/2016 at 04:06 2 comments

    Some REALLY BASIC! Background on Bluetooth Communication

    Being very, very new to working with Bluetooth, myself, I decided to include some additional information so that others can hopefully avoid making the same mistakes that I've made:

    Slave vs Master
    • Master is the device at the center of a Bluetooth network (in this case – your phone, tablet or computer)
      • a Master can pair with multiple Slave devices
    • Slaves send and receive data only to or from the Master (in this case – the MindFlex headset, you could, conceivably, pair multiple headsets to one Master device)
      • a Slave can only be paired to 1 Master at a time

    Pairing

    • Bonds Slave device to Master device
    • After pairing devices automatically connect when they are both powered on and close enough
      • uses authentication data saved on the 2 devices

    Profiles (devices need to support the same profile to communicate - "communication profiles") – this is not an exhaustive list

    • HSP -head set profile
    • HFP – hands free profile
    • HID – human interface device (generally a keyboard, mouse, etc.)
    • SPP – serial port profile (this is what we need for communication)
    • A2DP – advanced audio distribution profile (streaming audio data to speakers, etc)
    • AVRCP – A/V remote control profile (Bluetooth remote for TV, etc.)

    - A little note on profiles and their importance: I have an older android smartphone (Bluetooth and WiFi capable), an IPhone 5 and a Kindle Fire. It turns out that none of them support the Bluetooth Serial Port Profile and as a result the only way I can use the Bluetooth connection is with my laptop and a Bluetooth USB dongle. So, if you are planning to use this with a specific device make sure to check if it supports SPP (Serial Port Profile) Bluetooth Profile. If your device does not Bluetooth SPP (turned out that none of the devices I have support it) then you'll need a USB Bluetooth dongle that supports SPP (around $5).

    Bluetooth Modules (again: really basic!)

    Be sure to ca

    • The first modules I purchased were actually just back planes (essentially just the breakout board without the module – read descriptions very carefully – not a costly mistake but annoying and time consuming).
    • The next module was a Master – (projects I looked at never seemed to mention if I needed a Master or Slave module... well it turns out I needed a Slave module, of cour.
    • Slave Module!
    AT Commands

    You can find these on the datasheets for the Bluetooth Serial Modules (you can find them online - none of the ones I ordered included the datasheet). AT commands apply to both the HC-05 and HC-06 boards. These are the ones we need to setup the HC-06 breakout:

    • AT pings the device (response back “OK”over serial)
    • AT+PINxxx
    • AT+NAMExxx
    • AT+BAUD4 (sets baudrate to 9600 – default rate)
    • AT+BAUD7 (sets baudrate to 57600)

    Setting up the HC-06 Bluetooth Slave Module (SPP – Serial Port Profile)

    Configuring the Bluetooth Slave Module for 57600 baud rate (most modules seem to be configured for 9600 baud rate as the default setting) **This step should be done with the Bluetooth Module alone (not connected to the TGAM1 board)**

    Wiring the HC-06 and configuring using an Arduino

    • The logic level shifter is not optional - these modules use 3.3v logic (RX/TX lines must be 3.3v)

    Bluetooth TX goes thru level shifter to Arduino TX (Pin 3). Bluetooth RX goes thru level shifter to Arduino RX (Pin 4).

    Arduino Code:

    /*
    HC-06 Bluetooth simple setup sketch
    
    *** Important. If you change the HC-06 baud rate, you must change the "myserial" baud to match what was just set. 
    * Steps:
    
    Changing default 9600 baud to 57600 baud needed to communicate raw data from TGAM1 chip
    1) uncomment (remove the double backslash) the line:  //btSerial.begin(9600); 
    2) uncomment the line:  //btSerial.print("AT+BAUD7"); // Set baudrate to 57600
    3) run the sketch.  This will set the baud to 57600.  However, you may not see the response OK. 
    4) comment out (add double backslash back) the line btSerial.begin(9600);
    ...
    Read more »

  • Converting a Mindflex to a MindWaveMobile Headset

    Tom Meehan10/03/2016 at 02:07 2 comments

    This basically involves adding a Bluetooth serial transmitter (and configuring it) to the Mindflex Headset and changing some components on the TGAM1 board (the board that acquires the EEG data).

    This ended up being a bit of an adventure – even after a good deal of research (reading datasheet's very carefully) and reviewing other peoples tutorials of similar hacks. In the end, it took about a week of part time research on components, Bluetooth (profiles, module boards, communication protocols), TGAM1 board (communication protocols, identifying board connection points, hardware settings etc.). Presently, I have a fully functional headset that is recognized by Neurosky's MindWaveMobile software as a MindWave Mobile Headset.

    Hardware:
    • Mindflex Headset ($10-20 on ebay)
    • HC-06 Bluetooth Slave Module (that communicates with Serial Port Profile (SPP))
      • these are between $5-10 on Amazon or Ebay (cheaper in quantity, or if you are willing to wait, from China)
      • should be able to use an HC-05 also (connections and configurations a little different – HC-05 can be configured either as a Master or a Slave module – unlike HC-06 which is only one or the other)
      • I'm a noob concerning Bluetooth: protocols, host modes, etc.
    • 10k resistor (pull up to set TGAM board to 57600 baud, ¼ or 1/8 watt)
    • Hookup wire
    Tools:
    • Soldering iron (and solder, of course)
    • Multi-Tester/VOMeter (non-essential - mainly to verify connections)
    • Magnifier (non-essential - to see TGAM1 board pins and labels clearly)
    • 5V to 3.3V Level Shifter (essential if using an Arduino board to set up the Bluetooth module, non-essential otherwise)
    • Arduino Board with USB connection
      • Software Serial sketch
        • This is what I ended up using and it worked fine – though you do need to upload the sketch a few times:
          • Change baud rate of module
            • change software serial baud rate – reload
            • etc.

    Here are a couple of screen shots of the headset working with a couple of applications:

    Next up -

    1. Setting up TGAM1 board for raw data communication.
    2. How to Set Up Bluetooth Board to transmit.
    3. Connecting HC-06 Bluetooth board to the TGAM1 Board.

  • Neurofeedback References

    Tom Meehan09/14/2016 at 05:04 0 comments

    Direct links to full text when possible, pubmed link, web link, or at least citation.

  • A functioning JavaFX Media Player - FINALLY

    Tom Meehan09/14/2016 at 05:01 0 comments

    Java coding has been difficult for me but after working with MPLABX to develop code for PIC micro-controllers (MPLABX is built on Netbeans - just like the Arduino IDE was developed from Processing). Anyway, all the trials I've had in PIC programming have paid off for me in understanding Java coding using the NetBeans IDE. As a result, in just a morning of work I finally got a basic video player functional using JavaFX in NetBeans.

    Fairly simple code, I'll post it up in the morning tomorrow.

  • Continuing Java NeuroFeedback Development

    Tom Meehan09/11/2016 at 01:49 0 comments

    I've been digging into existing code for parsing the serial data from the TGAM1 board, mainly the open source Brainflex Project, instead of the ThinkGear Connector from Neurosky. A more direct link to the download release page: BrainFlex02 (I'm using the research release).

    After having issues with the compiled .jar file (Brainflex001.jar) – not connecting to headset – I decided to build the .jar file for Brainflex02 (the research release). I've been working a lot with the NetBeans IDE, for this project and with Microchips MPLABX, which is built on the NetBeans IDE. Even so, I am still learning all the little in's and out's needed to effectively use it.

    To build an executable .jar file from the source code using NetBeans: After opening NetBeans I clicked File → New Project and selected Java → JavaApplication. I named the project “BrainFlex2Build”. After creating the project I imported the unzipped files from the github repository, that I downloaded.

    After importing the source files I immediately saw errors flagged, even before building the project. I still attempted to build the project, just so that I could see what the specific errors were. The build errors turned out to be the result of missing libraries – specifically the jSSC (Java Simple Serial Connector) library and the Apache.org Math3 library. I was able to find both of these with a simple search but couldn't figure out how to add them to NetBeans so that the functions would be included in the build. Lucky for me I came across the following article, including videos, by Andr.oid Eric: Prepare jSSC download and add library



    While there is no voice over on these videos, they are short and quite clear as to how to add libraries to NetBeans and added the libraries to the properties of the project file (so they are included in the compiled code).

    Quick comment: Switching from a plain dry electrode (the one on the MindFlex headset) to a 'wet' electrode (using conductive electrode paste) definitely improves the signal. I am curious: does using 'wet' electrodes allow from longer electrode cables?

  • Software Development Slow But Promising

    Tom Meehan07/18/2016 at 06:41 0 comments

    Hardware development has been pretty straightforward - everything is working perfectly on that front.

    Software development is a bit slower due to having to learn Java programming. I am steadily learning it by working on it every day. Also, I've got the logic for the base program clearly worked out.

    I don't have much to post but the project is far from dead or abandoned - I'm determined to finish the basic software platform so that is is usable and expansible.

  • Everything keeps changing...

    Tom Meehan06/07/2016 at 04:48 0 comments

    My initial hardware design involved pulling the TGAM1 board out of the MindFlex Headset, placing it in a separate enclosure with a Bluetooth transmitter and using a separate power supply (with batteries and voltage regulator). While this was ended up being perfectly functional, I found there were other issues – mainly the reach for the EEG electrode. The lead wire is limited to a max length of 12” (according to the data-sheet for the TGAM1 board – the original lead wire was only about 3” long with a fixed electrode). With a max length of 12 inches, the TGAM1 board needs to be fairly close to the the head to allow the EEG electrode to reach most of the scalp.

    The main limitations I see with the MindFlex headset are:

    1. Electrode placement is fixed. (No choice on placement)
    2. Comfort, EEG electrode contact uncomfortable after short period of time.
    3. Poor conduction, EEG electrode is just metal to skin contact (simple dry electrode) – no electrolyte used to improve signal conduction and no adhesive used to ensure good contact.

    Electrode Specs (per the TGAM1 Datasheet, page 3):

    • Maximum surface area of ~150mm2 (but less surface area is optimal)
    • Ag/AgCl, Stainless Steel, Gold, or/and Silver (both solid and plated material works)
    • EEG electrode located above the left or right eye on the forehead
    • Ground and reference electrodes located behind the ear or at the earlobe
    • Have enough pressure to prevent movement, with a minimum of 0.8 PSI
    • Length of less than 12 inches, the longer the higher the susceptibility to noise
    • Shielding (not necessary for the ground)
    • Thinner than AWG28

    For the purposes of prototyping this project I decided to go back to using the MindFlex headset and fitting it with a different electrode and lead wire. I've finished fabricating a new electrode out of some thin stainless steel sheet metal, heat shrink tubing, 0.1” Dupont female crimp connector, and shielded 28AWG lead wire (just under 12 inches). I pulled out the original electrode, in the headstrap, and removed the lead connected to the TGAM1 board. Following that I soldered my new shielded cable to the board and then drilled a 1/8th inch hole in the MindFlex headset for the EEG lead wire to exit the headset.


    My, newly fabricated, test electrode is a 10mm diameter disk (surface area of 78.5mm2 – well under the max of 150mm2). Testing of the new electrode went fine (good signal conduction). In addition, I just ordered some Ten20 electrode paste (conductive adhesive to attach electrode to scalp and provide better signal conduction).


    I may attempt to fabricate some 10mm cup electrodes from some 416 stainless steel bar stock that I have (left over from another project).

    I continue to inch my way along, teaching myself Java coding. Learning Java is my most challenging part of this project.

  • Designing and Coding Video Player for Neurofeedback

    Tom Meehan05/25/2016 at 06:11 0 comments

    Switching to using JavaFX to design video/media player. Still learning Java and how to use JavaFX Scene Builder but finally making some good progress. initially I was using Eclipse to write and debug code but finally switched to NetBeans (mainly because there is more tutorials and documentation available). Also using the code in the Brainflex project on GitHub to understand how to parse the serial data coming from the EEG signal.

  • Brainflex Up and Working

    Tom Meehan05/04/2016 at 19:12 0 comments

    I found that while I had updated my Java SDK and JRE my actual version of Java wasn't updated and my system was cluttered with 3 different versions. After taking off the old versions of Java and loading the newest one Brainflex.jar now functions perfectly.

    Now I just need to dig into the source code so that I see how to capture the data and perform a bit of math on it.

    I'm still trying to get VLCJ Player to function - will try rebuilding the .jar file.

View all 14 project logs

  • 1
    Step 1

    Add resistor to TGAM1 board to set it for higher speed communication

    Need pictures and possibly video of this

  • 2
    Step 2

    Program Bluetooth HC-06 breakout board

    Need:

    • Arduino Uno (or Nano)
    • 5v - 3v level shifter
    • Sketch (to set up Bluetooth)
  • 3
    Step 3

    Connect Bluetooth HC-06 to TGAM1 board

    Pictures, illustration, video

View all 3 instructions

Enjoy this project?

Share

Discussions

penco193 wrote 11/25/2016 at 13:35 point

Hi!. i just developed a code for a Photon device from Particle to register
the raw values from mindflex @57600 (based on TGAM1 - rev2.7) and after
sending the command byte for configuring the 0x02 mode, i started receiving raw data packets
correctly, but after 2 packets, it starts giving checksum errrors
and eveything goes wrong ... as you can see on the following portion of
the log file i recorded:


latestByte: AA
PacketLength: 4
latestByte: 80
latestByte: 2
latestByte: 3
latestByte: 80
latestByte: AA
ERROR: Checksum: 170 250[128, 2, 3, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,...

Do you know where the problem can be? ... i've not using any optoacoplator
between mindflex and the Photon device. Thanks a lot for your help.

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates