DIY ECG?

UPDATE: An improved ECG design was posted in August, 2016.
Check out: http://www.swharden.com/wp/2016-08-08-diy-ecg-with-1-op-amp/

Last night my wife put her head on my chest while we were watching a movie. A minute or two later I felt a light sinking feeling in my upper chest, and my wife looked up at me in horror. “Your heart stopped beating!” I assured her that everything was okay (it quickly resumed), and that it happens all the time. I feel the sinking feeling often, know it’s because my heart is briefly beating irregularly, and assume it’s normal. After all, your heart isn’t a robot, it’s a living organ doing the best it can. It’s never perfectly regular, and presumably everybody has momentary irregularities, they just don’t notice them. When I got in bed I began wondering how regular irregular heartbeats are. What would the chances be that I have some kind of arrhythmia? I’ve had a checkup not too long ago by a family practice physician who used a stethoscope on my back to listen to my heartbeat, and he didn’t notice anything. Then again, how often do general practice doctors detect subtle arrhythmia?
I know that whatever problem I have is likely too small to cause any serious troubles, but at the same time I’m becoming obsessed as to determining exactly what my problem is. How many times a day does my heart skip beats? What about nighttime? If only there were some way to record heartbeat data, then I could analyze it and determine the severity of my problem. But wait, data? That would be hours of heartbeat recordings… that means… YES!!!! HOME MADE DO-IT-YOURSELF HARDWARE! WRITING SOFTWARE TO ANALYZE LARGE AMOUNT OF DATA! SUPER-COOL SCIENCY STUFF THAT I CAN MAKE MYSELF, COMBINING BASIC ELECTRONICS WITH BIOMEDICAL DATA ANALYSIS AND, HARAY, PROGRAMMING WITH PYTHON!
Naturally, my thoughts began to overwhelm my reality as soon as Python entered the scene. I wondered how I could use my PC to record my heartbeat, without spending much money on hardware, and only using software I write myself. I pondered this on the way to work this morning, and came up with two possible methods:
Method 1: acoustical recordings. This would be the easiest way to record my heartbeat. I could tape a stethoscope to my chest, insert a small microphone in the earpiece, connect the microphone to my PC, and record sound data for several hours. Theoretically it would work, but it would be highly prone to noise from breathing, and I would have to lay perfectly still to avoid noise caused by movements. The data (trace) would have to be smoothed, processed with a band-pass filter (to eliminate interference), and heartbeats could be calculated. However, this would only give me heart beat time information…
Method 1: electrical recordings. This would be a little more complicated, but generate much more information. I could record the electrical activity of my heart, and the charts would look like the cool electrocardiograms (ECGs) that you see on TV shows and stuff. I would have to build some circuity to amplify the 1mV heartbeat signal recorded from electrodes taped to my chest, but then again what’s more fun than ghetto-building circuits! (I apologize for any people reading this blog who actually live in the ghetto and enjoy building circuits.) I did a little Googling and found that similar things have been done before with a handful of diodes, resisters, and 6 op-amps. I think I’m going to follow the guide on this page and build the circuit seen below:


Schematic of a crude ECG circuit

Supposedly, the data I can obtain looks something like the image at the bottom of this blog entry. I’d attach 3 electrodes to my body (chest, arm, and leg), hook them up to my little circuit, then connect to circuit to my PCs sound card. I’d record the trace (maybe while I sleep?) and analyze it with Python, Numpy, Scipy, and Matplotlib (gosh I love Python). There are several websites which demonstrate how to build DIY ECG recording devices, but none of these actually ANALYZE the data they obtain! Hopefully I could fill this little niche on the internet. We’ll see what happens. I have my thesis to work on, and a whole bunch of other stuff on my plate right now.

A sample recording from the circuit pictured above

The terms assigned to different parts of the heartbeat

UPDATE: I found an extremely crude ECG circuit which I can make from parts I already have at my house. It has tons of noise, but maybe I can filter it out? Perhaps I’ll try this tonight? [ponders]