hrv spectral analysis
20 views (last 30 days)
Show older comments
Hello, I've been trying to perform spectral analysis for hrv for some time already but there all the time problems with it.
I'm using such code:
%Spectral Analysis - WELCH metod
odstepRR=odstepRR.*1000; %odstepRR it an array with NN intervals
fs = 400;
maxF=fs/2;
odstepRR=detrend(odstepRR,'linear');
odstepRR=odstepRR-mean(odstepRR);
%Calculate PSD
[PSD,F] = pwelch(odstepRR,128,64,[],fs); %uses a hamming window
VLF = [0.0033 0.04];
LF = [0.04 0.15];
HF = [0.15 0.4];
% find the indexes corresponding to the VLF, LF, and HF bands
iVLF= (F>=VLF(1)) & (F<=VLF(2));
iLF = (F>=LF(1)) & (F<=LF(2));
iHF = (F>=HF(1)) & (F<=HF(2));
% calculate areas, within the freq bands (ms^2)
aVLF=trapz(F(iVLF),PSD(iVLF));
set(handles.vlf, 'string', num2str(aVLF));
aLF=trapz(F(iLF),PSD(iLF));
set(handles.lf, 'string', num2str(LF));
aHF=trapz(F(iHF),PSD(iHF));
set(handles.hf, 'string', num2str(aHF));
aTotal=aVLF+aLF+aHF;
set(handles.tp, 'string', num2str(aTotal));
% calculate areas relative to the total area (%)
% pVLF=(aVLF/aTotal)*100;
% pLF=(aLF/aTotal)*100;
% pHF=(aHF/aTotal)*100;
%calculate LF/HF ratio
lfhf =aLF/aHF;
axes(handles.axes5);
set(handles.text45, 'visible', 'on')
set(handles.axes5, 'visible', 'on')
%plot area under PSD curve
area(F(:),PSD(:),'FaceColor',[.6 .6 .6]);
grid on;
What am I doing wrong? The program doesn't count the spectral parameters (TP, HF, LF) and the plot is in different freq bands than it should be (on X axis freq should be 0.0-0.5 Hz). Shall be grateful for any help. ;)
3 Comments
Apoorva Gangula
on 24 May 2021
What is odstepRR here?
I'm doing a project for fetal heart rate analysis and need to do spectral analysis as a part of it
please answer this
Accepted Answer
Wayne King
on 14 Mar 2012
Hi Olga, I think your problem is that your frequency resolution is too poor.
You are only obtaining PSD estimates at steps of 1.5625 Hz. Look at:
diff(F)
This is based on your sampling frequency and window (segment) length.
Therefore the code:
VLF = [0.0033 0.04];
LF = [0.04 0.15];
HF = [0.15 0.4];
iVLF= (F>=VLF(1)) & (F<=VLF(2));
iLF = (F>=LF(1)) & (F<=LF(2));
iHF = (F>=HF(1)) & (F<=HF(2));
Is going to return a vector of zeros for iVLF, iLF, and iHF. Look at the output for
nnz(iVLF)
nnz(iLF)
nnz(iHF)
You are trying to obtain power estimates on a grid that is much finer than your frequency resolution.
6 Comments
Bach
on 27 Jul 2012
you can increase the number of FFT to improve the resolution. The frequency resolution = fs / nfft.
More Answers (3)
Pradeep Kumar R
on 23 Feb 2016
hi guys i'm doing a project of fetal heart rate variability analysis i'm finding difficult to find and plot the heart rate of fetal i've extracted the fetal signal but only heart rate part i'm not able to come to a solution please help me with that.i've attached my code please help me out
0 Comments
KYAW KYAW
on 26 Jul 2012
Dear Wayne King,
I am facing problem for optimizing the peak frequency location in frequency domain analysis for normal and low respiratory rate.
Theoretically, the highest peak frequency must occured at 0.16667 Hz but in pratical is 0.164 to 0.1799(mostly 0.176 above).
My frequency resolution in X axis is 0.0078 which is in FFT only and I optimized then I got the wrost results.
The low frequency lower than 0.10 Hz(low respiratory rate) has issue for spectral analysis that is can't get the peak frequency in 0.10 Hz around there.
Please advise me why theoretical and experimental results are different and can't achieve for very low frequency.
In addition, why the peak frequeny occured in FFT is not same as AR Burg in some of the cases.
Thanks and best regards
Pradeep Kumar R
on 23 Feb 2016
hi guys i'm doing a project of fetal heart rate variability analysis i'm finding difficult to find and plot the heart rate of fetal i've extracted the fetal signal but only heart rate part i'm not able to come to a solution please help me with that.i've attached my code please help me out
0 Comments
See Also
Categories
Find more on Spectral Estimation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!