SlideShare a Scribd company logo
Target Heart Rate Monitor (THRM)
Susan Hamilton, Omar Nada, and Elijah Willie
skhamilt@sfu.ca, onada@sfu.ca, and ewillie@sfu.ca
Department of Computing Science
CMPT 340
Ghassan Hamarneh
I. Abstract
By taking a 30 second video of a user finger and measuring the
change in colour intensities we are able to obtain the heart rate in beats per
minute of the user. This is found by using several methods of computing
the brightness of the signal then passing that under a band-pass filtering.
From this point using a sliding window we in sequence find the fourier
transform of the signal, find the maximum peaks, and smoothing these
peaks. From these sequence of methods we obtained the EKG graph which
provides a visual understanding for the user. Because we already had the
users optimal heart rate of ther user we can advise them on how to obtain
their optimal heart rate for the given activity.
II. Keywords
 Heart Rate or Heart Beat
 Brightness Signal Computation
 Band-Pass Filtering
 Fast Fourier Transform
 Sliding Window
 Sampling Frequency
 Peak Detection
 Smoothing
 Image Noise or Signal-to-Noise Ratio (SNR)
III. Introduction
It is often that we find ourselves wanting to participate in a particular
activity such as studying, exercising, or just waking up or going to sleep,
but complaining about not being in the right state of mind. THRM’s main
purpose is to assist in achieving this optimal state by monitoring the heart
rate. Over a testing period THRM is able to obtain an optimal heart rate
specific to the user. From this point on THRM is able to monitor the users
heart rate using their mobile device and advise in ways to either rase or
lower their heart rate in a short amount of time in order to allow the user to
achieve the optimal state necessary for peak performance in their activity.
The motivation of this project is to assist the user to obtain their own
personalized heart rate monitor. That is to say that not everyone is the same
and what works for one person may not work for another. Also heart rate
could be affected by a person’s height, weight, gender, and general state of
health. THRM is also specialized in that though it will provide initial
activities such as those listed above, it will also allow the user to
personalize their own activity tags specific to their needs. No one person is
the same and neither should THRM only cater to a small rage of activities.
In the rest of the report we will cover the material that is used, section
IV, and section V will cover the methods that were used to construct our
results and accomplishments which will then be covered, section VI and
section VII. Following this we will overview the contributions of
individual members, section VIII, as well as acknowledge referenced
material in section, XII. We will also provide our discussions on our
conclusions and what could be coming in the future for this project in
sections IX and X.
IV. Material
 Human subjects
 Mobile device or computer with camera
 30 second clip to obtain the signal required to analyze and
produce a EKG graph
V. Methods
i. Video Signal Analysis
o Since research shows the human heartbeat is
between 60 and 200 beats per minute to avoid
aliasing we followed the Nyquist Sapling
Theorem where we doubled the maximum value.
ii. Brightness Signal Computation
o We looked at the red value and averaged their
values.
o
Where W=frame width
H=frame height
[n,x,y,1] % since looking at red only
video = VideoReader('path to your video file here');
brightness = zeros(1, video.NumberOfFrames);
for i = 1:video.NumberOfFrames,
frame = read(video, i);
redPlane = frame(:, :, 1);
bght(i)=sum(sum(redPlane))/(size(frame,1)*size(frame,2));
end
iii. Band-Pass Filtering
o This step attenuates frequencies not within the
interested region.
o Helps to remove extra noise.
o In particular we used second-order Butterworth filter
– applies the ‘maximally flat‘.
BPM_L = 40; % Heart rate lower limit [bpm]
BPM_H = 230; % Heart rate higher limit [bpm]
FILTER_STABILIZATION_TIME = 1; % [seconds]
% Butterworth frequencies must be in [0, 1], 1
corresponds to half the sampling rate
[b, a] = butter(2, [((BPM_L / 60) / v.FrameRate * 2),
((BPM_H/60)/v.FrameRate*2)]);
filtBrightness = filter(b, a, brightness);
% Cut the initial stabilization time
filtBrightness = filtBrightness((v.FrameRate *
FILTER_STABILIZATION_TIME + 1):size(filtBrightness, 2));
iv. Fourier Transform
o We used the discrete fourier trasform to change it
from the time domain to the frequency domain.
o Used fft(signal) in Matlab
o Sliding window was used to repeat peak detection
and smoothing over every .5seconds of a 6 second
frame
o
 Where Fr= frequency resolution
Fs=sampling frequency
N=number of window samples
Tw=window time duration
 Window length effects accuracy: higher the
window time better the Fr but the lower the
time accuracy
v. Peak Detection
o Use findpeaks function in Matlab we find a sample
data if the point is larger than its two neighbours and
then we use max function to find the max peak.
o Then change it to the fourier tranform vector.
% Translate the freq range to indices within FFT vector
rangeOfInterest = ((BPM_L:BPM_H) / 60) *
(size(fftMagnitude, 2) / sampFrequency) + 1;
% Find peaks in the range of interest
[peaksValues,peakIndices]=findpeaks(fftMagnitude(rangeO
fInterest));
% Find the highest peak
[maxPeakValue, maxPeakIndex] = max(peaksValues);
% Translate the peak index to an FFT vector index
bpmFreqIx = rangeOfInterest(peakIndices(maxPeakIndex));
% Get the freq in bpm corresponding to the highest peak
bpmPk = (bpmFreqIx - 1) * (sampFrequency /
size(fftMagnitude, 2)) * 60;
vi. Smoothing
o We have now found teh most powerful spot in
frequency
o Now correlate around the fourier transform around
the peak using zero-padding
fftResolution = 1 / WINDOW_SECONDS;
lowFreq = bpmPeak / 60 - 0.5 * fftResolution;
smoothingResolution = SMOOTHING_RESOLUTION / 60;
testFreqs = round(fftResolution / smoothingResolution);
power = zeros(1, testFreqs);
freqs = (0:testFreqs -1)*smoothingResolution + lowFreq;
for k = 1:testFreqs,
re = 0; im = 0;
for j = 0:(size(b, 2) - 1),
phi = 2 * pi * freqs(h) * (j / samplingFreq);
re = re + b(j+1) * cos(phi);
im = im + b(j+1) * sin(phi);
end
%only need to find the maximum, we use power
power(k) = re * re + im * im;
end
[maxPeakValue, maxPeakIndex] = max(power);
smoothedBpm = 60 * freqs(maxPeakIndex);
VI. Results
When we film a 30 second video of a finger placed on the screen
we obtain the heart rate in bpm and a graph showing the heart rate
for that frame and how it changed over time
Sleeping Exercising
VII. Accomplishments
For a project such as this, it was difficult to know what was feesable
to accomplish within the given time restrictions as well as without
experience and knowledge in the areas we would be attempting to delve
into. With this being said we were able to accomplish success in many of
the important areas of the proposed project. The fundamental part of the
assignment we put as foremost necessary to accomplish was the functional
heart rate monitor using the camera of a mobile device or laptop. This we
were able to achieve due to online resources (see section XII for our
acknowledgements). With a some tweaking we were able to apply multiple
methods (described in section V) in taking a signal and removing noise to
find the heart rate of the individual. We were also able to find a wealth of
resources on heart rate. We did meet an opstacle here with ensuring that the
information we obtained was FDA approved. With this being said we were
able to find quite a few works that cited information which was FDA
approved. With this problem also came a fundamental lack of knowledge
on heart rate. In using a testing period where the user would have their
heart rate tested when they were in their optimal state we were able to
overcome the need to know in depth knowledge on what science says an
optimal heart rate should be given a wide range of factors such as weight,
height, and gender. Another detail is to know by how much deviation of the
heart rate should be considered over or under the optimal heart rate and we
did do a bit of testing with various activities, but this is an area that could
use further testing and research. The one area that proved to be the largest
obstacle was that of the graphic user interface. Initially we had decided to
focus on an iOS device application using xCode. Though many hours were
spent on this, due to a lack of previous experience by any of the members
this area was progressing rather slowly. We also came to realize that Apple
required a license to publish applications and that we would perhaps not
wish to make an iOS device application, but instead an Android application
as well as a laptop or desktop application. Do to the time constraint we
decided that it was more important to ensure that the actual software was
working and that we obtained a plentiful of information was obtained for
the application before we focussed on producing the GUI.
VIII. Contributions
All members helped one another in the various areas one
advicement or on research and understanding. With this in mind,
below is listed the assigned duties of each member and what their
main focus was on.
Omar Nada contributed mainly to the research of all information
pertaining to the heart rate. Information on how to increase and decrease
the heart rate as well as information on general heart rate health.
Susan Hamilton crontributed to the research iOS programming as well
as on programming on other devices such as android and desktop. All GUI
programming was done by Susan. Also did the write up for the project
proposal and the written report as well as produced the oral presentation
poster hard copy.
Elijah Willie contributed to the research and the implementation of
the heart rate monitor in Matlab, focussing on the research of filtering and
noise reduction. Elijah was responsible for ensuring that the software for
producing the heart rate as well as the EKG graph were working. Elijah
also wrote the project update.
IX. Conclusions and Discussions
From the amount of time we had and the understanding we went into
the assignment I would say that what we accomplished and learned was
very good. From the algorithm we used to compute the heart rate and EKG
graph we found that the run time was decent do to many attempts to
simplify computation. Also with an error of approximately 2-3 values of
standard deviations we can declare that the accuracy was very decent. Time
constrants did play a large role in how much we could accomplish which is
a good lesson to learn in order to help us budget our time better in the
future, especially when a GUI must be produced. In general it was a great
way to learn the general application of the methods we learned in class. It
means that something that was initially just theory has way more meaning
to us and we can now broaden what we can apply the methods learned to.
X. Future Work
As mentioned above in section VII, some areas of our project were
not completed fully. One such section is that we would like to obtain more
information on heart rate. Information that we did obtain could be further
inhanced by further research. Also when the application is made we do not
want to provide the same suggestions again and again on how to lower and
raise the heart rate. It would create a more fun and interesting application if
we could provide ideas that were more creative such as meditating for half
an hour, but information such as this is harder to verify as FDA approved
and so this is where research is necessary. Another area that we need to
research is variation in heart rate from activity to activity. Simple tests did
show that the difference in heart rate for running and at rest activities is
sufficiently different, but research and testing on variation from studying
and waking up is necessary. On this not we would like to make the
application even more useful by providing a section which includes further
information for the user on what a healthy heart rate is and ways to achive a
better one in order to promote a healthy lifestyle. The last section that
requires future work is continued research into GUIs as well as porting
languages. That is our software code is in Matlab while iOS programming
is in xCode. This is obviously a fundamental future development in order to
actually publish the finished application we will have produced.
XI. References
Wilmore JH, et al. Physiology of Sport and Exercise. 4th ed. Champaign,
Ill.: Human Kinetics; 2008:162.
American College of Sports Medicine. ACSM's Resources for the Personal
Trainer. 3rd edition. Baltimore, Md.: Lippincott Williams & Wilkins; 2009:274.
Sauer WH. Normal sinus rhythm and sinus arrhythmia.
http://www.uptodate.com/index. Accessed June 28, 2012.
Your guide to physical activity and your heart. National Heart, Lung, and
Blood Institute. http://www.nhlbi.nih.gov/health/public/heart/#obesity.
Accessed June 25, 2012.
http://www.mayoclinic.org/diseases-conditions/heart-disease/in-depth/heart-
disease-prevention/art-20046502?pg=2
http://www.heart.org/HEARTORG/Conditions/More/MyHeartandStrokeNews/All-
About-Heart-Rate-Pulse_UCM_438850_Article.jsp
http://www.appcoda.com/enhance-your-simple-table-app-with-property-list/
https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneO
SProgrammingGuide/iPhoneAppProgrammingGuide.pdf
XII. Acknowledgements
Ghassan Hamarneh for providing motivation for our project and
Ignacio Mellado for providing detail methodology and code for the success
of the project. http://www.ignaciomellado.es/blog/Measuring-heart-rate-
with-a-smartphone-camera

More Related Content

Viewers also liked

Curs de formació SIRENA-UPC (Juny 2012)
Curs de formació SIRENA-UPC (Juny 2012)Curs de formació SIRENA-UPC (Juny 2012)
Curs de formació SIRENA-UPC (Juny 2012)
UPC-BarcelonaTech - Innovació i Comunitat
 
IDEAFIX GROUP
IDEAFIX GROUPIDEAFIX GROUP
IDEAFIX GROUP
IDEAFIX GROUP
 
MoneySuperSparkler
MoneySuperSparklerMoneySuperSparkler
MoneySuperSparkler
Alice Edwards
 
Apresentação enlicsul
Apresentação enlicsulApresentação enlicsul
Apresentação enlicsul
Giuliafs
 
урок 1 по твору Діккенса
урок 1 по твору Діккенсаурок 1 по твору Діккенса
урок 1 по твору Діккенса
Кристина Мельник
 
Check your Chips Report_Final
Check your Chips Report_FinalCheck your Chips Report_Final
Check your Chips Report_Final
Lauren Ensor
 
CV_updated_Chitwood2016
CV_updated_Chitwood2016CV_updated_Chitwood2016
CV_updated_Chitwood2016
Albert Chitwood
 
Pla d'estalvi energètic UPC. Resultats 2011
Pla d'estalvi energètic UPC. Resultats 2011Pla d'estalvi energètic UPC. Resultats 2011
Pla d'estalvi energètic UPC. Resultats 2011
UPC-BarcelonaTech - Innovació i Comunitat
 
Matemática&biologia exercicios
Matemática&biologia exerciciosMatemática&biologia exercicios
Matemática&biologia exercicios
Santos Santos
 
Capstone Presentation
Capstone PresentationCapstone Presentation
Capstone Presentation
Jaclyn Sayler
 
SchoolwideMotivationalStudentAssistance
SchoolwideMotivationalStudentAssistanceSchoolwideMotivationalStudentAssistance
SchoolwideMotivationalStudentAssistanceDavid Moore
 
160210107050
160210107050160210107050
160210107050
DivyaTeraiya
 

Viewers also liked (13)

Curs de formació SIRENA-UPC (Juny 2012)
Curs de formació SIRENA-UPC (Juny 2012)Curs de formació SIRENA-UPC (Juny 2012)
Curs de formació SIRENA-UPC (Juny 2012)
 
IDEAFIX GROUP
IDEAFIX GROUPIDEAFIX GROUP
IDEAFIX GROUP
 
MoneySuperSparkler
MoneySuperSparklerMoneySuperSparkler
MoneySuperSparkler
 
Apresentação enlicsul
Apresentação enlicsulApresentação enlicsul
Apresentação enlicsul
 
урок 1 по твору Діккенса
урок 1 по твору Діккенсаурок 1 по твору Діккенса
урок 1 по твору Діккенса
 
AAR_Etairiko_GR2016
AAR_Etairiko_GR2016AAR_Etairiko_GR2016
AAR_Etairiko_GR2016
 
Check your Chips Report_Final
Check your Chips Report_FinalCheck your Chips Report_Final
Check your Chips Report_Final
 
CV_updated_Chitwood2016
CV_updated_Chitwood2016CV_updated_Chitwood2016
CV_updated_Chitwood2016
 
Pla d'estalvi energètic UPC. Resultats 2011
Pla d'estalvi energètic UPC. Resultats 2011Pla d'estalvi energètic UPC. Resultats 2011
Pla d'estalvi energètic UPC. Resultats 2011
 
Matemática&biologia exercicios
Matemática&biologia exerciciosMatemática&biologia exercicios
Matemática&biologia exercicios
 
Capstone Presentation
Capstone PresentationCapstone Presentation
Capstone Presentation
 
SchoolwideMotivationalStudentAssistance
SchoolwideMotivationalStudentAssistanceSchoolwideMotivationalStudentAssistance
SchoolwideMotivationalStudentAssistance
 
160210107050
160210107050160210107050
160210107050
 

Similar to Target_heart_rate_monitor

My Resume
My ResumeMy Resume
My Resume
Heidi Maestas
 
Robust Speech Recognition Technique using Mat lab
Robust Speech Recognition Technique using Mat labRobust Speech Recognition Technique using Mat lab
Robust Speech Recognition Technique using Mat lab
IRJET Journal
 
Compression Using Wavelet Transform
Compression Using Wavelet TransformCompression Using Wavelet Transform
Compression Using Wavelet Transform
CSCJournals
 
Quality and Distortion Evaluation of Audio Signal by Spectrum
Quality and Distortion Evaluation of Audio Signal by SpectrumQuality and Distortion Evaluation of Audio Signal by Spectrum
Quality and Distortion Evaluation of Audio Signal by Spectrum
CSCJournals
 
Getting Started with TDS1000B / 2000B Digital Phosphor Oscilloscope Series
Getting Started with TDS1000B / 2000B  Digital Phosphor Oscilloscope SeriesGetting Started with TDS1000B / 2000B  Digital Phosphor Oscilloscope Series
Getting Started with TDS1000B / 2000B Digital Phosphor Oscilloscope Series
Premier Farnell
 
Detection of Lie by Involuntary Physiological Phenomena using Distance Camera
Detection of Lie by Involuntary Physiological Phenomena using Distance CameraDetection of Lie by Involuntary Physiological Phenomena using Distance Camera
Detection of Lie by Involuntary Physiological Phenomena using Distance Camera
IJCSIS Research Publications
 
IRJET- Voice based Gender Recognition
IRJET- Voice based Gender RecognitionIRJET- Voice based Gender Recognition
IRJET- Voice based Gender Recognition
IRJET Journal
 
Voice Recognition Accelerometers
Voice Recognition AccelerometersVoice Recognition Accelerometers
Voice Recognition Accelerometers
Nathan Glatz
 
ICT-GroupProject-Report2-NguyenDangHoa_2
ICT-GroupProject-Report2-NguyenDangHoa_2ICT-GroupProject-Report2-NguyenDangHoa_2
ICT-GroupProject-Report2-NguyenDangHoa_2
Minh Tuan Nguyen
 
Internet of Things Application: Soundsense
Internet of Things Application: SoundsenseInternet of Things Application: Soundsense
Internet of Things Application: Soundsense
Peter SHIN
 
Hand Gesture Controls for Digital TV using Mobile ARM Platform
Hand Gesture Controls for Digital TV using Mobile ARM PlatformHand Gesture Controls for Digital TV using Mobile ARM Platform
Hand Gesture Controls for Digital TV using Mobile ARM Platform
ijsrd.com
 
An Introduction to Various Features of Speech SignalSpeech features
An Introduction to Various Features of Speech SignalSpeech featuresAn Introduction to Various Features of Speech SignalSpeech features
An Introduction to Various Features of Speech SignalSpeech features
Sivaranjan Goswami
 
GENDER RECOGNITION SYSTEM USING SPEECH SIGNAL
GENDER RECOGNITION SYSTEM USING SPEECH SIGNALGENDER RECOGNITION SYSTEM USING SPEECH SIGNAL
GENDER RECOGNITION SYSTEM USING SPEECH SIGNAL
IJCSEIT Journal
 
FINAL report
FINAL reportFINAL report
FINAL report
Mandar Jadhav
 
Multimodal RGB-D+RF-based sensing for human movement analysis
Multimodal RGB-D+RF-based sensing for human movement analysisMultimodal RGB-D+RF-based sensing for human movement analysis
Multimodal RGB-D+RF-based sensing for human movement analysis
PetteriTeikariPhD
 
Artificial Intelligent Algorithm for the Analysis, Quality Speech & Different...
Artificial Intelligent Algorithm for the Analysis, Quality Speech & Different...Artificial Intelligent Algorithm for the Analysis, Quality Speech & Different...
Artificial Intelligent Algorithm for the Analysis, Quality Speech & Different...
IRJET Journal
 
IRJET - Touch-Less Heartbeat Detection and Cardiopulmonary Modeling
IRJET -  	  Touch-Less Heartbeat Detection and Cardiopulmonary ModelingIRJET -  	  Touch-Less Heartbeat Detection and Cardiopulmonary Modeling
IRJET - Touch-Less Heartbeat Detection and Cardiopulmonary Modeling
IRJET Journal
 
IRJET - Smart Vision System for Visually Impaired People
IRJET -  	  Smart Vision System for Visually Impaired PeopleIRJET -  	  Smart Vision System for Visually Impaired People
IRJET - Smart Vision System for Visually Impaired People
IRJET Journal
 
An Evaluation Of Lms Based Adaptive Filtering
An Evaluation Of Lms Based Adaptive FilteringAn Evaluation Of Lms Based Adaptive Filtering
An Evaluation Of Lms Based Adaptive Filtering
Renee Wardowski
 
How to not fail at security data analytics (by CxOSidekick)
How to not fail at security data analytics (by CxOSidekick)How to not fail at security data analytics (by CxOSidekick)
How to not fail at security data analytics (by CxOSidekick)
Dinis Cruz
 

Similar to Target_heart_rate_monitor (20)

My Resume
My ResumeMy Resume
My Resume
 
Robust Speech Recognition Technique using Mat lab
Robust Speech Recognition Technique using Mat labRobust Speech Recognition Technique using Mat lab
Robust Speech Recognition Technique using Mat lab
 
Compression Using Wavelet Transform
Compression Using Wavelet TransformCompression Using Wavelet Transform
Compression Using Wavelet Transform
 
Quality and Distortion Evaluation of Audio Signal by Spectrum
Quality and Distortion Evaluation of Audio Signal by SpectrumQuality and Distortion Evaluation of Audio Signal by Spectrum
Quality and Distortion Evaluation of Audio Signal by Spectrum
 
Getting Started with TDS1000B / 2000B Digital Phosphor Oscilloscope Series
Getting Started with TDS1000B / 2000B  Digital Phosphor Oscilloscope SeriesGetting Started with TDS1000B / 2000B  Digital Phosphor Oscilloscope Series
Getting Started with TDS1000B / 2000B Digital Phosphor Oscilloscope Series
 
Detection of Lie by Involuntary Physiological Phenomena using Distance Camera
Detection of Lie by Involuntary Physiological Phenomena using Distance CameraDetection of Lie by Involuntary Physiological Phenomena using Distance Camera
Detection of Lie by Involuntary Physiological Phenomena using Distance Camera
 
IRJET- Voice based Gender Recognition
IRJET- Voice based Gender RecognitionIRJET- Voice based Gender Recognition
IRJET- Voice based Gender Recognition
 
Voice Recognition Accelerometers
Voice Recognition AccelerometersVoice Recognition Accelerometers
Voice Recognition Accelerometers
 
ICT-GroupProject-Report2-NguyenDangHoa_2
ICT-GroupProject-Report2-NguyenDangHoa_2ICT-GroupProject-Report2-NguyenDangHoa_2
ICT-GroupProject-Report2-NguyenDangHoa_2
 
Internet of Things Application: Soundsense
Internet of Things Application: SoundsenseInternet of Things Application: Soundsense
Internet of Things Application: Soundsense
 
Hand Gesture Controls for Digital TV using Mobile ARM Platform
Hand Gesture Controls for Digital TV using Mobile ARM PlatformHand Gesture Controls for Digital TV using Mobile ARM Platform
Hand Gesture Controls for Digital TV using Mobile ARM Platform
 
An Introduction to Various Features of Speech SignalSpeech features
An Introduction to Various Features of Speech SignalSpeech featuresAn Introduction to Various Features of Speech SignalSpeech features
An Introduction to Various Features of Speech SignalSpeech features
 
GENDER RECOGNITION SYSTEM USING SPEECH SIGNAL
GENDER RECOGNITION SYSTEM USING SPEECH SIGNALGENDER RECOGNITION SYSTEM USING SPEECH SIGNAL
GENDER RECOGNITION SYSTEM USING SPEECH SIGNAL
 
FINAL report
FINAL reportFINAL report
FINAL report
 
Multimodal RGB-D+RF-based sensing for human movement analysis
Multimodal RGB-D+RF-based sensing for human movement analysisMultimodal RGB-D+RF-based sensing for human movement analysis
Multimodal RGB-D+RF-based sensing for human movement analysis
 
Artificial Intelligent Algorithm for the Analysis, Quality Speech & Different...
Artificial Intelligent Algorithm for the Analysis, Quality Speech & Different...Artificial Intelligent Algorithm for the Analysis, Quality Speech & Different...
Artificial Intelligent Algorithm for the Analysis, Quality Speech & Different...
 
IRJET - Touch-Less Heartbeat Detection and Cardiopulmonary Modeling
IRJET -  	  Touch-Less Heartbeat Detection and Cardiopulmonary ModelingIRJET -  	  Touch-Less Heartbeat Detection and Cardiopulmonary Modeling
IRJET - Touch-Less Heartbeat Detection and Cardiopulmonary Modeling
 
IRJET - Smart Vision System for Visually Impaired People
IRJET -  	  Smart Vision System for Visually Impaired PeopleIRJET -  	  Smart Vision System for Visually Impaired People
IRJET - Smart Vision System for Visually Impaired People
 
An Evaluation Of Lms Based Adaptive Filtering
An Evaluation Of Lms Based Adaptive FilteringAn Evaluation Of Lms Based Adaptive Filtering
An Evaluation Of Lms Based Adaptive Filtering
 
How to not fail at security data analytics (by CxOSidekick)
How to not fail at security data analytics (by CxOSidekick)How to not fail at security data analytics (by CxOSidekick)
How to not fail at security data analytics (by CxOSidekick)
 

More from Elijah Willie

Co-OP Presentation
Co-OP PresentationCo-OP Presentation
Co-OP Presentation
Elijah Willie
 
BC-Cancer ChimeraScan Presentation
BC-Cancer ChimeraScan PresentationBC-Cancer ChimeraScan Presentation
BC-Cancer ChimeraScan Presentation
Elijah Willie
 
Molecular_bilogy_lab_report_2
Molecular_bilogy_lab_report_2Molecular_bilogy_lab_report_2
Molecular_bilogy_lab_report_2
Elijah Willie
 
Molecular_bilogy_lab_report_1
Molecular_bilogy_lab_report_1Molecular_bilogy_lab_report_1
Molecular_bilogy_lab_report_1
Elijah Willie
 
Computational_biology_project_report
Computational_biology_project_reportComputational_biology_project_report
Computational_biology_project_report
Elijah Willie
 
Image_processing
Image_processingImage_processing
Image_processing
Elijah Willie
 
Fin_whales
Fin_whalesFin_whales
Fin_whales
Elijah Willie
 

More from Elijah Willie (7)

Co-OP Presentation
Co-OP PresentationCo-OP Presentation
Co-OP Presentation
 
BC-Cancer ChimeraScan Presentation
BC-Cancer ChimeraScan PresentationBC-Cancer ChimeraScan Presentation
BC-Cancer ChimeraScan Presentation
 
Molecular_bilogy_lab_report_2
Molecular_bilogy_lab_report_2Molecular_bilogy_lab_report_2
Molecular_bilogy_lab_report_2
 
Molecular_bilogy_lab_report_1
Molecular_bilogy_lab_report_1Molecular_bilogy_lab_report_1
Molecular_bilogy_lab_report_1
 
Computational_biology_project_report
Computational_biology_project_reportComputational_biology_project_report
Computational_biology_project_report
 
Image_processing
Image_processingImage_processing
Image_processing
 
Fin_whales
Fin_whalesFin_whales
Fin_whales
 

Target_heart_rate_monitor

  • 1. Target Heart Rate Monitor (THRM) Susan Hamilton, Omar Nada, and Elijah Willie skhamilt@sfu.ca, onada@sfu.ca, and ewillie@sfu.ca Department of Computing Science CMPT 340 Ghassan Hamarneh
  • 2. I. Abstract By taking a 30 second video of a user finger and measuring the change in colour intensities we are able to obtain the heart rate in beats per minute of the user. This is found by using several methods of computing the brightness of the signal then passing that under a band-pass filtering. From this point using a sliding window we in sequence find the fourier transform of the signal, find the maximum peaks, and smoothing these peaks. From these sequence of methods we obtained the EKG graph which provides a visual understanding for the user. Because we already had the users optimal heart rate of ther user we can advise them on how to obtain their optimal heart rate for the given activity. II. Keywords  Heart Rate or Heart Beat  Brightness Signal Computation  Band-Pass Filtering  Fast Fourier Transform  Sliding Window  Sampling Frequency  Peak Detection  Smoothing  Image Noise or Signal-to-Noise Ratio (SNR) III. Introduction It is often that we find ourselves wanting to participate in a particular activity such as studying, exercising, or just waking up or going to sleep, but complaining about not being in the right state of mind. THRM’s main purpose is to assist in achieving this optimal state by monitoring the heart rate. Over a testing period THRM is able to obtain an optimal heart rate specific to the user. From this point on THRM is able to monitor the users heart rate using their mobile device and advise in ways to either rase or lower their heart rate in a short amount of time in order to allow the user to achieve the optimal state necessary for peak performance in their activity. The motivation of this project is to assist the user to obtain their own personalized heart rate monitor. That is to say that not everyone is the same and what works for one person may not work for another. Also heart rate could be affected by a person’s height, weight, gender, and general state of health. THRM is also specialized in that though it will provide initial activities such as those listed above, it will also allow the user to
  • 3. personalize their own activity tags specific to their needs. No one person is the same and neither should THRM only cater to a small rage of activities. In the rest of the report we will cover the material that is used, section IV, and section V will cover the methods that were used to construct our results and accomplishments which will then be covered, section VI and section VII. Following this we will overview the contributions of individual members, section VIII, as well as acknowledge referenced material in section, XII. We will also provide our discussions on our conclusions and what could be coming in the future for this project in sections IX and X. IV. Material  Human subjects  Mobile device or computer with camera  30 second clip to obtain the signal required to analyze and produce a EKG graph V. Methods i. Video Signal Analysis o Since research shows the human heartbeat is between 60 and 200 beats per minute to avoid aliasing we followed the Nyquist Sapling Theorem where we doubled the maximum value. ii. Brightness Signal Computation o We looked at the red value and averaged their values. o Where W=frame width H=frame height [n,x,y,1] % since looking at red only video = VideoReader('path to your video file here'); brightness = zeros(1, video.NumberOfFrames); for i = 1:video.NumberOfFrames, frame = read(video, i); redPlane = frame(:, :, 1); bght(i)=sum(sum(redPlane))/(size(frame,1)*size(frame,2)); end iii. Band-Pass Filtering o This step attenuates frequencies not within the interested region. o Helps to remove extra noise.
  • 4. o In particular we used second-order Butterworth filter – applies the ‘maximally flat‘. BPM_L = 40; % Heart rate lower limit [bpm] BPM_H = 230; % Heart rate higher limit [bpm] FILTER_STABILIZATION_TIME = 1; % [seconds] % Butterworth frequencies must be in [0, 1], 1 corresponds to half the sampling rate [b, a] = butter(2, [((BPM_L / 60) / v.FrameRate * 2), ((BPM_H/60)/v.FrameRate*2)]); filtBrightness = filter(b, a, brightness); % Cut the initial stabilization time filtBrightness = filtBrightness((v.FrameRate * FILTER_STABILIZATION_TIME + 1):size(filtBrightness, 2)); iv. Fourier Transform o We used the discrete fourier trasform to change it from the time domain to the frequency domain. o Used fft(signal) in Matlab o Sliding window was used to repeat peak detection and smoothing over every .5seconds of a 6 second frame o  Where Fr= frequency resolution Fs=sampling frequency N=number of window samples Tw=window time duration  Window length effects accuracy: higher the window time better the Fr but the lower the time accuracy v. Peak Detection o Use findpeaks function in Matlab we find a sample data if the point is larger than its two neighbours and then we use max function to find the max peak. o Then change it to the fourier tranform vector. % Translate the freq range to indices within FFT vector rangeOfInterest = ((BPM_L:BPM_H) / 60) * (size(fftMagnitude, 2) / sampFrequency) + 1; % Find peaks in the range of interest [peaksValues,peakIndices]=findpeaks(fftMagnitude(rangeO fInterest)); % Find the highest peak [maxPeakValue, maxPeakIndex] = max(peaksValues); % Translate the peak index to an FFT vector index bpmFreqIx = rangeOfInterest(peakIndices(maxPeakIndex));
  • 5. % Get the freq in bpm corresponding to the highest peak bpmPk = (bpmFreqIx - 1) * (sampFrequency / size(fftMagnitude, 2)) * 60; vi. Smoothing o We have now found teh most powerful spot in frequency o Now correlate around the fourier transform around the peak using zero-padding fftResolution = 1 / WINDOW_SECONDS; lowFreq = bpmPeak / 60 - 0.5 * fftResolution; smoothingResolution = SMOOTHING_RESOLUTION / 60; testFreqs = round(fftResolution / smoothingResolution); power = zeros(1, testFreqs); freqs = (0:testFreqs -1)*smoothingResolution + lowFreq; for k = 1:testFreqs, re = 0; im = 0; for j = 0:(size(b, 2) - 1), phi = 2 * pi * freqs(h) * (j / samplingFreq); re = re + b(j+1) * cos(phi); im = im + b(j+1) * sin(phi); end %only need to find the maximum, we use power power(k) = re * re + im * im; end [maxPeakValue, maxPeakIndex] = max(power); smoothedBpm = 60 * freqs(maxPeakIndex); VI. Results When we film a 30 second video of a finger placed on the screen we obtain the heart rate in bpm and a graph showing the heart rate for that frame and how it changed over time Sleeping Exercising
  • 6. VII. Accomplishments For a project such as this, it was difficult to know what was feesable to accomplish within the given time restrictions as well as without experience and knowledge in the areas we would be attempting to delve into. With this being said we were able to accomplish success in many of the important areas of the proposed project. The fundamental part of the assignment we put as foremost necessary to accomplish was the functional heart rate monitor using the camera of a mobile device or laptop. This we were able to achieve due to online resources (see section XII for our acknowledgements). With a some tweaking we were able to apply multiple methods (described in section V) in taking a signal and removing noise to find the heart rate of the individual. We were also able to find a wealth of resources on heart rate. We did meet an opstacle here with ensuring that the information we obtained was FDA approved. With this being said we were able to find quite a few works that cited information which was FDA approved. With this problem also came a fundamental lack of knowledge on heart rate. In using a testing period where the user would have their heart rate tested when they were in their optimal state we were able to overcome the need to know in depth knowledge on what science says an optimal heart rate should be given a wide range of factors such as weight, height, and gender. Another detail is to know by how much deviation of the heart rate should be considered over or under the optimal heart rate and we did do a bit of testing with various activities, but this is an area that could use further testing and research. The one area that proved to be the largest obstacle was that of the graphic user interface. Initially we had decided to focus on an iOS device application using xCode. Though many hours were spent on this, due to a lack of previous experience by any of the members this area was progressing rather slowly. We also came to realize that Apple required a license to publish applications and that we would perhaps not wish to make an iOS device application, but instead an Android application as well as a laptop or desktop application. Do to the time constraint we decided that it was more important to ensure that the actual software was working and that we obtained a plentiful of information was obtained for the application before we focussed on producing the GUI. VIII. Contributions All members helped one another in the various areas one advicement or on research and understanding. With this in mind, below is listed the assigned duties of each member and what their main focus was on.
  • 7. Omar Nada contributed mainly to the research of all information pertaining to the heart rate. Information on how to increase and decrease the heart rate as well as information on general heart rate health. Susan Hamilton crontributed to the research iOS programming as well as on programming on other devices such as android and desktop. All GUI programming was done by Susan. Also did the write up for the project proposal and the written report as well as produced the oral presentation poster hard copy. Elijah Willie contributed to the research and the implementation of the heart rate monitor in Matlab, focussing on the research of filtering and noise reduction. Elijah was responsible for ensuring that the software for producing the heart rate as well as the EKG graph were working. Elijah also wrote the project update. IX. Conclusions and Discussions From the amount of time we had and the understanding we went into the assignment I would say that what we accomplished and learned was very good. From the algorithm we used to compute the heart rate and EKG graph we found that the run time was decent do to many attempts to simplify computation. Also with an error of approximately 2-3 values of standard deviations we can declare that the accuracy was very decent. Time constrants did play a large role in how much we could accomplish which is a good lesson to learn in order to help us budget our time better in the future, especially when a GUI must be produced. In general it was a great way to learn the general application of the methods we learned in class. It means that something that was initially just theory has way more meaning to us and we can now broaden what we can apply the methods learned to. X. Future Work As mentioned above in section VII, some areas of our project were not completed fully. One such section is that we would like to obtain more information on heart rate. Information that we did obtain could be further inhanced by further research. Also when the application is made we do not want to provide the same suggestions again and again on how to lower and raise the heart rate. It would create a more fun and interesting application if we could provide ideas that were more creative such as meditating for half an hour, but information such as this is harder to verify as FDA approved and so this is where research is necessary. Another area that we need to research is variation in heart rate from activity to activity. Simple tests did show that the difference in heart rate for running and at rest activities is
  • 8. sufficiently different, but research and testing on variation from studying and waking up is necessary. On this not we would like to make the application even more useful by providing a section which includes further information for the user on what a healthy heart rate is and ways to achive a better one in order to promote a healthy lifestyle. The last section that requires future work is continued research into GUIs as well as porting languages. That is our software code is in Matlab while iOS programming is in xCode. This is obviously a fundamental future development in order to actually publish the finished application we will have produced. XI. References Wilmore JH, et al. Physiology of Sport and Exercise. 4th ed. Champaign, Ill.: Human Kinetics; 2008:162. American College of Sports Medicine. ACSM's Resources for the Personal Trainer. 3rd edition. Baltimore, Md.: Lippincott Williams & Wilkins; 2009:274. Sauer WH. Normal sinus rhythm and sinus arrhythmia. http://www.uptodate.com/index. Accessed June 28, 2012. Your guide to physical activity and your heart. National Heart, Lung, and Blood Institute. http://www.nhlbi.nih.gov/health/public/heart/#obesity. Accessed June 25, 2012. http://www.mayoclinic.org/diseases-conditions/heart-disease/in-depth/heart- disease-prevention/art-20046502?pg=2 http://www.heart.org/HEARTORG/Conditions/More/MyHeartandStrokeNews/All- About-Heart-Rate-Pulse_UCM_438850_Article.jsp http://www.appcoda.com/enhance-your-simple-table-app-with-property-list/ https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneO SProgrammingGuide/iPhoneAppProgrammingGuide.pdf XII. Acknowledgements Ghassan Hamarneh for providing motivation for our project and Ignacio Mellado for providing detail methodology and code for the success of the project. http://www.ignaciomellado.es/blog/Measuring-heart-rate- with-a-smartphone-camera