# Segmentation of multiples ecg signals

32 views (last 30 days)
sania urooj on 19 Jun 2021
Edited: KALYAN ACHARJYA on 20 Jun 2021
Hello! I am working on ECG signal classification. During pre processing stage. I need to segment my signal into 2 sec duration length (2000 samples, frequency 1000 hertz). The problem is I have to do this for multiple signals (whole dataset is consisting of 1000 signals) and save them to use for further processing. I am not getting how to apply loop to get this task done.
for one signal I am using these approaches.
First one:
vb = buffer((sig, numel(sig/5)))
vb= vb.'
Second one:
before=250;
after= 400;
nn = length(qrs_amp);
beat = zeros(length(qrs_amp) - 1, 651);
for i=2:nn-2
beat(i,:)=ecg_h(qrs_amp(i)-before:qrs_amp(i)+after))
end
where sig = original signal
ecg_h= filtered signal
qrs_amp= R-peak value

KALYAN ACHARJYA on 20 Jun 2021
Edited: KALYAN ACHARJYA on 20 Jun 2021
First Part:
Read the y axis data (mV) as another column data & store in new variable, say ecg_data. The time vector (x data in ms) is generally linearly spaced, so you can consider the same as indexing. If your time scale unit is second, consider 2 spacing, otherwise 20 spacing for ms time unit.
Suppose the time scale in seconds
ecg_data=data(:,2);
len=length(ecg_data)/2; % Considering length of ecg_data as even number
ecg_segment=mat2cell(data,2*ones(1,len),1);
The ecg_segment as follows
ecg_segment=
...×1 cell array
{2×1 double}
{2×1 double}
{2×1 double}
{2×1 double}
{2×1 double}
.......
Here individual cell elements represent segment of the signal. Aferwards you can use the cell elements for further processing or save the data also.
Think: You may consider the 3 dimensional cell array to store the segment of the ecg in multiple planes based on signal number, which is quite easy to handle on Matlab processing. But in case of save in excel or otherways you have to decide.
Second Part:
There the multiple threads to call the multiple files/mat files/text/images. You can replicate the same just by changing the the file format extention name and local path of the files.