EOG for REM Sleep Detection
By
Robert Slavicek
Andrew Wassef
ECE 445, SENIOR DESIGN PROJECT
SPRING 2005
TA: Adam Zych
5/3/05
Project No. 23
ABSTRACT
Our team designed, built, and tested a system to detect, record, and analyze lateral eye motion and body temperature changes. We did this with the intention of being able to portably detect REM sleep patterns for personal, diagnostic, and research purposes. Our system captured lateral eye position data by taking advantage of the natural corneal-retinal dipole in the eye. Round Ag/AgCl electrodes placed on the lateral canthi of the eyes are able to detect rotation of the corneal-retinal dipole and provide a signal proportional to lateral eye position. Our circuit then amplifies, filters, and reduces DC offset of this signal in order to produce a more measurable signal. A change in the resistance of the thermistor placed under the armpit was used to follow body temperature changes. These signals were then fed into a sound card on a PC. Once digitized, the eye signal was analyzed by a program designed to detect eye deflection events and display them in a user-friendly format. We were able to successfully determine when a subject went into REM sleep by seeing when left-right signals from the eyes were similar to the eye movement seen when a subject is in REM sleep.
TABLE OF CONTENTS
1.INTRODUCTION...... 1
1.1 Purpose of Project...... 1
1.2 Electro-Oculargram Signal...... 1
1.3 Design Characteristics...... 1
1.4 Block Diagram...... 2
2.DESIGN PROCEDURE...... 3
2.1 Analog Signal Circuitry...... 3
2.2 Tools Used...... 3
3.DESIGN DETAILS...... 4
3.1 Analog Signal Circuitry for EOG...... 4
3.1.1 Buffer Circuit...... 4
3.1.2 Differential Amplifier...... 4
3.1.3 LowPass Filter...... 5
3.1.4 Variable Amplifier...... 6
3.1.3 Summer...... 6
3.1.3 Inverting Amplifier...... 7
3.2 Analog Signal Circuitry for Thermistor...... 7
3.2.1 WeinBridge Oscillator...... 7
3.2.2 Temperature Sensor...... 8
3.3 Data Acquisition...... 8
3.4 C Program...... 10
4.DESIGN VERIFICATION...... 14
4.1 Testing...... 14
4.2 Conclusions...... 18
5. COST...... 19
5.1 Parts...... 19
5.2 Labor...... 19
6. CONCLUSIONS...... 20
6.1 Accomplishments...... 20
6.2 Obstacles...... 20
6.3 Future Improvements...... 20
APPENDIX I – Electrode Placement...... 21
APPENDIX II – PSPICE Scematic...... 22
APPENDIX III – eog.c...... 23
REFERENCES...... 25
1
1. INTRODUCTION
1.1Purpose of Project
Our main goal is to allow the home user to be able to identify how much random eye motion (REM) sleep they are getting, possibly revealing any sleeping disorders he or she may have. We planned on accomplishing this by creating a portable, comfortable device that can be brought home and used to record sleeping patterns (by looking for random eye motion signals and temperate changes found in REM sleep). With the ability to monitor REM sleep, it becomes possible to determine which daily activities cause adverse effects on sleep. People will become able to adjust both their active work habits and their sleeping habits in order to find an optimal balance between them. We wish to successfully record this data, and to create a program that analyzes and detects when a subject has entered REM sleep. This is accomplished using the fact that the eye stays in relatively constant position while in non-REM sleep and body temperature is regulated and kept at the patient’s normal temperature. When the subject goes into REM sleep, the eyes move in a sporadic, sometime oscillatory manor, which can cause the corneal-dipole of the eye to move back and forth, allowing us to capture this changing voltage using electrodes on the outsides of each eye. Also during REM sleep, the body temperature is not regulated, so it deviates towards the room temperature, causing decreased body heat. By digitally recording and analyzing the data from this device a subject can accurately track his or her REM sleep throughout the course of several weeks, and verify whether any lifestyle changes or medical equipment have had an effect or not.
1.2Electro-Oculargram Signal
The electro-oculargram (EOG) is a measurement of a biopotential produced by changes in eye position. In the normal eye, there is a steady electric dipole of approximately 0.4 to 1.0 mV [1] between the cornea and the retina. This dipole is not caused by muscle movement, but rather by the higher metabolism rate of the retina, which creates more free ions in the back of the eye, leading to a difference in voltage [2]. The corneal-retinal potential can be measured by placing a single surface electrode directly lateral to each of the orbits of the eye on the canthi (near temple) and a reference electrode to the forehead (see Appendix I).
When a test subject is gazing straight ahead, the corneal-retinal dipole is symmetric between the two electrodes, and measured EOG output is zero. As the subject looks to the right, the cornea becomes closer to the right lateral electrode and the retina becomes closer to the left lateral electrode, causing the EOG output to be more positive since we measure right minus left. The inverse is true when the subject looks to the left. When measuring the EOG output, there is a fairly linear relationship between the horizontal angle of gaze and the EOG output. This relationship remains true up to 30 degrees of eye shifting [3].
1.3 Design Characteristics
The main factor that needed to be taken into account when designing this system was obtaining a useable biosignal. Since the signal directly from the eyes is between 0.4mV and 1.0 mV, we must have a gain on the order of 1000 to amplify the biosignal into a useable signal (in the volt range). The frequency of this signal is very small, approximately DC. Since the highest you can oscillate your eyes is less than 10 Hz, a filter was choosen with a cut off value of 34Hz. A sampling rate for the sound card which imported data into matlab was important in that the signal had to be digitized at rate so that no data would be lost (more than 1000 Hz). Since every person’s biology is different EOG signals that are detected will vary from person to person, we must have variable factors to account for such differences. Thus the resistances chosen in one of the gain portions of our circuit must be potentiometer, enabling us to quickly find the most appropriate resistance value. Also a natural DC offset is present due to the electrodes and must be accounted for. This too is variable from person to person and must be able to change by use of a potentiometer. If an incorrect resistance is chosen in either potentiometer, the circuit could have the op-amps saturate and fail.
1.4 Block Diagram
Figure 1.3 – High level block diagram
Block Description:
Test Subject: An electrode will be put around the outer part of each eye, with a reference ground electrode placed on the forehead above the bridge of the nose. By combining these signals we obtain a changing voltage depending on eye motion. A thermistor will be placed on the subject (held in armpit, secured by and ace bandage wrap) to record body surface temperature.
Signal Filtering and Amplification: This is the analog circuitry that must clean up the biosignals so that they are useable for data analyze.
Summer Circuit: We only have one sound card available so we must combine these two biosignals into one.
Data Acquisition and Storage: The signal will be convertered to a digital signal using the sound card and the program Audacity. This signal will then be fed into Matlab were the signal will be processed and split, allowing us to view a digital representation of the eye movement
C Program and Display: This C program will take in the digital output of Matlab as a .txt file and determine at what time the subject was looking left or right in a user friendly manor.
2. DESIGN PROCEDURE
2.1 Design Decisions
Due to the larger size (more surface area to attach to) and the stickiness of the adhesive, along with overall general comfort, the Dyna/Trace Stress Electrodes (made by ConMed Corporation) were chosen as our eye electrodes over other brands and types.
The temperature reading could have been done any number of ways, however the cheapest was to have a simple thermistor placed under the armpit. Thus went the body temperature went down the thermistor resistance went up. Using this change in resistance we were able to use this in a feedback loop to vary the peak to peak voltage of an electrical signal.
This device must be portable and cheap, thus we must use basic analog circuitry to clean and amplify our signal. By using LM741 op-amps, we will have a cheap, reliable, easy to use, and readily available analog system [4].
We choose to use the A/D conversion of the sound card since all PC have an audio microphone jack, which we can use to sample our signal. The program Audacity was used to record this data, because it could sample at a rate we needed. The commands in Matlab for this same procedure did not work and could not be used because the frequency of the eye movement was too low. Matlab was used to filter and split the signal (thus allowing us to place the two biosignals on one line). Other ideas for digitally recording the signal centered around using Agilent VEE and recording a multimeter reading of the signal at a certain rate. This was not feasible because the system would then become too bulky and expensive and also we would not be able to record both of the biosignals at the same time.
C was chosen as the programming language due to prior experience and ease of use. The user interface had to been easy and very readable in order to have the general public consider it viable.
2.2 Tools Used
In order to prove that our signal analog circuitry was a feasible idea, Cadence PSD was used to create circuit diagrams and simulate them using test signals. Once the design circuitry was finalized, the circuit was created on a protoboard and analyzed and tested using a Agilent 54642A Oscilloscope. By using a 1mV 1 Hz signal (to model the voltage from the eyes) from a waveform generator, we could debug and verify all parts of the project with out having to attach our to the circuit. Any standard PC sound card with microphone capabilities is useable when coupled with the program Audacity. Audacity is free, open source software for recording and editing sounds and for our uses it can record our signal output as a .wav file. This signal is then processed in Matlab, which was used to further filter the signal and split the two biosignals. Matlab was also used to convert the wave file into a .txt file with the voltage reading sampled at a certain frequency. CodeWarrior by Metrowerks was used to debug, compile, and run the C code.
3. DESIGN DETAILS
3.1 Analog Signal Circuitry for EOG
The overall block diagram of the analog signal circuitry for the EOG signal is shown in Figure 3.1. The overall circuit is shown in Appendix II.
Figure 3.1 – Analog signal circuitry
3.1.1 Buffer Circuit
The input buffer circuit (Figure 3.1.1) is a safety feature to prevent any electrical shock to the subject. Since there is no current flowing in the inverting and non-inverting inputs of the op-amp, connecting the electrodes to the non-inverting inputs insures that no current will be flowing to the user. Due to the high input resistance and the low output resistance, there is no loss of signal in the buffer circuit.
Figure 3.1.1 - Buffer
Equation 3.1.1 shows the gain for this buffer.
(3.1.1)
In our circuit all the resistances (R1, R2, R3) are 10K, so the overall gain is 2.
3.1.2 Differential Amplifier
The differential amplifier is used to amplify the difference between the two electrodes. This helps by attenuating signals that are present at both electrodes. These common signals may be the heartbeat or body movement and since they are present on both electrodes, the differential amplifier effectively cancels the signals out. The difference of the two signals is outputted in a single output signal, shown in Figure 3.1.2.
Figure 3.1.2 – Differential Amplifier
Equation 3.1.2 shows the gain for this differential amplifier, assuming that R6=R4 and R7=R5.
(3.1.2)
In our circuit the resistances of R6, R4 are 10K and R7, R6 are 68K, so the overall gain is 6.8.
3.1.3 LowPass Filter
The next component of the circuit is the low pass filter seen in Figure 3.1.3. This part of the circuit is used to attenuate high frequencies seen from muscle twitches and other high frequency noise (60Hz).
Figure 3.1.3 – LowPass Filter
The cutoff frequency and gain is dependent on the resistors and capacitor. In order to gain a greater attenuation after the cutoff frequency, four filters were put in series creating a fourth order low pass filter.
(3.1.3.1)
(3.1.3.2)
The expected cutoff is shown in Equation 3.1.3.1 and the gain is shown in Equation 3.1.3.2. The values choosen are R8, R9 equal to 10K and the capacitor is 470pF. This gives us a cutoff frequency of roughly 33.8 Hz, which completely attenuates signals that are not from the eye dipole movement. The gain of this circuit is unity since the resistances are matched.
3.1.4 Variable Amplifier
The variable amplifier is shown in Figure 3.1.4 and serves to amplify the signal that is outputted from the filter. This is needed in order to gain a larger difference when the eye voltage is switching between positive and negative. The feedback resistor is variable in this case to give the operator greater control over how much gain is produced. This is needed because each subject has differing dipole strengths and attenuation due to skin, fat, etc.
Figure 3.1.4 – Variable Amplifier
For this circuit, the gain is shown in Equation 3.1.4.
(3.1.4)
The potentiometer was at optimum at 10.56K and R10 is 2K, giving us a gain of 5.28. This value is variable however and is altered to best fit the subject.
3.1.5 Summer
In Figure 3.1.5 is a basic summer circuit, which is used to decrease DC voltage offset. In the case of our circuit, there is a certain amount of DC offset from the electrodes, which is amplified throughout the circuit. This part of circuit effectively blocks that offset by summing it with an equal and opposite voltage. By using voltage divider on a potentiometer with ±12V on its ends, a specific voltage can be chosen.
Figure 3.1.5 - Summer
(3.1.5)
The output of the circuit is shown in Equation 3.1.5. Our Vb (potentiometer voltage) was +4.75V, which got rid of the unwanted offset voltage. This Vb is variable and is set to whatever value best zeros the DC offset for each individual subject. The gain is approximately –20, since for our circuit the Rf value was 100K and the Ri, Rb was 10K and the input voltages were roughly 1V.
3.1.6 Inverting Amplifier
The last aspect of the circuit is the inverting amplifier shown in Figure 3.1.6. This serves to increase the signal so that the output can be easy read on an oscilloscope as well as by the sound card (Audacity) in conjunction with Matlab so that our EOG program can differentiate eye movement effectively.
Figure 3.1.6 – Inverting Amplifier
(3.1.6)
Equation 3.1.6 shows the gain acquired by this circuit. The Rf is 100K and the Ri is 10K in our circuit giving us an over gain of 10 from this amplifier.
3.2 Analog Signal Circuitry for Thermistor
This circuit must place the thermistor at a certain frequency and then allow the change in resistance to change the voltage level, then mix the signal with the EOG circuit output.
3.2.1 WeinBridge Oscillator
Figure 3.2.1 shows the WeinBridge oscillator. This is used to create a sine wave so that the temperature sensor is at a different frequency spectrum
Figure 3.2.1 – WeinBridge Oscillator
The frequency of oscillation is shown in Equation 3.2.1.
(3.2.1)
This circuit oscillates at a frequency of 300Hz, which is well above our EOG circuit output (DC-33.8Hz).
3.2.2 Temperature Sensor
Figure 3.2.2 shows how the temperature dependent resistance of the thermistor is coupled to the 300Hz sine wave and then summed with the EOG circuit output.
Figure 3.2.2 – Temperature Sensor
As the temperature decreases the resistance of the thermistor increases, which leads to a decrease in the voltage output of the first op-amp (simple inverting amplifier) according to Equation 3.1.6. That signal is then summed with the EOG signal according to Equation 3.1.5. This single output is now ready for data acquisition.
3.3 Data Acquisition
After receiving the signal from the circuit board, the sound card takes in the varying voltage as a sound signal. The audio signal (Figure 3.3.1) is taking in through a program called Audacity. The record function enables us to record the voltage signal and a sample of 8000 Hz at 16 bits.
Figure 3.3.1 – Sample from eyes
There is a microphone gain feature in the software that allowed us to vary the gain of the sound card, which helped in dealing with a wide range of voltages.
From Audacity, the file was encoded as a .wav file and sent to Matlab for data analysis. In Matlab, the wavread function takes in the .wav file data and converts into a data array of M by 1 samples, where M is the number of samples taken by the sound card. This data contains the data of the thermistor at 300 Hz and the eye movement around the 3-5 Hz range. We therefore can perform the FFT or Fast Fourier Transform (Figure 3.3.2) of this signal so we can analyze the frequency range of each component of the signal.