Saturday, June 9, 2012

Monday, June 4, 2012

Week Ten Updates

The final touches were put on the project. The algorithm was changed slightly to include a temporary variable so that the command function is only called when the signal energy crosses the threshold. This prevents the function from executing the same command many times rapidly.

The electrodes continued to cause problems. The alligator clamps tend to peel the corners off of the face, and the electrodes are so sensitive that they must be completely attached or they will not detect muscle contractions properly. More adhesive electrodes would mitigate this problem.

We recorded a demo demonstrating control of foobar2000 using EMG signals.

 

The final script and command function can be found here:
http://www.mediafire.com/?gnwzcfvslxr42oi
http://www.mediafire.com/?iy545a746d6y3nc

Friday, June 1, 2012

Week Nine Updates

The final adjustments to the project were made. Lines of MATLAB code were added so now skip ahead, skip backwards, and play/pause can all be controlled with blinks. The script was also edited to display the signal graphs for both eyes simultaneously.
Plots for both eye signals

There is some trouble with the electrodes because they are not sticking to the face very well. They are extremely touchy and must be completely attached to the the face to pick up a signal. There is also a small delay in the rolling display of the signals detected because of the amount of signals being read. Additionally, a few more adjustments need to be made that will cause the algorithm to wait a few milliseconds after reading one jump in energy before executing a command. This will fix the problem experienced when one eye is read before the other eye in a double blink.

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

Tuesday, April 24, 2012

Week Three Updates

In order to understand how MATLAB interfaces with other programs, such as a music player, tutorials MATLAB were watched. Basic functions and applications of MATLAB were practiced during this week. General ideas about how the placement of electrodes on the face and how the electrodes will communicate with MATLAB through a data-aquisition system were discussed. Ideas of which muscle contractions would control the music player were also discussed, such as a forceful blink of the right eye will skip the song ahead and a forceful blink of both eyes will play or pause the song.

The instrumentation amplifier will not be available for another few weeks, therefore the preliminary testing of the electrodes will be delayed.

Research was done to find a suitable music player. A MATLAB generated graphical user interface (GUI) will be used to control Windows Media Player. This program will then be operated by the EMG signals, rather than with the GUI.

MATLAB generated GUI

Research was also done to find what causes the electrical conduction in muscles. Neurons are cells that control all body functions, and motor neurons specifically control muscle movement. Motor neurons consist of the main cell body, dendrites that receives nerve impulses from other neurons, the axon, and the axon terminal that sends nerve impulses to other neurons. Nerve impulses are sent between neurons to tell the muscles when to contract. [11]

Motor Neuron [11]

Action potential allows the cell to have a nerve impulse and is caused by the rapid change in charge of the axon of the cell. At its resting potential, the axon has more positive ions inside the membrane than outside the membrane, causing the axon to have a net negative charge. This change occurs because there are more Na+ ions outside than inside the membrane and more K+ ions inside than outside the membrane. The action potential begins when the Na+ ions flow into the membrane and causes depolarization. Depolarization is when the membrane to loses its negative charge to now have a positive charge. To repolarize the membrane, the K+ ions flow out of the membrane and the membrane regains its negative charge. The wave of the change in charge caused by the depolarization and repolarization travels down the axon and this change in charge is the change in voltage that is detected by the electrodes. More information about this can be found here. [11]

The depolarization and repolarization of a neuron [11]


The orbicularis oculi are muscles that are located around the eyes and cause the eyelids to close. The palpebral part is in the eyelids, and closes over the eyes. The orbital part is around the eye and contracts when the eye closes. The orbital part of the orbicular is oculi is more accessible and less obtrusive to the user, therefore this will be the muscle that the electrodes will be placed over. The electrodes will detect the voltage changes in the orbital orbicularis oculi when the user forcefully blinks. The voltage changes are caused by the neuron impulses in the muscle cells to tell the muscle to contract. These voltage changes will be interpreted by MATLAB so the music player can be controlled by the forceful blinks. [11]

The Orbicularis Oculi muscle [9]

The EMG signals of the orbicularis oculi muscles are shown in the picture below. The signals vary in amplitude between +/- 0.5 mV. The peaks in the graph are when the neurotransmitter signals the receiving cells and tell the muscle to contract. The rising part of the peaks are caused by the depolarization of the axon and the downward part of the peaks are caused by the repolarization of the axon. The neuron impulses which tell the muscle to contract when blinking or squinting cause the continuous bioelectrical signals. [10]

Change in EMG Volts over time [10]

Monday, April 16, 2012

Week Two Updates

In week two, a more specific design for the bioelectrically controlled music player was decided upon. The design proposal was also finalized and posted on the blog. Research on similar bioelectrically controlled devices, such as elecrtooculography control of both physical devices such as prosthetics and computers, was conducted.

Tuesday, April 10, 2012

Week One Updates

The design project for the term is to control basic functions of a music player - play, pause, skip, and volume - using biotechnological sensors. The sensors will be placed on the face and will be triggered by different muscle movements. This week, the blog was created and updated with group member and advisor information. Tasks were delegated amongst the team members.