# Gas station without pumps

## 2021 November 25

### PVC and pulse

Filed under: Circuits course — gasstationwithoutpumps @ 15:17
Tags: , ,

In PVC: Premature Ventricular Contraction, I posted some ECG recordings of my heart to show the premature ventricular contractions.  But that post brought up two questions for me:

1. Do the PVCs pump blood around, or do they do nothing?
2. How are PVCs affected by exercise?

In this post, I’ll try to answer the first question, by simultaneously recording both a Lead I ECG signal and a fingertip pulse with an optical pulse monitor.  The amplifier for the optical pulse monitor has a 0.35Hz–5.6Hz filter on it, there is some rounding and delay of the pulse waveform, but I was too lazy to build a new log-transimpedance amplifier without that filter.

I recorded for about 209 seconds, and I got 119 spikes and 56 PVCs.  The overall pulse rate was 50.0bpm, but the sinus rhythm was only about 33.9bpm with 15.8 PVCs/min.  That is a very high rate of PVCs.

I wrote a program that bandpass-filtered  (0.2–50Hz, 4th-order Bessel filter, both forwards and backwards in time) the signal and then identified where all the R spikes were. The program also separated the normal pulses from the PVCs.  This program was specific to my recordings of Lead I—it does not attempt to identify PVCs from an arbitrary ECG!  I also had the program average all the normal waveforms and all the PVC waveforms, lining them up by the detected peak of the R spike.

The solid lines are the ECG signals (in mV) and the dashed lines are the optical pulse signal (in dB, because I was using a log-transimpedance amplifier).

So what can I determine from this plot?

First, the P-spike is missing from the PVCs—this is part of the definition of a premature ventricular contraction, so is hardly surprising.

Second, the T-spike that represents the repolarization wave seems to happen at about the same time for both normal and PVC events, though the shape of the waveforms is different.

Third, my pulse is slow enough and irregular enough that the averaging does not show adjacent ECG signals within this 1.4-second window, but the optical pulse signal shows that the PVC is happening sooner relative to the recovery from the previous pressure pulse than a normal beat. (Again what we would expect from a premature contraction.)

The optical pulse at the fingertip had about the same delay from the R spike for both PVCs and normal pulses—the difference may be due to my defining the R spike as happening at the positive peak, when a more accurate time for the R spike on the PVC would be slightly later.  The PVC pulses were definitely weaker at the fingertips than the normal pulses, but were still fairly strong, so the premature ventricular contractions are pumping blood, but not as much as a normal heartbeat.

In a subsequent post, I’ll try looking at what exercise does to the PVCs.

## 2021 November 10

### PVC: Premature Ventricular Contraction

Filed under: Circuits course — gasstationwithoutpumps @ 14:05
Tags: , , ,

This fall, when I went to my doctor for my standard annual physical, she thought my heartbeat sounded a bit strange, so she ordered a 12-lead ECG and an echocardiogram.  The imaging report from the cardiologist told me some things I already knew from the tests done for Project Baseline almost 3 years ago—namely that there was some sclerosis on the aortic valve, but no stenosis. There were a couple of new things reported, though: frequent premature ventricular contractions (PVCs) and mild concentric hypertrophy of the left ventricle.

I looked up what PVCs are and how they are diagnosed, since they were reported on both the ECG report and the echocardiogram report. PVCs are extra contractions of the ventricle, triggered by something in the ventricle rather than the sinus rhythm from the sinoatrial node.  The diagnosis on the ECG is pretty easy, as there is no P spike from the contraction of the atrium, and R spike travels in a different direction from a normal beat—radiating from the different initiation point.  That sounded like something I could see with my home-built ECG that uses just an MCP6004 op-amp chip, a few discrete passive parts, and a Teensy LC running PteroDAQ.  So I set up the ECG and recorded for about 5½ minutes on Lead I, then for about 4⅓ minutes on Lead II.

I saw 37 beats that looked odd in the Lead I recording, or about once every 9 seconds, which certainly qualifies as “frequent”.

Here is a 10-second stretch of Lead I, showing both normal beats and two of the PVCs.

Here is a normal beat and part of a second normal beat, as a detail of the 10-second interval. I’ve aligned the R spike to be at about 400 ms.

Here is one of the PVCs—the first from the 10-second section shown above. I’ve aligned the R spike to be at about 400ms.

The PVC is clearly missing the P spike, the R spike suggests an orientation for the depolarization wave almost at right angles to Lead I, and the T spike is larger than usual.  I have not seen (or at least not noticed) this waveform in my years of playing with my home ECG, so I think that the PVCs have developed in just the past 2 years (they were not mentioned on my stress ECG and echocardiogram reports from Project Baseline in December 2018, and they would be hard to miss, so I don’t think I had them then).

Formerly, both my Lead I and Lead II recordings looked like the canonical PQRST complex that one sees in popular representations of heartbeats, but now my Lead II shows a different pattern, indicating that the direction of the depolarization wave has changed.

Here is a normal pulse from Lead II. This is not what I used to see, so I think that even the normal depolarization waves are traveling in a different direction than they used to.

So I do have something new going on with my heart, even though I am not experiencing any symptoms from it. From what I’ve been able to tell from reading on the web, PVCs are common and not dangerous—unless one gets other symptoms.

The “mild concentric left ventricular hypertrophy” in the imaging report might explain the change in the direction of the depolarization wave, but I don’t understand the cause of the hypertrophy. What I’ve found online indicates that high blood pressure is a common cause for hypertrophy, but I don’t have high blood pressure.  The analysis of the echocardiogram imaging report was “Your heart ultrasound is essentially normal with no significant abnormalities.”

So there doesn’t seem to be anything to be concerned about with these changes in my heart, but I suspect that my doctor will want to monitor the changes on a periodic basis.

## 2018 December 16

### Project Baseline

Filed under: Circuits course — gasstationwithoutpumps @ 10:58
Tags: , , ,

This month I joined a research project, Project Baseline, that is collecting detailed medical information on 10,000 subjects across the US.  I’ve not joined as a researcher, but as subject.

I wish I could tell you precisely what the goals of Project Baseline are, but none of their materials are very clear about that. The name suggests that they are trying to collect information about what results to expect from medical tests for asymptomatic patients—so many of the standard medical tests are only applied to people who are already ill that there is little idea what the results would be for a normal person.  Because the study runs for 4 years for each subject, they may also be looking for early-warning signals from tests—do any of the tests predict problems up to 4 years in advance?

The structure of the study is fairly straightforward—each subject gets extensive medical tests on an annual basis, wears a watch that monitors pulse and motion, and keeps a sleep monitor in their bed.  The selection of subjects is pretty broad: almost any US resident 18 or older who can get to one of the study sites is eligible.(You have not be allergic to nickel or metal jewelry, be able to speak and read English or Spanish, not work for Project Baseline, and be willing to share health information with them.)

I’ve been wanting to do a bunch of baseline fitness and health tests for a few years, but the retail cost of them has been prohibitive—with Project Baseline, not only were the tests free, but they pay me a tiny stipend for participating.  They also issued me a fancy watch for the pulse monitor and ECG and a sleep monitor to put under my mattress.

The watch, a Verily Life Sciences “Study Watch” has a nice E-ink display, but the firmware (BASELINE 000.048.009.BSL) is set up to make it less useful to me than my previous watch, a dime-store Casio model.  The study watch shows me only the date and time—and the time only to the nearest minute and only in 12-hour, not 24-hour format.  My dime-store watch showed seconds, could be set to 24-hour mode, and could be used as a stopwatch—none of which is possible with the study watch.

The wristwatch supposedly has an accelerometer for step counting—not a very useful feature for someone whose main aerobic exercise is bicycling. They should make an ankle bracelet for bicyclists—one that doesn’t look like the GPS ankle monitors worn by felons.  In any case, the step counter feature is not very useful, as the watch has no bluetooth synchronization, and only updates records when it is returned to its charging station.  That limitation makes it rather weird that the step count information is available only through a phone app, and not the Project Baseline web portal.  Because I don’t have a cellphone (and don’t see it as worthwhile to get one to view day-old step information), I have no access to this data record either.

The study watch is taking my pulse continually—it has a pair of green LEDs on the back of the watch that sample at 30 Hz (600µs on, 32.733 ms off).  It will also do a 1-minute ECG recording whenever I request one, which I’m supposed to do at least once a day.  Unfortunately, it never tells me my pulse nor is there anywhere I can look up either the pulse recordings or the ECG recordings, both of which I would find very interesting.  I’d really like to know what my pulse gets up to on my commute up the hill in the morning, and how long it takes to recover afterwards.  That information is being sent to Project Baseline, but they are not sharing it with me.

Similarly, the under-mattress sleep tracker is recording something about my sleep that I would be interested in knowing, but I have no access to that data either.

I had two 4–5-hour sessions of medical tests in Palo Alto as part of the study.  These seemed to focus mainly on cardiovascular tests, though there was a large panel of blood and urine tests also, and I had to ship them a bowl full of frozen poop by FedEx.

The first day included measuring my ankle-branchial index (the ratio of systolic blood pressure in the ankles to systolic blood pressure in the arms), to check for peripheral vascular disease.  One part of that is interesting, in that they listen to the blood flow with an ultrasonic Doppler-shift probe, which allows them to listen to a single artery at a time, presumably with more accuracy than just using a stethoscope.

They also took about 300 mL of my blood in many tiny tubes.  They ended up having to stick me three times: the first time the phlebotomist missed the vein, the second time they got only halfway through the tubes before the blood clotted enough to seal off the puncture, and the third time they managed to finish (though that puncture was the most painful of the lot).  I was not impressed with the competence of the phlebotomist—I’ve had less discomfort from the bigger needles of blood donations.

Other samples collected that day included urine, saliva (for oral microbiome I think, but possibly for genetic tests), tears, and swabs of ears, nose, inside cheeks.

They also took a 12-lead ECG, which I did not get to see.

They also spent a lot of time trying to get my medical history recorded.  I had brought detailed notes (which I left with them), but they had to enter it all into Google Forms, which seemed very poorly chosen for the task.

The second visit included some simple strength and balance tests, timed walking, vision screening, photos of cornea and retina, pulmonary function (including gas exchange), an echocardiogram, a stress EKG and echocardiogram, CT scan of my chest, and chest X-ray.  The timed walking consisted of some very short timed walks at low speed and high speed, then a 6-minute walk in the corridor at “normal speed”.  The person measuring that thought I might have set a course record in their hallway at 630m, but that is only 6.3 km/h or 3.9 mph, which not a particularly fast walking pace.  I suspect that many people find it difficult to walk at a normal pace when you have to reverse direction every 20m.

The pulmonary function and echocardiogram tests were the most interesting—it was particularly cool to see my heart beating and the false color showing the flow rate of the blood through the valves.

This is the MicroGard II mouthpiece that was used for the pulmonary tests.

The commercial mouthpiece used in the pulmonary function test might be useful for student lab kits next year, in place of the PVC elbow and barbed connector that the students currently use for their breath-pressure measurements.  The cost per student would be about the same, but I would have to make adapters as lab equipment—the circular tube fits tightly in a 1″ PVC slip connector, so it would not be difficult to make the adapters, but it would cost about \$100 to make 25 adapters with barbed connectors and a 2mm vent hole.  The main advantages to using the commercial mouthpiece are that it has a filter to prevent cross-contamination, that it holds the mouth comfortably open, that it comes with a nose clip to prevent air leakage through the nose, and that it is a standard medical component, and so will seem more real to students.  The main disadvantage is that students would not get to practice using the drill press to drill the 2mm holes in the PVC elbows.  Of course, they would still get to drill holes in Lego bricks for the pulse-monitor lab.

The stress ECG and echocardiogram involved walking (and starting to jog) on a treadmill until the cardiologist thought I was working hard enough and had me immediately lie down to get an echocardiogram with my heart pounding.  I believe that the intent was to get me up to my maximum heart rate, but I don’t think we achieved that, as I was not feeling that I was going all out when the cardiologist started telling me to stop any time. I got my heart rate to 163 bpm (which is over the normal guideline of 220 − age in years), but I think I could have gone higher.  If they do the test again next year, I’ll have to tell the cardiologist not to hint at when to stop but to just keep increasing the treadmill speed until I call a halt.

They were supposed to administer a hearing test, but I don’t remember getting one.  It has been about a year since I last was tested by an audiologist, but I don’t think that there has been much change since then.  If they want the data, they can probably access my medical records.

Project Baseline has sent me a few results from the lab tests.  All the numerous blood and urinalysis standard lab tests came back in the normal range, except the cholesterol test—and I already knew about my cholesterol.  Besides which, the blood tests were not done fasting, so the cholesterol test was rather useless anyway—I did not bother adding it to my cholesterol records.

They also sent me some results from my CAT scan, which were again mainly normal: the biggest reports were that I had no spleen (which I knew already) and that I may have had a viral infection in my lung (I did have a cold that week).  The main thing they were looking for, calcification in the heart and arteries, came up with 0 calcium scores, though they also reported “trace focus of atherosclerotic calcification in the left anterior descending artery” and “calcifications of the aortic valve”.  Aortic valve calcification is a common condition in older adults, but “usually doesn’t cause significant heart problems, but requires regular checkups to make sure your condition isn’t worsening” according to the Mayo Clinic.  I suspect that Project Baseline will be doing those regular checkups for the next few years, but after the study ends I’ll have to make a point of having my valves checked every few years.

The chest X-rays did tell me something I didn’t know—I have “azygos fissure”, which occurs in 0.4–1.2% of the population (different sources give different frequencies, depending on how the estimate was made).  An azygos fissure is a result of a normal variant in embryonic development, in which the right lung grows around the right posterior cardinal vein, one of the precursors of the azygos vein, instead of the vein moving to the left as the lung grows. It generally is of no clinical significance, unless thoracic surgery is needed or it gets misinterpreted as something else when images are read.

## 2017 December 18

### EKG without amplifier

Filed under: Circuits course,Data acquisition — gasstationwithoutpumps @ 18:24
Tags: , , , ,

I have done a lot of EKG projects on this blog, mostly for the Applied Electronics course, where an EKG amplifier is Lab 12, but some just for fun. Today I decided to see whether one could do an EKG with just the Teensy LC board or just an Analog Discovery 2 USB oscilloscope.

The project was partly inspired by the Digilent post DIY ECG using a Analog Discovery 2 and LabVIEW, which I saw the title for and assumed that they were using just the USB oscilloscope.  It turns out that wasn’t what they meant—it is just a simple 6-op-amp EKG amplifier looked at with the USB oscilloscope.

The setup I tried was about as simple as you can get—I put on three electrodes wired up as Lead I (see earlier post for this configuration), connected the body electrode to ground, and the other two electrodes to the plus and minus leads of channel 1 of the Analog Discovery 2.

The signal I got was quite small (about 1mV) and buried in 60Hz noise:

The raw signal from the oscilloscope, sampling at 1200 Hz, shows some spiking from the pulse, but a lot of noise. The big R spike is only about 3 LSB, so quantization noise is a problem.

I ran the recording through a digital filter to bandpass filter it to 0.1Hz–100Hz and put in a notch from 58Hz to 62Hz. The 100Hz low-pass had the effect of averaging out the noise, producing a signal with much finer resolution than the raw ADC values:

After filtering, the EKG signal is fairly clear. I don’t recommend trying to use only a couple of the lower-order bits of an ADC, but it is surprising how much information can be recovered by the filter.

I also tried using a Teensy LC board running PteroDAQ, using the A10–A11 differential channel. I had to bias my body between 0V and 3.3V, so I used a pair of 120kΩ resistors (one to GND, one to 3.3V) to connect to the body electrode.

Once again the raw signal was not great:

The signal had less noise than the signal to the Analog Discovery 2, but the signal was smaller also, negating the value of the finer steps of the ADC on the Teensy LC.

Once again, digital filtering restored the signal:

The signal-to-noise ratio here looks a little worse than for the Analog Discovery 2, despite the raw signal looking cleaner.

I managed to get a cleaner signal for the Analog Discovery 2 by turning off the surge protector, so that there was no 60Hz current anywhere nearby. The results after filtering were no better (and possibly worse) than from the signal with the 60Hz interference, so I did not bother plotting them for this post.

My conclusion is that it is possible to get EKG signals without adding an amplifier, but you can only see the signal clearly if you do some filtering.  I’ll have to decide whether to recommend to students that they record signals directly from the EKG electrodes to get an idea what their amplifiers have to work with.

## 2015 June 3

### Crude theremin

On Monday I again had 2 lectures: one in Banana Slug Genomics on the Burrows-Wheeler Transform and FM index, and one in applied electronics finishing up the EKG preparation and starting into optional material.

The BWT and FM-index lecture was a bit rough though I had prepped on the material for a fair amount of time over the weekend.  I think that the written presentations I’d used to prep from (which included the Li and Durbin paper on BWA) were better than my lecture, so I ended up pointing the students to them as well, hoping that my lecture would at least make them more willing to click through and read the paper.

In the electronics class, I provided some feedback on the lab reports (reminding students once again how to figure out the DC bias resistor for an electret microphone).  Over the weekend I had finally caught up on the grading, so of course Monday saw a huge stack of redone work being turned in—I did the prelab grading Monday night, but I did not have the heart to start on the redone work last night or tonight.

After the feedback, and questions from the class on the EKG lab, I gave the EKG demo (which had worked fine before cycling up the hill).  Needless to say, it did not work when I hooked everything up in front of a live audience.  But I turned this into a teachable moment by explaining what I thought the problem was (bad electrode connections, because touching the reference wire produced a change in the output), and getting out three new electrodes, adding a a little electrode gel, sticking them on next to the ones I was already wearing, and moving the clips over.  Luckily, that was the problem, so I was able to demonstrate debugging, even with no lab equipment.

The EKG demo concluded the required material for the course, and so I asked students for suggestions on what I should cover next.  I suggested the electronics of the nanopore and nanopipette labs, and asked them for other ideas. One student wanted me to explain how theremins work, and a couple of others agreed that would be an interesting topic.  So I finished Monday’s lecture on the nanopore electronics (basically telling them it was just a transimpedance amplifier, but engineered for high gain and very low noise, and talking a bit about the copper boxes around the stations to reduce capacitive coupling), and told them I’d try to talk about theremins on Wednesday.

Tuesday’s lab went fairly smoothly, but I was kept busy helping students debug their designs—most often the problem was miswiring, but some students had electrodes that weren’t making good contact.  I had on a set of working electrodes, so that we could swap the leads to my electrodes to see if the problem was the electrodes or their boards.  A lot of the students had a lot more 60Hz noise pick up (even with my electrodes) than I was getting, and I could not always determine why. In some cases it was simply long wires on the breadboard.  They’ll be soldering up their EKGs on Thursday, and the wiring should be much more compact there.

Tuesday night I read up on a bunch of analog circuits relevant to Theremin design, and in today’s class I presented

• a block diagram for a theremin (two oscillators—one with an antenna, a mixer, and a low-pass filter to pass only the difference frequency)
• I showed them a rather crude theremin that they could implement from what they already knew: two relaxation oscillators using Schmitt triggers, an XOR gate, and an RC low-pass filter. (Only the XOR gate was new to them.)
• I then talked about mixers, presenting a ring modulator (which they probably didn’t understand, as we’ve not done transformers except in passing), a simple two-resistors plus a diode non-linear mixer, and a synchronous decoder using a switch to change an op amp gain from +1 to –1.  I mentioned a couple of Wikipedia articles they could look up for other mixer designs (Gilbert Cell and frequency mixer).
• I then introduced the notion of a sine-wave oscillator as a loop with gain exactly 1 and a phase change of 2πn for some integer n.
• The first oscillator I showed them was a Wien oscillator using an op amp, for which I derived that at $\omega RC = 1$ the phase change of the positive feedback was 0 and the gain was 1/3, so we could set the positive gain to 3 to satisfy the requirements.  I mentioned the first Hewlett-Packard oscillator, and the trick of using an incandescent light bulb to control the gain and avoid clipping.  I showed them a plot of the amplitude and phase change for the feedback circuit, using gnuplot functions that they are familiar with from their own modeling.
• Next I showed them an LC tank circuit, and derived the infinite impedance resonance $\omega^2 LC = 1$.
• I then got to a Colpitts oscillator, showing them a possible circuit using an op amp, and how to model it as cascaded voltage dividers using gnuplot.  I showed them that the phase change of the feedback was 180° and that the phase change moved away from 180° very fast.  I was running out of time, so I briefly mentioned the Hartley oscillator and the Clapp oscillator, but didn’t really go into them.

On Friday, I plan to cover one-transistor amplifiers (common emitter with emitter degeneration and common collector—I probably won’t do common base), as those seem to be popular in theremin designs.

Tonight, since I was not willing to face grading, I decided to try out the crude relaxation oscillator Theremin.  Here is the circuit I ended up with (not including the bypass capacitors):

I used the potentiometer on the second oscillator to do crude pitch matching for the two oscillators, just looking at the period on an oscilloscope. The emitter-follower amplifier was used to get enough current to drive the loudspeaker.

The crude theremin only sort-of works.  I could get high-pitched theremin-like noises from it, but when the difference frequency dropped to 500Hz, the two oscillators phase-locked and the speaker went silent (often with very irritating on-off stuttering). The phase lock occurred even though the oscillators were on different chips at opposite ends of the breadboard, and I had 10µF ceramic bypass capacitors on each Schmitt trigger package and a 470µF electrolytic on the middle of the power bus.  Everything was powered to 5V with the USB power from my MacBook Pro.

I also often got 60Hz modulation of the signal, often as a on/off square wave, when the frequency difference was close to the point where the oscillators phase locked.

I’m not sure how the oscillators are getting coupled so that they phase lock when the difference frequency is small, so I’m not sure how to fix the problem.  The 60Hz sensitivity is almost inherent in the relaxation oscillator design, since the thresholds for the hysteresis on the Schmitt trigger remain fixed, but the hand near the antenna couples in 60Hz interference.  I suppose that over the summer I should try building a theremin with Colpitts oscillators or Clapp oscillators, to see if that works any better.

Next Page »