LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

help on autocorrelation

Ratnam, you started a post in the middle of this thread (unable to display waveform / multiple recording). I have transferred the discussion to a new thread so that it will get the proper visibility.

To answer your questions.  Your main problem is you are collecting 1000 data points at 5kHz.  Heart rates tend to be somewhere between 1Hz and 2Hz (60 to 120 beats/minute).  Since you only have 200ms of data, you end up with about 1/5 of a heartbeat.  This means your autocorrelation is essentially noise. Decrease your acquisition rate to 500Hz and your number of data points to 2000.  This will give you four seconds of data.  Then run your autocorrelation.  You should probably look for peaks, not valleys.  Find the peaks (use a threshold to remove noise).  Either subtract the distance between two adjacent peaks to get the heart period, or, for some averaging, do a line fit on peak index vs. position and use the slope to get the period.

As an alternate, you may consider using Extract Single Tone Information.vi on your data.  It will give you the frequency directly.  However, it is not really accurate for less than about ten periods, which would be ten seconds of data.  I don't know what your update times need to be.

As you may expect, there are techniques to get faster update times (once per beat), but they require some fairly advanced programming techniques . I would strongly suggest you read the attachment in the first thread about large LabVIEW applications before you attempt such a thing. If applied, the information there will save you a lot of time and effort in the long run.

Good Luck! Smiley Happy

Message 1 of 3
(3,274 Views)
Hi Dfgrey, Thanks for that explanation.Is it possible for you troubleshoot my program.I've got no time .My dateline for submission  is coming monday.I will be  grateful for your help.Thanks
0 Kudos
Message 2 of 3
(3,268 Views)
Ratnam,  I do not have DAQmx Base installed on my computer, nor do I have your collection apparatus or sample waveforms.  In addition, the code you posted is missing a couple of filter subVIs.  However, I can give you a couple of simple things to do that may solve your problem.
  1. Use a 1D fetch from the DAQ device, that way you will not have to convert the array from 2D to 1D.
  2. Remove all filtering between the output of the DAQ device and the autocorrelation function, unless you really know you need them.  You probably don't.  Autocorrelation usually takes care of this problem.  You almost always better off using raw data than filtered data for almost any analysis.  Viewing is another matter...
  3. Use peak, not valley for your peak find algorithm.
  4. Clean up your code.  The plethora of backward going wires makes debugging very difficult.  Wire flow should be top left to bottom right in most cases.
  5. Plan your algorithm and understand it before you attempt to implement it.  You will save a lot of time by doing this and will end up being more creative in the process.  You can find good explanations for most of the algorithms in LabVIEW in Numerical Recipes in C, by Press et. al.  Most university and major city libraries have a copy.
  6. Make sure you are not following this example Smiley Wink.
Good luck! You should be able to make this work by Monday if you stop and think about it.

0 Kudos
Message 3 of 3
(3,237 Views)