LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

peak detectors width for ecg

Hello guys, 

I'm new to labview (started working with it a week ago) and I managed to do a program which detects the peaks in a sinus wave, (it works very well, thanks to the advice I got here) in order to calculate the frequency (I'm doing a project for my university).

Now, I have to adapt this technique for ecg signal. I'm using the VirtualBench of NI, so the minimum sample rate I get is 15.26k, I use a sample rate of 16k and I'm taking the measurements in a window of 2s. So I tried to put a width of 8k, but it's not working very well... Sometimes the frequency goes to 3.. Any suggestion of how to adjust the width?

Any help is VERY appreciated!  

0 Kudos
Message 1 of 20
(3,128 Views)

Have you used a real oscilloscope?  [I'm old enough to think that a "real" oscilloscope has a CRT where a moving electron beam "paints" the CRT with a "sweeping" beam whose Y position varies as the input "signal" voltage].  Almost all oscilloscopes are Digital, meaning there's (somewhere) a fast A/D converter and "software" that plays out the (vastly-over-sampled) signal at the rate you specify.  So the "minimum sampling rate" of the Virtual Bench is more-or-less meaningless -- you are over-sampling, so you need to figure out how to see the signal on a time scale that makes sense to you.  A simple thing to do would be a "poor-man's Low Pass Filter" -- sample at, say, 20kHz, take 200 points and average them (this takes 200/20k = 10 msec) and display it at an "effective" sampling rate of 100 Hz, probably reasonable for an EKG signal.

 

Doesn't the Virtual Bench "do this for you"?  [I've seen it at shows, but never played with one -- I thought it would "act like" an oscilloscope emulator].

 

Bob Schor

0 Kudos
Message 2 of 20
(3,098 Views)

Yes I've used the analogical oscilloscope, but in my case I have to work with the Virtual Bench because of my thesis... I acquire the signal from there and then take the measurements using my labview program. 

I will try the filter to sample at a lower sample rate. Will this solution be ok in terms of memory? If I sample at a lower rate, will I have memory enough to take the measurements for like one hour? 

 

The virtual bench actually oversamples and doesn't let me go lower than a circa 15k sample rate... and I'm having problems in the term of memory

Can you give me an idea what to do?

0 Kudos
Message 3 of 20
(3,069 Views)

16k sampling means 16,000 samples in a second. Assume somebody has a pulse rate of 60 beats per minute, that is 1 beat per 16,000 samples that you acquired. If you take 32,000 samples then you should see 2 beats.

 

I am not a medical doctor, but I believe the ECG is a series of short pulses. Did you read the advice Henrik_Volkers gave you here 

 

I quote

"The help file tell you to take not more than half width of the pulse,"

You set a width of 8k, which implies 0.5s. Is an ECG pulse really that wide, I thought it was much narrower. Have you tried adjusting the width, like Henrik suggested?

 

mcduff

Message 4 of 20
(3,063 Views)

Do you have an envelope?  Turn it over and take out a pencil -- we're going to do a "back-of-the-envelope" calculation.

  1. EKG comes because the heart is beating.  We're going to assume the heart beats once/second.
  2. We know the EKG has some peaks (they even have names!) -- we'll assume that the "peak" is less than 20% of a beat, which means we want to analyze a signal on the order of 0.2 seconds.
  3. We'll "guess" that if we have 100 points to play with, we should be able to find the peak.  100 points in 0.2 sec means 1 point every 2 msec, or a Sampling Rate of 500 Hz.
  4. You have a Virtual Bench which has a high "native" sampling rate, with a minimum around 16kHz.  Let's set it to sample at 20 kHz.  We want to get samples every 2 msec, so we'll take 40 samples at 20 kHz, which takes 2 msec.
  5. But we only want a single sample!  OK, we average, or else we "choose one".  What are the advantages of each method?  [There is an "advantage" to simply using the first sample instead of averaging, and it has nothing to do with speed of processing ...].
  6. Presto -- we've just "created" a Virtual A/D Converter running at 500 Hz from our Virtual Bench.  Plot this data (take 1000 points so you'll see several heartbeats -- how many do you expect to see?) and now start thinking about scaling finding the peaks.

Bob Schor

Message 5 of 20
(3,055 Views)

Congrats newest Knight of NI, Bob Schor!

 

As usual your posts are always like an excited teacher trying to drive home a point to his student 🙂

[BADGE NAME]

0 Kudos
Message 6 of 20
(3,048 Views)

Thank you, BlessedK.  My only quibble is I think of myself as "calm", not "excited" ...

 

Bob Schor

0 Kudos
Message 7 of 20
(3,040 Views)

Mcduff, 

I read the advices several times, now I think I understand it better. I adjusted the width (to 4k, with my sample rate at 16k) and it works!

Bob_Schor, thank you so much for your detailed advice! I get the method that you suggested, but my question is wether the memory will support that kind of data, and maybe how to do the average in just taking one sample... (or maybe by doing the average my memory will not take the undeeded samples?) 

0 Kudos
Message 8 of 20
(3,015 Views)

I noticed that with a filter I can adjust the sample rate of the signal. I attached here the vi, you can see what my code looks like

0 Kudos
Message 9 of 20
(3,012 Views)

You need to do some signal processing on your input to remove stuff/noise, low frequency drifts, etc. Here is an idea to try, not sure how well it works, but it may point you in the right/wrong direction.

 

 

Snap22.png

 

snip.png

 

mcduff

0 Kudos
Message 10 of 20
(3,007 Views)