LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Triggering on peak of ECG waveform

Hey,

 

Basically, Ive got to simulate an ECG waveform within labview and then use it to trigger solenoid valves. For now, I am trying to use the highest peak (Point R) to turn on an LED. Firstly, I could only find an ECG simulator on NI which just returns the shape, and not a continuous wave. So with a lot of help from a member of university staff, I have attached a VI where the data was transformed into dynamic and then the amplitude and data number is constantly being read.

 

I have the following problems:

 

How can I make the proccess start again after the end of the waveform, as it eventually gives an amplitude of 0 after the data point where the wave finishes.

 

How Can I make the led come on from the time the graph is at the middle of the 2nd highest peak till it turns off at the middle of the lowest peak, and stays off untill it reaches the middle of the 2nd highest peak again, and so on....?

 

I thought of 2 ways, firstly to find the highest peak and use equations based on the BPM (note: the vi given is for 60BPM) to offset the triggers on the 2nd and lowest peaks. And a much simpler,; to find the requied peaks by finding peaks within a certain threshold range. But how can i look for a peak within a range of amplitudes? The find peaks and valleys function only has one threshold input.

 

Thanks in advance

0 Kudos
Message 1 of 6
(3,327 Views)

Without any data it is hard to tell what is going on on your program.  Either post your data file or run your program and then make the value in Array default. Save. Post the VI with the data saved as default.

 

I do not understand your question about restarting.  Your VI will keep analyzing the same data until you press stop and keep reading the file and analyzing its data until you press stop2.  The for loop contributes nothing.  Remove it.  Since it appears that you are reading a .csv file rather than a Measurement file, you might be able to use the Read from Spreadsheet File.vi with transpose set to True and wire directly to the First Row output getting the 1D array. Use a waveform Graph rather than a Chart and wire the array to it directly.

 

Use Array Max & Min on the Peak Detector Amplitudes output.  Then remove the maximum value and run it again to get the 2nd highest peak.  Of course you have no data wired to the Peak Detector so ther will be no peaks to detect.

 

Also your =? comparison on the Locations array will likely produce all false results because you are comparing an integer "i" with a double precison value which is interpolated to give the peak location. The value is effectively a fractional index value and will almost never be exactly equal to an integer.

 

Lynn

0 Kudos
Message 2 of 6
(3,317 Views)

Thanx for the reply. the data is attachted.

I got it from exporting data from a graph using the vi from http://zone.ni.com/devzone/cda/epd/p/id/6188 

What im stuck on is triggering/ turning an LED on (for example), by triggering from the highest peak. Also the other problem, which I need to tackle first is how do I make the ECG wave continuous. I couldnt find a continuous waveform ECG, so I used that one, and converted it like i have, but after that wave finishes then the amplitude is zero, but i want the wave to continue, or restart, in order to be able to trigger on the peak, and then keep the led on until the 2nd highest peak, when it is turned off.

 

Let me know if I have not explained something properly.

 

And I have now taken off the overall while while loop, but theres no point me attaching that, thers no change to the output.

Download All
0 Kudos
Message 3 of 6
(3,302 Views)

Hi SaintSoulja,

 

I have changed the code a little to enable you to constantly make the ECG wave continous. The measurement file is first read, then the array is indexed and the array size is counted. Inside the loop the array size is compared against the index of the while loop using the Quotient and Remainder function, this effectively indexes the array and once the inputs x and y are the same, the array wraps back round to 0.

 

Hopefully this shoud give you a good start to add into your program. With this program you would only need to generate one ECG into your file.

 

 

Regards,

Ben B.

Applications Engineer
National Instruments UK & Ireland

"I've looked into the reset button, the science is impossible!"
Message 4 of 6
(3,267 Views)

Thanks for that benjamin. Ive now attached the latest version where I am trying to keep the LED on while the ECG is in systole. Could you tell me why the LED sometimes rapidly blinks randomly, or sometimes misses beat.

 

Also, I would like to attach this to a DAQ to turn a valve on using this VI. but the DAQ assist does not take in boolean data. How can I convert to appropraite form of data?

 

I tried to use a combo box to link differerent ECG waveforms (with different BPM extracted as data from static ecg generator vi) but I do not know how to link differen file paths, could you direct me to somewhere where this is told, or explain?

 

I coudltn attach the data set this time for some reason, but if I use the ECG vi to export the data for say 70, or 80 etc BPM, they all come up on the graph within the same data range on the x-axis of the graph in my VI. But do they have diiferent time scales? Like for 60 BPM, the whole one ECG wave form should be 1 second long, and 70 BPM should be 0.857seconds long.

 

 

Thanks Smiley Happy

0 Kudos
Message 5 of 6
(3,249 Views)

You do not have any timing data in your lower loop, so it cannot run at a rate proportional to the original ECG data.  The .csv file you posted earlier also does not have good timing data.  The first 440 data elements in column zero are "00:00.0".  I am guessing that your sample rate is 8000-10000 samples per second, but without the actual value if is impossible to get the timing right. 

 

The minimum (non-zero) wait is 1 ms, so data sampled at rates above 1 kHz cannot easily be simulated at approximately actual time.  What is the purpose of the upper loop?  Turning Beat 2 on at each peak and off 300 ms later can be done in the lower loop with a couple of shift registers and no local variables.

 

I do not understand what you are asking about the combo box for different waveforms.  Are you trying to select from a set of predefined files?  Are the files all in the same directory or folder? Are other files in that same directory?

 

Lynn

0 Kudos
Message 6 of 6
(3,238 Views)