Charles Moyes (cwm55) and Mengxiang Jiang (mj294)        Cornell University ECE 4760 Final Project:       Brain-Computer I...
an instrumentation amplifier and Besselworth filter IC from Maxim IC and cheap op amps that we will usefor this project. A p...
Tentative Parts ListA tentative parts list follows:For Each Analog EEG Channel:                                   Part    ...
users will never be allowed to touch any other electrical devices while wearing the EEG helmet. We will takesafety very se...
Opto-isolated UART Serial     As mandated by our safety procedures, we will electrically isolate the UART from the USB. Th...
21   {         AinLow = ( int ) ADCL ;23       Ain = ( int ) ADCH *256;         Ain = Ain + AinLow ;25         fprintf ( s...
Upcoming SlideShare
Loading in …5
×

Ece4760 hw5

596 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
596
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
6
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Ece4760 hw5

  1. 1. Charles Moyes (cwm55) and Mengxiang Jiang (mj294) Cornell University ECE 4760 Final Project: Brain-Computer Interface using Multi-Channel ElectroencephalographyProject OverviewThe goal of the project is to build a multi-channel electroencephalography (EEG) Brain-Computer Inter-face (BCI). At a high level, the project will record and collect EEG data from the user using electrodesattached to the patient’s scalp. The data will then be processed by a machine learning algorithm such asa feed-forward artificial neural network (ANN) which will attempt to classify the data. We plan on eithertrying to discover which color the user is thinking of or allowing the user to control a mouse pointer usingtheir thoughts. Because of the nature of the machine learning algorithms we will be using, an initial trainingperiod will be required where the user is prompted to “think of” or “imagine” colors and mouse movementdirections. The EEG data corresponding to the user’s thoughts will then be used to train the neural networkvia the back-propagation method. From there, the user will be able to control the system using their mind: Because we feel that this project is fairly ambitious, there will be several “checkpoints” or stoppingpoints, in case we run out of time or encounter difficulties. The first goal will be to collect EEG data fromthe user using the microcontroller’s analog-to-digital (ADC) converter. The analog circuitry involved willconsist of a three-stage amplification circuit with an instrumentation amplifier, an operation amplifier, anda filter. The filter will consist of a high-pass filter with a cut-off frequency very close to zero to remove DCoffsets from the signal, along with a low-pass filter with a cut-off frequency of around 60 Hz for anti-aliasingand possibly a 60 Hz notch filter to remove AC power noise induced in the user’s body. We ordered low-costEEG electrodes from a Chinese medical supply company on eBay for around $20, but we may resort tohome-made electrodes constructed from metal guitar picks borrowed from a friend who is a musician and anold baseball cap if the budget does not permit us to use the medical-grade electrodes. Another note is thata so-called “right-leg driver” connected to the user’s right leg will be necessary to cancel out common-modenoise from the user’s body. This driver will be connected to the instrumentation amplifier to take advantageof its common-mode rejection functionality. The main challenge will be amplifying a signal from the user’sscalp on the order of microvolts, while filtering out the vast sources of noise. This data could then be presented on a graphical pixel LCD attached to the microcontroller, or it couldbe transmitted to a computer over USB serial UART. However, for now we will be content with merelycollecting the EEG data from the user and sending it to MATLAB over UART. This will require some Ccode to be written for the microcontroller that will read the ADC input, format the data in Modular EEGpacket format, and send it to the PC over the serial port. Once we have a working EEG (this is one “check-point”), we would like to add as many channels (up to 16, ideally) as our budget permits. We have found 1
  2. 2. an instrumentation amplifier and Besselworth filter IC from Maxim IC and cheap op amps that we will usefor this project. A possible time-permitting feature is the addition of a Bluetooth system-on-chip wirelesstransceiver (TI has one that we could sample). This would allow the user to control their smartphone orBluetooth-enabled laptop using the BCI, but it would also impact our budget significantly. The next checkpoint would be processing the collected data. We have had significant coursework inartificial intelligence (AI) and have been studying papers on diagnosing sleep apnea and processing EEGdata in the context of brain-computer interfaces throughout the semester. We cannot guarantee good resultswith the latter since we have not done anything like it before, so if we are unable to obtain good results,then we will merely determine the patient’s level of emotional arousal based on the EEG waveforms usingtheir frequency spectra. An example follows: However, we would definitely like to take time to experiment, namely with ANN’s so that we can attemptto classify the user’s thoughts based on their brainwaves. Another simpler possibility would be detectingEEG arousals in users that have sleep apnea. This is fairly simple to do given that one has a real-time EEGdata source, and the details have been outlined in several IEEE papers. The goal would be to have a userthink of a color (e.g. red, blue, or green) and then have the ANN classify which color the user is thinking offrom the received EEG data. Yet another possibility is having them thinking of cardinal movement directionsand then using the EEG data to move the mouse pointer. We feel that this is significantly more advanced,however, than the color-detection process. At this point, we would be very satisfied with our project and wewould be more than happy to call it complete.Relevant StandardsWe will follow the Modular EEG serial packet standard for transmitting EEG data over UART. Moreover,serial communications will follow the RS232/USB standards. Another consideration is the IEC601 standard.IEC601 is a medical safety standard for medical devices that ensures that they are safe for patient use.Unfortunately, testing for IEC601 compliance is very much out-of-budget. Nevertheless, we discuss themany safety considerations that we will absolutely adhere by in the Societal Impact of Project sectionof this write-up. If we opt to use Bluetooth as a wireless communication interface for this project, we willuse the Texas Instruments CC2560 single-chip Bluetooth IC, which complies with FCC standards. 2
  3. 3. Tentative Parts ListA tentative parts list follows:For Each Analog EEG Channel: Part Cost MAX4194 - instrumentation amplifier IC SAMPLE MAX7401 - 8th order Bessel filter IC SAMPLE AD8605 - op amp IC SAMPLE TL062CP - op amp IC 2*$0.26/channel (Digikey) Filter capacitors and resistors LAB/CHEAP 2K Potentiometer LAB/CHEAP 4x NPN and PNP transistors LAB/CHEAPEEG electrodes: Part Cost CONTEC ten pcs silver plated electrodes (budget-permitting) $20 (eBay) OR OR Metal Guitar Picks and Headband ALREADY OWNRS232 isolation: Part Cost 6N137 optoisolator (or equivalent) 2*$1.55 (1 if only using TX) (Digikey) 2x NPN transistors LAB/CHEAPUnavoidable Lab Costs Incurred: Part Cost White Board OR Solder Board (Time-Permitting) $6 OR $2.50 4x AA Batteries ALREADY OWN 4 AA Battery Holder $1.33 (Digikey) Mega644 Microcontroller $8 SIP Header Sockets/DIP sockets To Be Determined (TBD) AT Mega 644 Target Board LABExtra features: Part Cost Graphical LCD (budget-permitting) $15 (SparkFun) CC2560 - TI Single-Chip Bluetooth SAMPLE (time-permitting)Societal Impact of Project/Safety FeaturesBecause this is a device attached to a patient’s brain, safety is our utmost priority. The microcontrollerwill only be powered by four 1.5V AA batteries, rather than through an AC power supply connected tomains. Moreover, serial communication to a PC over USB will be isolated from the USB using optocouplers,which we will test extensively to ensure that both ground loops are separated. Only laptops running off ofbattery power supplies (no AC adapters connected) will ever be connected to the microcontroller over USB.As a corollary, the microcontroller will never be connected to a user’s head while the programmer cable isconnected to a PC. Lastly, the EEG circuitry itself will have transistors connected directly to the electrodes(in between the electrodes and the analog circuitry) to act as a user current/ESD protection mechanism.We promise that 120 VAC power will never be connected to this project directly or indirectly. As a result, 3
  4. 4. users will never be allowed to touch any other electrical devices while wearing the EEG helmet. We will takesafety very seriously throughout the development of the project. This project will have great societal impact because it is designed for users with special needs. Usingbrain-computer interfaces, users with special needs will be able to interact in computers in ways that werenot previously possible. Patients with sleep apnea will be able to collect and analyze their own EEG datawhile asleep without having to participate in expensive overnight sleep studies at hospitals. They will beable to see their data; rather than being shielded from it by a medical doctor. Because our budget is lessthan $75, they will be able to do this at a very low cost. We are strongly considering releasing our schematicsand source code on the Internet free-of-charge under the Creative Commons license in order to give back tosociety.Project Block DiagramAn overall block diagram of the project follows: EEG High-Pass High-Pass Electrodes Filter Filter ADC ESD Discharge Instrumentation Operational Besselworth AT Mega 644 Protection Amplifier Amplifier Filter Microcontroller CircuitUser’sHead UART EEG Electrodes Right-Leg Driver ELECTRICALLY ISOLATED LINE: Real-Time FFT On-Screen with Battery-Powered FTDI Classification Artificial Neural Laptop PC USB RS232 Output to User Network in MATLABTentative SchematicsNOTE: These tentative schematics are highly subject to change throughout the development of our project!Analog Amplification Circuit 4
  5. 5. Opto-isolated UART Serial As mandated by our safety procedures, we will electrically isolate the UART from the USB. The isolated UART will use high-bandwidth 6N137 opto-couplers from Fairchild Semiconductor as follows: It will interface with the UART Pin D.0 and Pin D.1 from the microcontroller. Note that we may have to add NPN transistors to invert the output as specified in the 6N137 datasheet if we cannot figure out a way to invert the UART output in software. The TX and RX lines will then connect to the FT232RL FTDI chip, which will be connected to USB GND and USB 5V for power. Unlike Open EEG’s Modular EEG project, we opted to use 6N137 optoisolators with USB rather than 6N139’s with RS232 using a MAX232 IC. Code Overview Sample code for reading the ADC values and transmitting them to MATLAB over the UART follows. This code will be extended to support multiple ADC channels and output to a graphical LCD. Note that the following code listing has not been tested yet and so we cannot guarantee code correctness: 1 # include < avr / io .h > # include < avr / interrupt .h > 3 # include < avr / pgmspace .h > # include < avr / eeprom .h > 5 # include < stdio .h > # include < stdlib .h > 7 # include < string .h > # include " lcd_lib . h " 9 # include < util / delay .h >11 // UART file descriptor // putchar and getchar are in uart . c13 FILE uart_str = F D E V _ S E T U P _ S T R E A M ( uart_putchar , uart_getchar , _FDE V_SETUP_ RW ) ;15 // ADC variables volatile int Ain , AinLow ;17 # define ADC_BITS 1019 // ADC ISR ISR ( ADC_vect ) 5
  6. 6. 21 { AinLow = ( int ) ADCL ;23 Ain = ( int ) ADCH *256; Ain = Ain + AinLow ;25 fprintf ( stdout , " % d n r " , Ain ) ;27 ADCSRA |= (1 < < ADSC ) ; // start another ADC conversion29 }31 void main () {33 // init the A to D converter // channel zero / left adj / EXTERNAL Aref35 // !!! DO NOT CONNECT Aref jumper !!!! // Need capacitor at AREF pin and AVCC set to VCC37 ADMUX = (1 << REFS0 ) ;39 // enable ADC and set prescaler to 1/128*16 MHz =125 ,000 // and clear interupt enable41 // and start a conversion ADCSRA = (1 < < ADEN ) | (1 < < ADIE ) + 7;43 // sleep register45 SMCR = (1 << SM0 ) ; // ADC sleep47 // init the UART -- uart_init () is in uart . c uart_init () ;49 stdout = stdin = stderr = & uart_str ; fprintf ( stdout , " Starting ADC demo ... n r " ) ;51 sei () ; // start interrupts53 // main loop55 while (1) {57 sleep_cpu () ; }59 } Listing 1: C Source Code Listing References [1] Openeeg project. http://http://openeeg.sourceforge.net/, 2009. [2] Homebrew do-it-yourself eeg, ekg, and emg. http://sites.google.com/site/chipstein/home-page, 2011. [3] F Lotte. A review of classication algorithms for eeg-based braincomputer interfaces. Journal of Neural Engineering, 2007. [4] G. Matsuoka, T. Sugi, F. Kawana, and M. Nakamura. Automatic detection of apnea and eeg arousals for sleep apnea syndrome. In ICCAS-SICE, 2009, pages 4651 –4654, aug. 2009. [5] Hazrati MKh and Efranian A. An online eeg-based brain-computer interface for controlling hand grasp using an adaptive probabilistic neural network. PubMed, 2010. [6] Jorge Baztarrica Ochoa. EEG Signal Classification for Brain Computer Interface Applications. PhD thesis, Ecole Polytechnique Federale de Lausanne, 2002. [7] Olson. Eeg page. http://www.pkfamily.com/users/solson/eeg/eeg.html, 2007. [8] Kouhyar Tavakolian, Faratash Vasefi, Kaveh Naziripour, and Siamak Rezaei. Mental task classifica- tion for brain computer interface applications. In First Canadian Student Conference on Biomedical Programming. 6

×