LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to calculate power in specific frequency band

Is your program not functioning like you expect it to?  Or are you having trouble optimizing the code?  If you're not seeing the results that you expect, then it might help to see what the results you are getting and what you expect them to be.

 

If you're looking for programming/optimization tips, then you might want to start by modularizing your code.  Even though you might be prototyping it right now, it could be helpful down the line to have already created subVIs that do some of the operations you're looking for.  This should help clean the code and make it easier to debug if there is a problem.  I'm not quite sure how to optimize the algorithm itself, just because I'm not too familiar with heart rate analysis :), but I don't see any obvious problems.

Jared S.
Applications Engineering
National Instruments
0 Kudos
Message 11 of 19
(1,759 Views)

The problem is that I don't have any known correct data to compare my results to, so I am having to trust the calculations.

 

If you could clarify that I am on the right track with the frequency bins then that would be helpful. Here is my understanding so far :

 

Frequency resolution = Sample rate / Number of samples

 

Therefore in my example (Sample rate 100Hz, Number of samples 10,000) then the resolution is 0.1Hz and  the number of bins in the output array (from FFT) is 10,000. 

 

One thing that springs to mind is that this would give an upper frequency limit of 10,000 * 0.1 or 1,000Hz. Surely this is wrong since it is way above the nyquist frequency?

 

Second question is that if I want to look at power for the the bottom 1Hz of data, then is this simply 10 array elements of data (1 hz / frequency resolution = 10) ? So my output array elements 1-11 would contain the required data (I omit element 0 as according to the FFT help page this contains the DC component).

 

Does this all sound sensible so far? 🙂

0 Kudos
Message 12 of 19
(1,739 Views)
You are correct in thinking that the frequency resolution should equal sample rate / number of samples. However, I think your math was a little off.  100 Hz / 10000 should be 0.01 Hz.  Also, a quick reference to the frequency resolution is to look at the df component of the output of the PSD measurement.  This is the frequency resolution of the measurement, so you don't have to know all of the other components beforehand.  It also looks like the number of samples in the output of the FFT should only be 5000 to also meet the maximum measurable frequency of 50 Hz.  Are you seeing more samples coming back?
Jared S.
Applications Engineering
National Instruments
0 Kudos
Message 13 of 19
(1,726 Views)

Yes my math was a little off there, oops 🙂 Thanks for the suggestion of looking at the df component of the PSD instead of trying to work it out beforehand.

With regard to your question of the number of samples. My data starts off as an array of heart rate intervals such as the following

 

0.60

0.61

0.60

0.65

0.70

0.62

 

 

I am taking a subset of this (say for example the last 20 beats), and then passing this to the "Align and Resample" VI with spline interpolation.

 

I see a potential issue here in getting the required 5000 samples though, since I want to use a subset of the recent heart beat times over no more than a 30 second period. This means I start off with only 30-40 samples and would have to interpolate all the rest, would this introduce a lot of error?

0 Kudos
Message 14 of 19
(1,706 Views)

I have a feeling that something is fundamental wrong in your setup. In order to do HRV analysis you need to collect a lot of heart  beat to beat intervals and then do analysis on the result. You can not use the acquired SPO2 signal for this analysis. As your result will be a soup from of many signal sources. You must separate the beat to beat variations from your signal. Also in order to have a good HRV analysis you must do continuous measurement for a quite long period, say 10 minutes.



Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
0 Kudos
Message 15 of 19
(1,691 Views)

NikT,

 

Heart rate data is non-uniformly sampled data.  This means that you cannot use Fourier transform methods (such as PSD) directly because they require uniform sampling. Coq Rouge mentioned this in message 5.

 

You may need to spend more time with the mathematics and the literature related to your task before worrying about the program.

 

Lynn 

0 Kudos
Message 16 of 19
(1,680 Views)

johnsold wrote:

NikT,

 

Heart rate data is non-uniformly sampled data.  This means that you cannot use Fourier transform methods (such as PSD) directly because they require uniform sampling. Coq Rouge mentioned this in message 5.

 

You may need to spend more time with the mathematics and the literature related to your task before worrying about the program.

 

Lynn 


That will be a good idea. Have you discussed your setup with your teacher? Because I do not think you are on the correct track at all.  



Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
0 Kudos
Message 17 of 19
(1,661 Views)

There is no SP02 data, the array is an array of R-R intervals in seconds.

 

To perform frequency domain measures on this data it is plotted on a tachogram

 

I cite http://www.macses.ucsf.edu/research/allostatic/heartrate.php summary

 

"Frequency measures involve the spectral analysis of HRV. Briefly, R-R interval data are represented on a tachogram (Figure 1), in which the y-axis plots the R-R intervals, and the x-axis the total number of beats. Spectral analysis of the tachogram transforms the signal from time to frequency on the x-axis, by representing the signal as a combination of sine and cosine waves, with different amplitudes and frequencies"

 

This is what I am doing, by using the R-R intervals as the Y component and resampling/interpolating this to make a uniformly spaced sequence.

 

However after revisiting the above journal I have noticed an oversight on my part - I was interpolating with a fixed dt value which is naturally wrong since the R-R intervals are ocurring at different time points! I am glad that you are questioning the basis of the data as it is making me double check everything 🙂

 

The standard I am following is that published by American Heart Association/European Society of Cardiology and I think I am following it properly 

 

"The series of data subjected to spectral analysis can be obtained in different ways. A useful pictorial representation of the data is the discrete event series (DES), that is, the plot of RiRi-1 interval versus time (indicated at Ri occurrence), which is an irregularly time-sampled signal. Nevertheless, spectral analysis of the sequence of instantaneous heart rates has also been used in many studies.26 The spectrum of the HRV signal is generally calculated either from the RR interval tachogram (RR durations versus number of progressive beats; see Fig 5aDown,b) or by interpolating the DES,"

 

A quick question - What is the most reliable way to interpolate an irregularly time-sampled signal? Until now I was incorrectly using the Align and Resample VI which only allows a fixed dt.

0 Kudos
Message 18 of 19
(1,644 Views)

I still do no not think your approach is optimal. You may not be aware of it but we have a Biomedical User Group here http://decibel.ni.com/content/groups/biomedical-user-group.

So why not move your question to that group.



Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
0 Kudos
Message 19 of 19
(1,636 Views)