LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Real-Time Processing of ECG Acquired Using NI DAQ and Labview

Hi All,

 

I am acquiring ECG waveform data using NI WiFi Chassis (cDAQ 9191) and DAQ Module NI 9234.

 

Everything works well.

 

However, I want to do some real-time signal processing on the ECG data coming in. Typically, I am looking to analyze about 1 second of data chunk to identify R-peaks in it. For this, I need time information and y-value for each sample and I need to analyze ~ 2000 samples in one go each as the data comes in. This is because my sampling frequency is ~2000 Hz.

 

I seem to have figured out how to get time stamp and y-value. But don't seem to understand how I can increase the amount of information at my disposal to be able to do the analysis. So, for now, I have [t1, t2] and [y1, y2]. But I need [t1, t2, ..., t1000] and [y1, y2, ..., y1000] anytime in real time. That is, the last 1000 values (and time stamps) of the data coming in.

 

I am attaching what I have. Any guidance would be greatly appreciated.

 

Cheers,

 

Saif

Download All
0 Kudos
Message 1 of 9
(5,140 Views)

In the 'Get Waveform Components' function, other than Y, you will get "t0" and "dt". t0 is the time stamp for the first sample and increment it by 'dt' with each sample, to get the to get the time stamp for those samples.

 

And if your sampling frequency is 2000, you would need t1, t2,...t2000; not upto t1000.

0 Kudos
Message 2 of 9
(5,117 Views)

So you need an array of values and an array of timestamps.  See below.

 

Also, please keep us informed on your progress.  There are many others here who are trying to do the same thing.  See here.

 

Capture.JPG

 

 

 

 

http://www.medicollector.com
0 Kudos
Message 3 of 9
(5,088 Views)

Thank you so much Josborne!

 

What you have attached seems exactly what I was looking for!

 

Definately going to try it tonight and will post back what I got and how I am looking to find R-peaks in real-time, etc.

 

Thanks again!

 

Cheers,

 

Saif

0 Kudos
Message 4 of 9
(5,080 Views)

Hello Josborne,

 

I tried what you suggested. 

 

Please see attachments.

 

I still have couple of problems:

 

1. My buffer size is 1000. So, if I use Index = 990, I will see last 10 values. If I use Index = 0, I will see last 1000 values. At a sampling rate of 2000 Hz, this is 0.5 sec of data. But if I want to see more chunk of data, how do I do it? For example, can I see last 4 sec of data (8000 samples)?

 

2. The time values don't seem to change (update) as more data comes in. They are stuck at 3.44243E+09.

 

Once I resolve the above 2 issues, I can continue with the processing and may have more subsequent Qs.

 

Thanks again!

 

Saif

Download All
0 Kudos
Message 5 of 9
(5,074 Views)

Well there are two ways to do it:

 

1.  Increase the size of your DAQ buffer.  The problem with that is that your system will pause and only return data every 4 seconds.  That does not allow your program to "flow" well.

 

2.  A better solution is to create your own internal buffer using a shift register.  So every iteration in your while loop, you get a small chunk of data from the DAQ buffer (e.g. 0.5 seconds) which you then append to your own larger buffer which is stored in a shift register (could be the last 10 seconds of data). 

 

Not sure about the timestamp issue.  But try right-clicking on the control and select Display Format and change it to to display "Absolute Time" as seen below:

 

Capture.JPG

http://www.medicollector.com
0 Kudos
Message 6 of 9
(5,047 Views)

Thanks so much Josborne!

 

I tried to work with the 1000 samples buffer I have because I realized that I can distinctly find one R-peak in this interval.

 

I then used the peak detection VI. For a given threshold, this VI detects the peak and gives unique sample number too. I use dt to get exact time of beat in seconds. 

 

Please see attachments.

 

What's your opinion?

 

Now I want to compute instantaneous heart rate (HR). That is, the difference between two consecutive R-peak positions. I do have the latest R-peak position. How to store the previous location and subtract previous from new position. I think a shift register can do it. I tried it but it did not seem to work.

 

Any help would be greatly appreciated, as always

 

Cheers,

 

Saif

 

0 Kudos
Message 7 of 9
(5,032 Views)

Actually, I had a second Q too:

 

Is there a Matlab equivalent of HOLD ON in Labview. Ideally, it would be great if I could plot dots at the exact R-peak positions on the top plot which shows 5 seconds of real-time data.

 

Cheers,

 

Saif

0 Kudos
Message 8 of 9
(5,029 Views)

Hi Saif,

 

A Shift Register is definetly the method to solve your previous questions about subtracting the current value from the previous value. 

 

I am not really sure what you mean by "Hold On" because I havent used MatLab in over a decade (wow, I am getting old).  However, you can definitely overlay dots on a graph.  The best method is to use cursors.  To access the cursors in a graph, you need to create a "property node" for your graph.

 

In general, it sounds to me like you need to learn more of the basics of LabVIEW.  I'd seriously reccomend you spend 2 days going through some basic training (you can try starting here).  Also learn to use the basic online help functions in LabVIEW.  To learn more about shift registers and cursors, go the the HELP menu in LV and select EXAMPLE FINDER.  You will find lots of example code.  Navigate to some examples such as:

 

Fundamentals > Graphs and Charts > Cursor.vi

Fundamentals >Loops and Structures > Find Maximum Value from Array.vi

 

The "loops and structures" example is a basic VI that demonstrates shift registers.

http://www.medicollector.com
0 Kudos
Message 9 of 9
(5,021 Views)