Wednesday Nerd Fun: Oximetry with Ruby and R

These posts are getting pretty esoteric, which may be a sign that I should put the series on hold for a while. Feed back is welcome. In any event, here’s some midweek entertainment for the coders among you:

A popular and fast way to effectively get the heart rate is pulse oximetry. A pulse oximeter is a device placed on a thin part of a person’s body, often a fingertip or earlobe. Light of different wavelengths (usually red and infrared) is then passed through that part of the body to a photodetector. The oximeter works by measuring the amounts of red and infrared light absorbed by the hemoglobin and oxyhemoglobin in the blood to determine how oxygenated the blood is. Because this absorption happens in pulses as the heart pumps oxygenated blood throughout the body, the heart rate can also be determined.

We are not going to build an oximeter, but in this post we’ll use the same concepts used in oximetry to determine the heart rate. We will record a video as we pass light through our finger for a short duration of time. With each beat of the heart, more or less blood flows through our body, including our finger. The blood flowing through our finger will block different amounts of the light accordingly. If we calculate the light intensity of each frame of the video we captured, we can chart the amount of blood flowing through our finger at different points in time, therefore getting the heart rate.

Continue here.

About these ads

About You Study Politics, Right?

Graduate student in political science at Duke University.
This entry was posted in Uncategorized and tagged , , , , , , , , , , , , . Bookmark the permalink.

One Response to Wednesday Nerd Fun: Oximetry with Ruby and R

  1. Absolutely fantastic article. You made the calculating Heart Rate simple.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s