Azzera filtri
Azzera filtri

Segmetation of a heart sound signal, then after applying a threshold on the segments, concatenating the modified segments

4 visualizzazioni (ultimi 30 giorni)
I am working with a heart sound signal. i need to make "silence part" to "zero" leaving "Non-silence-part" as it is. To perform it, I took a signal sample of length 6893. Then I segmented it into 33 segments of 200 sample length. Further I am trying to implement a threshold using “for-loop” and “if-else condition. In next step, I need to recombine these outputs to make it a single signal having “silence part” and “non-silence-part of major sounds”
Here, I am sharing the signal file for your kind processing. Sampling frequency is Fs=5000 Hz.
I tried as following:
hs_ecg_file=input('input HS_ECG file Name : ','s');
y=load(hs_ecg_file); % it takes the file data_file_name as variable
y1=y(:,1);
y1=decimate(y1,5);% to decrese the sampling rate of signal by 5 times
% i.e. from Fs=5000 to Fs=1000.
plot(y1,'r')
Seperated_HS_Signal =reshape(y1(1:6800),200,[]);
% Separated 1st segment of the signal of 200 length
Seperated_HS_Signal_1=Seperated_HS_Signal(:,1);
%--------------------------------
nn=6800/200;
for j=1:nn
Spr_HS=Seperated_HS_Signal(:,j);
forNn=1:length(Spr_HS)
if abs(Spr_HS(Nn))>0.15
Spr_HS_new(Nn)= Spr_HS(Nn);
else
Spr_HS_new(Nn)=0;
end
end
Spr_HS_neww(k,:)= Spr_HS_new(:,j);
end
combined_HSS=reshape(Spr_HS_neww,[],1);
figure
plot(combined_HSS)

Risposta accettata

Mathieu NOE
Mathieu NOE il 1 Mar 2022
hello Maddy
I tried first to use your code but got an error message as "k" is undefined
Spr_HS_neww(k,:)= Spr_HS_new(:,j);
As I more or less guessed what your intention was , I tried my own approach based on findpeaks to locate the first major peak of each segment
from there I selected only 100 samples extracts as after 100 samples we got only noise; we can make the segments longer and make the second half zero but what does it bring ?
here my code for you below
NB : Spr_HS_neww array contains all valide segments "time aligned" based on the first major peak
now what you want to do after with
combined_HSS=reshape(Spr_HS_neww,[],1);
is a bit mysterious for me...
clc
clearvars
% hs_ecg_file=input('input HS_ECG file Name : ','s');
hs_ecg_file='HS_ECG_fs5000_p.txt';
y=load(hs_ecg_file); % it takes the file data_file_name as variable
y1=y(:,1);
y=decimate(y1,5);% to decrese the sampling rate of signal by 5 times
% i.e. from Fs=5000 to Fs=1000.
samples = length(y);
x = 1:samples;
MPH = 0.25;
MPD = 100;
[PKS,LOCS] = findpeaks(y,'MinPeakHeight',MPH,'MinPeakDistance',MPD);
figure(1)
plot(x,y,'r',LOCS,PKS,'db')
nn = numel(PKS);
newsamples = 100;
pre_trig = 20;
for ci = 1:nn
ind_start = LOCS(ci)-pre_trig;
ind_stop = ind_start+newsamples-1;
if ind_stop<=samples
Spr_HS_neww(ci,:)= y(ind_start:ind_stop);
end
end
figure(2)
plot(Spr_HS_neww')
combined_HSS=reshape(Spr_HS_neww,[],1);
figure(3)
plot(combined_HSS)
  1 Commento
Maddy
Maddy il 1 Mar 2022
Thank you Mathieu NOE for your kind support. Actually i wanted to segment the signal into a fixed length. Then after applying some condition on each segment, i had to concatenate the all modified segments. Anyways, i did it and got my desired output..
I appreciate your endeavours..
Thanks a lot..

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by