Average normalised Shannon energy for phonocardigraphy signals

4 views (last 30 days)
I have a code that has to calculate average normalised Shannon energy for phonocardigraphy signals but have a problem with calculating standard deviation. mayve something wrong with my code above this expression. Can somedody help me. please.
function segmentation_Shennon
close all
clear all
% Загружаем файл с данными
[F,Fs] = audioread('1.wav');
pcg = F(:,2);
t=0:1/Fs:(length(F)-1)/Fs;
%%Нормируем и фильтруем сигнал фильтром Чебышева 1 8го порядка НЧ с частотой среда 882 Гц
pcg_filter = chebushev1(pcg,Fs);
pcg_norm = pcg_filter./abs(max(pcg_filter));
%рассчитываем энергию Шеннона
shennon_energy= -((pcg_norm.^2).*log(pcg_norm.^2));
figure(1)
plot(t,shennon_energy)
%рассчитываем усредненную энергию Шеннона в сегменте длительностью 0,02с
%с перекрытием 0.01 с
win=0.002*Fs;
i=1;
k=1;
Es=[];
Es_t=[];
P=[];
while i<length(pcg_norm)
for i=i:i+win
square = pcg_norm(i).^2;
Es(k) = -1/win * sum( square .* log(square));
end
ES_t(k)=t(i);
i=i+round(win/2);
k=k+1;
end
% нормируем усреднeнyую энергию Шеннона
M_Es = (mean(Es)); %среднее значение энергии сегмента
S_Es = (std(Es(k-1))); %стандартное отклонение энергии сегмента
P(k) = (Es(k-1)-M_Es)/S_Es; % Нормированная усредненная энергия Шеннона,
plot(t,P)
  2 Comments
Brian Sang;Sang
Brian Sang;Sang on 18 Apr 2022
Hi, I understand what question you are trying to solve as it refers to Heart Sound Segmentation Algorithm Based on Heart Sound Envellogram and this is how I solved it.
N=0.02*Fs;
win = N;
k=1;
i = 1;
Es=[];
Es_t=[];
P=[];
m = length(filter)/N;
t=0:1/Fs:(length(norm)-1)/Fs;
for k = 1:m
for i = win*(k-1)+1:win*(k)
F1(i) = (norm(i).^2 * log(norm(i).^2));
end
Es(k) = -1/N* sum(F1);
F1 = [];
end
for k = 1:m
M_Es = (mean(Es));
S_Es = (std(Es));
P(k) = (Es(k)-M_Es)/S_Es;
end
tk = 0:60/(m-1):60;
[yupper,ylower] = envelope(P);
plot(tk,yupper)
Arthur Guilherme Santos Fernandes
Does the "Es" have the same length as the normalized signal ?
I am trying to reproduce this thecnique based on a paper, and they have this picture:
As if the Average Shannon Energy has the same length of the original signal.
This got me confused, i want to reproduce this picture but i can't because in my case i'm getting "Es" as a shorter array, since we do the splits of 0.02s.

Sign in to comment.

Accepted Answer

Star Strider
Star Strider on 22 Nov 2015
I am guessing here because I cannot run your code. You are taking the standard deviation of the second-to-last value of ‘Es’ in your loop. See if changing the standard deviation calculation to:
S_Es = (std(Es)); %стандартное отклонение энергии сегмента
gives you the correct result.
  2 Comments
Stefaniya Pirogova
Stefaniya Pirogova on 22 Nov 2015
yes, you're right, thank you. but still have problem with P(k) here is an archive where all the files that you need for running, can you, please, have a look at them?
Star Strider
Star Strider on 22 Nov 2015
My pleasure.
I do not download and open .zip files. If your .zip file contains your data, please save your data as a .mat file instead. (See the documentation for the save function for all the details.)
I understand phonocardiography (I am an Internal Medicine physician), but I have no idea what analysis you are doing. Do you have a PDF reference for it (in English), since I do not recognise what you are doing from your code. I cannot promise any solution even then, but at least I might have some idea.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!