필터 지우기
필터 지우기

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

조회 수: 4 (최근 30일)
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)

채택된 답변

Mathieu NOE
Mathieu NOE 2022년 3월 1일
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
Maddy
Maddy 2022년 3월 1일
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..

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by