Tuesday, May 29, 2012

Week Eight Updates

This past week, the algorithm was modified. It is now possible to pause and play the music player by forcefully blinking one eye. Only one eye can be used because so far the algorithm only has variables for one channel and can only interpret the voltage changes of one eye.
Rolling graph of raw signal, filtered signal, and energy

A second channel is currently being further researched and tested in order for both eyes to be used to send signals to MATLAB. After there are two working channels, one for each eye, MATLAB will be able to recognize multiple signals and execute more commands.

The raw EMG signals were slightly different from an ideal EMG signal. An ideal EMG signal always starts around -70 mV because this is the resting potential of the neuron when it is not contracting. In order for the muscle to contract, the neuron axon undergoes voltage changes in order to tell the muscle to contract. The voltage change includes polarization, when positive Na+ ions enter the axon and K+ ions leave the axon. This is why the graph of the EMG signal increases. The decrease in the graph of the signal is the axon depolarizing, which is when the K+ ions flood back into the axon and the Na+ ions are pushed out. The frequency of the signal depends on the intensity of the stimulus. A strong stimulus will cause a very high frequency and a weak stimulus will cause a low frequency[12]. An ideal signal does not have noise, however the raw signal almost always has noise. A filter of the frequency cuts out some of this noise and make the signal clearer. The low frequency cutoff is 15 Hz and the high frequency cutoff is 150 Hz. These frequencies are used in the filter in order to get a certain range of frequencies. Frequencies less than 15 Hz and grater than 150 Hz are not included in the filtered signal. The raw signal has added noise, and depending on the filter, not all of the voltage changes are read by MATLAB. The added noise is from motion artifact and other stimuli.

An ideal EMG signal
The motion artifact is noise caused by the motion of the electrodes against the skin as they sometimes start to peel off. The frequency of the motion artifact is 2-3 Hz. The motto artifact causes small peaks and valleys in the signal when the eye muscles are not being contracted. There is other noise caused by wall noise which is about 60 Hz in frequency. All of the electrical signals in the body can interfere with the raw signal because there are constantly signals being transmitted between the neurons and the central nervous system. These signals are caused by processes such as breathing, and outside stimuli such as changes in the environment. All of this background noise can be avoided by using a filter.

The energy signal is being read by MATLAB instead of the raw or filtered EMG signal. The energy signal is not the conventional energy unit in classical physics. The energy of signal processing is the sum of the squared values of the raw signal. It is more convenient to use the energy because it is always positive and therefore does not have to account for a negative threshold.

Once the MATLAB algorithm is working properly, the EMG signal will be used to control the music player. When the amplitude of the energy signal reaches a certain point, MATLAB will execute a command to play, pause, or skip the song. A hard blink of the right eye will skip to the next song. A hard blink of the left eye will skip backwards to the previous song. A double forceful blink of both eyes will cause the song to pause or play. The MATLAB algorithm is set up so that once the energy signal reaches a threshold of twenty energy units, the corresponding command will be executed.

Tuesday, May 22, 2012

Week Seven Updates

This week, the alligator clamps were soldered to the stranded wires that were connected to the amplifier. The alligator clamps clamp onto the electrodes so the signals can be carried through the wire to the amplifier and data-aquisition system. The ideal place for electrodes was determined. The reference electrode will be placed on the neck. There will be two electrodes for each orbicularis occuli muscle around the eye. They will both be placed underneath the eye, one at the beginning of the muscle and the other at the end of the muscle. There are two electrodes for each muscle in order to capture the signal and to block out extra noise signal from the muscle.

In order to test signals, the electrodes were placed on the face and the amplifier was turned on. The signals were not being read in MATLAB because it was uncertain how to add multiple channels to detect multiple signals. When turned on, the amplifier became very hot and started to smoke, so it was turned off in order to avoid damage. These are problems that will be solved during the next week. 

The DAQ, amplifier, 9V batteries, and alligator clamps all connected by stranded wire.

Tuesday, May 15, 2012

Week Six Updates

This week the amplifier was built. The amplifier is used to increase the biological signals by a multiple so they can be more easily read by MATLAB. The components were soldered onto a circuit board. The green LED lights light up depending on which gain resister the switch is set to. The data-aquisition system was connected to MATLAB through the computer and the drivers needed for the data-aquisition system were installed. The algorithm for MATLAB is now able to control the volume. It was originally thought that volume would not be able to be controlled because Foobar2000 uses a slider to control the volume, however it can be controlled up or down using a simple MATLAB command.

Amplifier connected to a 9V battery

Tuesday, May 8, 2012

Week Five Updates

The voltage amplitude for the average EMG signal is around 0.5mV. This value can differ depending on the specific muscle where the signals are being read. There was no specific voltage amplitude value of the bioelectrical signals found for the orbital orbicularis oculi, the muscle being used, so preliminary testing will be needed to determine the actual voltage range. The actual voltage range can then be used to determine the gain that should be used for the amplifier in order for the voltage to be large enough to be read by MATLAB. To stay within the dynamic range of the DAQ, the signal needs to be amplified to the maximum value of about 1.5V. The equation to find the gain is Gain=(Output Voltage)/(Voltage of EMG Signal before Amplification). Knowing that the output voltage needs to be 1.5V and that the average EMG signal is around 0.5mV, it can be determined that the gain should be set to about 3000.

From the INA2126 data sheet, it was determined that an R_G value, of the gain resistor, should be approximately 26.7 ohms. This was found using the equation 80000 ohms/(Gain-5)=R_G.

More code development was also done. The play, pause, next, and previous commands were put into a simple function. No signal data is available at this point, so arbitrary variable values were used to test. Once the signal data is available, the function will be able to be fully written.

Foobar2000 control function

MATLAB code to interface the instrumentation amplifier with MATLAB were procured, along with code to filter the signal and display the data in a rolling graph. These were mostly premade and little work was done with them. Once the equipment to retrieve the signals is available, more work will able to be done with the code. All codes are available for download through the links below.

Foobar2000 control: http://www.mediafire.com/?htm2t9ycyosjfth
MATLAB and instrumentation amplifier interface: http://www.mediafire.com/?c11gu1uatbgc9n3
Signal processing and display: http://www.mediafire.com/?ttuc16c59qc42au

Tuesday, May 1, 2012

Week Four Updates


Preliminary testing was not able to be done because the electrodes and amplifier have not been obtained. The data acquisition board (DAQ) was acquired, and this will allow the bioelectric signals to be read by MATLAB.
Data Acquisition (DAQ)
A new music player, foobar2000, is now being used. The MATLAB generated GUI had too many bugs and a very complicated algorithm containing over 800 lines, making it very difficult to control through MATLAB.
foobar2000
Foobar2000 is an actual program designed to play music files. It is easily operated using command line/DOS commands in MATLAB, making it a much better choice for the project.

Simple MATLAB script to control foobar2000 operations