EOG for REM Sleep Detection

advertisement
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.
ii
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 Low Pass 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 Wein Bridge 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
iii
1. INTRODUCTION
1.1 Purpose 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 nonREM 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.2 Electro-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
1
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
Test Subject
(Electrodes)
Signal
Filtering
and
Amplification
Signal
Filtering
and
Amplification
Test Subject
(Thermistor)
Summer
Circuit
Data
Acquisition
&
Storage
C Program
&
Display
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
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
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.
Av  1  ( R1  R3)
R2
(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.
4
Figure 3.1.2 – Differential Amplifier
Equation 3.1.2 shows the gain for this differential amplifier, assuming that R6=R4 and R7=R5.
Av  (V 4  V 3)( R5 / R 4)
(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 Low Pass 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 – Low Pass 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.
1
FH 
(3.1.3.1)
2  R9  C1
(3.1.3.2)
Av  R9 / R8
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.
5
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.
Av  Pot / R10
(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
V V 
Av   R f   i  b 
 Ri Rb 
6
(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
Av   Rf / Ri
(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 Wein Bridge Oscillator
Figure 3.2.1 shows the Wein Bridge oscillator. This is used to create a sine wave so that the temperature
sensor is at a different frequency spectrum
10K
20K
OUTPUT
10K
10K
53uF
53uF
Figure 3.2.1 – Wein Bridge Oscillator
The frequency of oscillation is shown in Equation 3.2.1.
7
f  1
(3.2.1)
(2 pi( R)(C ))
This circuit oscillates at a frequency of 300Hz, which is well above our EOG circuit output (DC33.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.
OSCILATOR
THERMISTOR
10K
100K
10K
100K
OUTPUT
10K
EOG
SIGNAL
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
8
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.
4
7
x 10
6
5
4
3
2
1
0
0
50
100
150
200
250
300
350
400
450
500
Figure 3.3.2 – FFT of two sinusoidal signals
In either in the Fourier domain or the time domain, we can apply Matlab filters to isolate each
component for analysis. We use Matlab’s sptool command to access Matlab’s filters. We input our data
signal and then apply either an FIR bandpass filter or LS lowpass filter. We mostly used a LS lowpass
filter, seen in Figure 3.3.3, with order of 80 to get our desired view of eye movement over the night.
Figure 3.3.3 – Low pass filter order 80, cutoff 170Hz
After filtering we could view our filtered signal, seen in Figure 3.3.4.
9
Figure 3.3.4 – Filtered Signal
We output the refined data into a sleep.txt file that can be used for analysis by a handwritten C program.
3.4 C Program
Having the text file with a list of voltages corresponding to eye position is sufficient for analysis.
Our C program “eog” (see Appendix III) accepts the data file and the sampling frequency as inputs. It
then reads in the data, matches each data point with its corresponding time, and determines when the
subject looked left and right. This is accomplished by comparing each data point to a previously
determined threshold value to decide if the eyes’ lateral deflection is sufficient to consider the subject to
be looking left or right. Additionally, a previously determined reset threshold value is used to decide
when the eye has returned far enough back to center so that a subsequent lateral deflection is considered
to be a separate left or right eye movement. Figure 3.4.1 demonstrates these two threshold values on a
sample data set.
Figure 3.4.1: Sample input data to eog program showing how the program
recognizes a left/right eye movement with four threshold values
10
The program outputs a data file called “out.txt” that contains a list of all recorded eye movements. This
file displays if the subject looked left or right, the time at which the subject looked left or right, and the
voltage value that triggered the output to be written. The program also asks the user if he would like to
view the output file as soon as it is created. The program interface as well as the output created from the
input data in Figure 3.4.1 is shown below in Figure 3.4.2:
remsun1> eog
Enter input file name: exinput.txt
Enter sampling frequency (Hz): 20
Would you like to average the data (y/n)?: n
The output file 'out.txt' was written successfully!
Would you like to view it (y/n)?: y
Left
Right
Left
Right
Left
Right
Left
Right
Left
Right
Left
Right
Left
Right
Left
at
at
at
at
at
at
at
at
at
at
at
at
at
at
at
0.4500
1.9500
3.7500
5.5000
7.2500
9.0000
10.7000
12.5000
14.3000
16.0000
18.0500
18.4500
18.8500
19.3500
19.9000
s
s
s
s
s
s
s
s
s
s
s
s
s
s
s
due
due
due
due
due
due
due
due
due
due
due
due
due
due
due
to
to
to
to
to
to
to
to
to
to
to
to
to
to
to
-0.2017
0.2179
-0.2174
0.2285
-0.2547
0.2144
-0.2121
0.2120
-0.2259
0.2297
-0.2486
0.2181
-0.2195
0.2295
-0.2308
V
V
V
V
V
V
V
V
V
V
V
V
V
V
V
Figure 3.4.2 – Output of EOG C program
One additional feature of the program is an averaging function. It was found that noisy signals could be
improved by averaging groups of data points together (groups of roughly 5-10 points for our purposes).
The program asks if the user would like to average the data before it is processed. It then performs the
averaging and outputs the new data to a temporary file called “temp.txt.” This is the file the program
then uses to analyze the data as before. Figure 3.4.3 shows an example of noisy data before averaging
and Figure 3.4.4 shows the same data after averaging with the program.
11
EOG Circuit Output (Recorded by MatLab)
0.045
Voltage (V)
0.035
0.025
0.015
0.005
-0.005
-0.015
0.01
1.51
3.01
4.51
6.01
7.51
9.01
10.51
Time (s)
Figure 3.4.3: Sample noisy data from the circuit recorded by MatLab through the soundcard
EOG Circuit Output (Averaged by 5's)
0.045
Voltage (V)
0.035
0.025
0.015
0.005
-0.005
-0.015
0.01
1.51
3.01
4.51
6.01
7.51
9.01
10.51
Time (s)
Figure 3.4.4: Data from Figure 3 averaged in groups of 5 by the eog program to reduce noise
Finally, we decided to hard code the values for the upper writing threshold, lower writing threshold,
upper reset threshold, lower reset threshold, and the number of data points to be averaged together
(should the user decide to average the data before processing). These five values are located at the top
of the code and only need to be changed there. The program can then be recompiled and run. We
decided to hard code these values because they don’t change often enough to warrant asking the user for
them each time the program is run. Additionally, an unfamiliar user might not know good values to set.
12
However, should these values need to be changed for a particular set of data, a somewhat familiar user
can easily alter them in the code.
A summary of the flow of information in the program is shown in Figure 3.4.5.
Input data file
Input sampling frequency
Yes
Average data?
No
Average data and
output to temp.txt
Analyze data for left/right eye movements
with preset threshold values
Output to out.txt
Yes
View output file?
No
Display output
Quit
Figure 3.4.5: Summary of the flow of information in the eog program
13
4. DESIGN VERIFICATION
For the system, tests were first performed with a function generator, oscilloscope and then later with the
circuit hooked up to the eyes.
4.1 Testing
Our circuit was first tested using Cadence PSD. Once the circuit was finalized and created on a
protoboard a 1 Hz sine wave from the function generator was used to model what oscillatory eye
movement would be like. Using an oscilloscope, the gain of each stage was found and was compared to
the theoretical gain to verify that the circuit was working correctly, shown in Table 4.1.
Table 4.1 – Comparison of Theoretical and Actual Gain
Input Diff.
4th Order Variable Summer Inverting Total
Buffer Amp
LowAmp
Circuit
Amp
Pass
Filter
Theoretical 2 V/V -6.8 V/V 1 V/V
-5.28 V/V -20 V/V -10 V/V 14361 V/V
Gain
Actual Gain 2 V/V
-6.5 V/V .89 V/V -5.1 V/V -17.9 V/V -10 V/V
10562
Figure 4.1 displays the frequency response of the circuit, which shows that our circuit almost completely
attenuates signals higher than 50 Hz. This allows the EOG signal to pass, but not the higher frequency
signals (muscle biosignals, 60Hz noise).
Frequency (log) Vs. Gain (log)
3
Gain (Vout/Vin) (log)
2.5
2
1.5
1
0.5
0
0
0.5
1
1.5
2
2.5
Frequency (Hz) (log)
Figure 4.1 – EOG circuit output gain frequency response
14
3
The software was easily tested by using the function generator to input a signal that most likely the
sound card would see. We started at a 2 V peak to peak sinusoidal signal at 3 Hz to be recorded. We
changed the range of voltages to see which range of voltages could still be analyzed by Audacity. The
gain from the software can be varied from -36 dB to 36dB meaning that voltages ranging from .48 V to
3.74 V could be monitored. We also used another function generator to add a 300 Hz signal to the
previous 3 Hz signal.
After recording this set of data, we had enough materials to traverse through Matlab and test out all the
filter and data acquisition tools they had to offer.
Below, we show three different recordings of eye motion using our system. The first trial is moving the
eye in a “square wave” fashion, the second is simulating REM in a “sine wave” fashion, and the third is
showing the effects of an up and down eye movement.
EOG Circuit Output
1.05
0.95
Voltage (V)
0.85
0.75
0.65
0.55
0.45
0.35
0.25
0.05
1.05
2.05
3.05
4.05
5.05
6.05
7.05
8.05
9.05
Time (s)
Figure 4.1.1: Sample data from circuit when subject looks center, left, center, right, center, etc. in a
stepwise manner
Figure 4.1.1 is the voltage data obtained from the file output by Matlab, which is recording the output of
the circuit. Below is the output that results from our program after it analyzes the data:
Left
Right
Left
Right
Left
Right
Left
Right
Left
Right
Left
Right
Left
Right
at
at
at
at
at
at
at
at
at
at
at
at
at
at
0.0500
0.6500
1.2000
1.8000
2.3500
3.0500
3.7000
4.4000
5.0000
5.6000
6.3000
6.9500
7.5500
8.2000
s
s
s
s
s
s
s
s
s
s
s
s
s
s
due
due
due
due
due
due
due
due
due
due
due
due
due
due
to
to
to
to
to
to
to
to
to
to
to
to
to
to
0.3102
0.9917
0.3910
0.9451
0.4125
0.9624
0.3767
0.9649
0.3725
0.9146
0.2827
0.9137
0.3443
0.9810
V
V
V
V
V
V
V
V
V
V
V
V
V
V
15
Left at
Right at
8.7000 s due to
9.3000 s due to
0.3835 V
0.9009 V
The program is able to accurately identify every left and right eye movement event and output this
information to a user-friendly text file.
EOG Circuit Output
0.3
0.2
Voltage (V)
0.1
0
-0.1
-0.2
-0.3
-0.4
-0.5
0.05
1.05
2.05
3.05
4.05
5.05
6.05
7.05
8.05
9.05
Time (s)
Figure 4.1.2: Sample data from circuit when subject simulates REM
Figure 4.1.2 is the voltage data obtained from the file output by Matlab, which is recording the output of
the circuit. Below is the output that results from our program after it analyzes the data:
Left
Right
Left
Right
Left
Right
Left
Right
Left
Right
Left
Right
Left
Left
Right
Left
Right
Left
Left
Right
Left
Right
Left
Right
Right
at
at
at
at
at
at
at
at
at
at
at
at
at
at
at
at
at
at
at
at
at
at
at
at
at
0.0500
0.1500
0.4000
0.6500
0.8500
1.0500
1.3500
1.5500
1.8500
2.1000
2.3000
2.5500
2.8000
3.2500
3.5500
3.7500
4.0500
4.2500
4.7000
4.9500
5.1500
5.4000
5.6000
5.9500
6.3500
s
s
s
s
s
s
s
s
s
s
s
s
s
s
s
s
s
s
s
s
s
s
s
s
s
due
due
due
due
due
due
due
due
due
due
due
due
due
due
due
due
due
due
due
due
due
due
due
due
due
to
to
to
to
to
to
to
to
to
to
to
to
to
to
to
to
to
to
to
to
to
to
to
to
to
-0.4279
0.1525
-0.3228
0.1831
-0.3472
0.1239
-0.3410
0.1944
-0.3426
0.2452
-0.3210
0.1284
-0.3957
-0.3876
0.2024
-0.3952
0.2044
-0.4400
-0.3433
0.1645
-0.3439
0.1676
-0.3352
0.2418
0.1550
V
V
V
V
V
V
V
V
V
V
V
V
V
V
V
V
V
V
V
V
V
V
V
V
V
16
Left
Left
Right
Left
Right
Left
Left
Right
Left
Left
Right
at
at
at
at
at
at
at
at
at
at
at
6.6000
7.1500
7.3500
7.6000
7.8000
8.1000
8.5500
8.8500
9.1000
9.5500
9.8000
s
s
s
s
s
s
s
s
s
s
s
due
due
due
due
due
due
due
due
due
due
due
to
to
to
to
to
to
to
to
to
to
to
-0.3099
-0.3518
0.2460
-0.3593
0.1448
-0.3291
-0.3490
0.2031
-0.3651
-0.3775
0.1818
V
V
V
V
V
V
V
V
V
V
V
The program had a little more difficulty with this data since the eye was moving very rapidly and the
sampling frequency was not high enough. However, it was able to identify most left and right eye
movement events.
EOG Circuit Output
0.5
0.4
Voltage (V)
0.3
0.2
0.1
0
-0.1
-0.2
-0.3
0.05
0.55
1.05
1.55
2.05
2.55
3.05
3.55
4.05
4.55
Time (s)
Figure 4.1.3: Sample data from circuit when subject looks left and right for
2.5 seconds and then looks up and down for 2.5 seconds
Figure 3.1.3 is the voltage data obtained from the file output by Matlab, which is recording the output of
the circuit. Below is the output that results from our program after it analyzes the data:
Left
Right
Left
Right
at
at
at
at
0.0500
0.5500
1.2000
1.9500
s
s
s
s
due
due
due
due
to
to
to
to
-0.2066
0.4051
-0.2246
0.4172
V
V
V
V
This data demonstrates that the circuit is able to ignore up and down movements of the eye. Only left
and right movements, as with REM sleep, will be recorded and output by the program.
17
4.2 Conclusions
Everything worked in the theoretical stage and when we simulated the random eye motion of REM
sleep. This translated over into successful capture of REM sleep data each time a subject slept in the
lab.
18
5. COST
5.1 Parts
Labor: Bob (120 hours * $50/hr * 2.5) + Andrew (120 hours * $50/hr * 2.5)
= $30,000
Table 5.1 shows the final parts and prices used in the final version of our project.
Table 5.1 - Parts List and Total Cost
Part Number
CFR-50JB-2R
CFR-50JB-10R
CFR-50JB-68R
CFR-50JB-100R
CFR-50JB-100R
B32620A6472J
LM741CN
RL1003-2871-103-SA
PVG5H203A01R00
31112496
1N5338
Manufacturer
Yageo
Yageo
Yageo
Yageo
Yageo
EpCos
Nat. Semi.
Thermometrics
Murata
Sound Blaster
ConMed
Dell
Radioshack
Fairchild
Kingston
Description
2K Resistor
10K Resistor
68K Resistor
100K Resistor
100K Resistor
470pF Capacitor
Op-Amp
Thermistor
20K Trim Pot
24-bit sound card
Electrodes (30)
Laptop
Microphone cable
Voltage Regulator
256MB thumb drive
Total
5.2 Total Cost
Total Cost = Labor + Parts = $30000 + $1031.76 = $31031.76
19
Price
$0.046
$0.046
$0.046
$0.046
$0.046
$0.37
$0.68
$3.01
$0.89
$31
$4.50
$900
$6
$.60
$24
Quantity
1
15
2
15
1
4
20
1
4
1
1
1
1
3
1
Total
$0.05
$0.69
$0.09
$0.69
$0.05
$1.48
$13.6
$3.01
$3.56
$31
$4.50
$900
$6
$1.80
$24
$1031.76
6. CONCLUSIONS
6.1 Accomplishments
We have successfully designed and built a system to detect lateral eye motion. We have taken data over
long periods of time and successfully analyzed and displayed the results. The data collected from our
system was accurate and consistent. The circuit outputted a strong, clear signal that corresponded to the
lateral eye position. We were then able to accurately digitize this signal and analyze the data for left and
right eye deflections with Matlab and our handwritten C program. Our device can be used at home with
a personal PC if the user has some kind of data acquisition capabilities. Our circuit and our program are
freestanding entities and Matlab is just one known program that can bridge the gap.
Overall, we consider the project to be a great success and we are very proud of our accomplishments.
We worked very well together as a team. We were able to work productively together as well as
delegate work according to our individual strengths when necessary. We also all learned a great deal
and overcame several obstacles to produce a fully functional, biomedical instrument.
6.2 Obstacles
There were unforeseen barriers that we had to overcome in the construction of our project. The offset of
electrodes pushed the patient’s signal out of viewable range and signals were lost due to saturation.
Electrodes would fall off the face during a night of sleeping in subjects own bed. The thermistor was
not responsive enough to accurately gauge when REM sleep occurs due to the fact it was hard to control
temperature in our environment in the lab. We were still able to overcome most of these problems to
produce a working project.
6.3 Future Improvements
We feel there are areas of improvement on the existing work we just finished. There could be more
functionality by adding EEG, EMG, HR, or BP monitors to help better determine the exact time of REM
sleep. For each patient, the circuit had to be recalibrated to specific level so it could monitor the person
accurately. This was a tedious and a time consuming task. A feedback loop in the circuit to normalize
the retinal-corneal dipole signal from all users rather than having to manually adjust the potentiometer in
the circuit and the threshold values in the program would be a great addition to the circuit. Lastly, if we
could make this a truly portable system, we would add the circuit to PCB board for easy transferring.
20
APPENDIX I– Electrode Placement
Figure 1 – Electrode placement on head. One electrode on the forehead (ground)
and one set of electrodes on the canthi of both eyes (near the temple).
21
APPENDIX II – PSPICE Schematic
22
APPENDIX III – eog.c
Below is the c program that is used to analyze the results and was used to determine when a subject was
in REM sleep.
#include <stdio.h>
#include <string.h>
#define
#define
#define
#define
UWTHRESH
LWTHRESH
UFTHRESH
LFTHRESH
#define avenum 5
1.0 /*Define upper write threshold value*/
–1.0 /*Define lower write threshold value*/
.3 /*Define upper flag reset threshold value*/
-.3 /*Define lower flag reset threshold value*/
/*Define number of data points to average together*/
int main()
{
FILE *in;
FILE *out;
char infile[50];
char view[1];
char ave[1];
char buffer[50];
float eog=0;
float f=0;
float time=0;
int count=0;
float tot=0;
int flag=0;
int i=0;
printf("\nEnter input file name: ");
scanf("%s",&infile);
in=fopen(infile,"r");
/*Prompt for input file*/
/*Open input file for reading*/
if(in != NULL) /*Check input file opened*/
{
printf("Enter sampling frequency (Hz): "); /*Prompt for freq*/
scanf("%f",&f);
printf("Would you like to average the data (y/n)?: "); /*Prompt for data averaging*/
scanf("%s",&ave);
if(strcmp(ave,"y") == 0) /*Average data if desired*/
{
out=fopen("temp.txt","w"); /*Open temp file for writing*/
while(flag==0)
{
tot=0;
for(count=1;count<=avenum;count++) /*Average sets of numbers*/
{
if(fscanf(in,"%f",&eog) != EOF)
{
tot=tot+eog;
}
else flag=1;
}
for(i=0;i<(count-1);i++) /*Print ave of groups of numbers that many times*/
{
fprintf(out,"%f\n",tot/(float)(count-1));
}
}
fclose(in);
fclose(out);
}
if(strcmp(ave,"y") == 0) /*Open the appropriate input file*/
{
in=fopen("temp.txt","r");
}
else
23
in=fopen(infile,"r");
out=fopen("out.txt","w");
count=0;
flag=0;
/*Open output file for writing*/
while(fscanf(in,"%f",&eog) != EOF)
{
count++;
if((eog<UFTHRESH) && (eog>LFTHRESH))
{
flag=0;
}
/*Reset flag variable*/
if((eog>=UWTHRESH) && (flag==0)) /*Write to output if above threshold*/
{
time=count/(float)f;
fprintf(out,"Right at %9.4f s due to %9.4f V\n",time,eog);
flag=1;
}
if((eog<=LWTHRESH) && (flag==0)) /*Write to output if below threshold*/
{
time=count/(float)f;
fprintf(out,"Left at %9.4f s due to %9.4f V\n",time,eog);
flag=1;
}
}
fclose(in); /*Close input and output files*/
fclose(out);
printf("\nThe output file 'out.txt' was written successfully!\nWould you like to view it (y/n)?:
");
scanf("%s",view);
if(strcmp(view,"y") == 0) /*Display output file if desired*/
{
printf("\n");
in=fopen("out.txt","r");
while(fgets(buffer,50,in) != NULL)
{
printf("%s",buffer);
}
}
}
else /*If input file does not open*/
printf("\nInvalid input file.\nOutput not written!\n");
printf("\n");
return 0;
}
24
REFERENCES
[1]
“A manual of standard terminology, techniques, and scoring system for sleep stages of human
beings.” Ed. Allan Rechtschaffen, Anthony Kales. US National Institutes of Health. Pub No. 24.
[2] “The Electric Signals Originating in the Eye.” March 2005,
<http://butler.cc.tut.fi/~malmivuo/bem/bembook/28/28.htm>
[3] Morgan, Stuart W. et. al. Utilizing EOG for the Measurement of Saccadic Eye
Movements. February 2005, <http://www.eng.monash.edu.au/ieee/ieeebio1999/p33.htm>.
[4] J.D. Enderle, S.M. Blanchard, J.D. Bronzino, Introduction to Biomedical Engineering. Boston:
Academic Press, 2000, pp 180-210.
25
Download