hi guys
i have a pcg signal
i want to segment the signal into 4 segment, s1 & s2 = 1 segment
how to do it?
thankss
shannon.jpg

 Akzeptierte Antwort

Star Strider
Star Strider am 22 Jan. 2019

2 Stimmen

The findchangepts (link) function (introduced in R2016a) is perfect for this:
D = load('matlab.mat');
data = D.data;
Fs = D.fs;
t = linspace(0, 1, numel(data))/Fs;
cp = findchangepts(data, 'Statistic','std', 'MinDistance',2E+3, 'MaxNumChanges',7);
figure
plot(t, data)
hold on
YL = ylim;
plot([t(cp); t(cp)], YL(:)*ones(1,numel(cp)), '-r', 'LineWidth',1)
hold off
producing:
how to automatic segmentation signal - 2019 01 22.png
The ‘cp’ vector are the change points corresponding to the vertical red lines in the plot. The findchangepts function takes about 15 seconds to complete this (on my desktop, using tic and toc),
Experiment to get the result you want.

6 Kommentare

Mr noobys
Mr noobys am 22 Jan. 2019
Hi Star strider
Thanks for the guidance this function is the one i need :D
now i can experiment with it
can i ask you again?
how do i extract the information per segment ? like the interval of time ?
something like this
Capture3.png
Thank you so much!
My pleasure.
After thinking about it later, tell findchangpts to create 8 change points, not 7. That will segment the first set as well, making the analysis easier:
cp = findchangepts(data, 'Statistic','std', 'MinDistance',2E+3, 'MaxNumChanges',8);
I assume 8 change points in my discussion of the indices and time calculations here.
The ‘cp’ output of findchangepts are indices into the argument vector, so to change them into time values, just subscript them such as I did in the second plot call. I would work with them as indices first, then convert them to time values. You will need to decide how to write your code to get the values you want. Consider using the diff (link) function for some of those, although on the itme values, not the index values.
So for example, to get the first set, use ‘cp(1)’ and ‘cp(2)’, the second, ‘cp(3)’ and ‘cp(4)’, and so on for all the intervals you want to analyse. The times would be for example ‘t(cp(1))’, and so for the others. Calculate the intervals from the time differences, not the index differences.
Mr noobys
Mr noobys am 22 Jan. 2019
Bearbeitet: Mr noobys am 22 Jan. 2019
Hi Star strider
thanks again for the explanation :D
Yes i think change the cp to 8 will be perfect for the easier analysis!
is it just me,but when i changed the cp from 7 to 8 it take's a long time to run and the result didnt come out ?
and i am sorry i dont quite understand, how do i change the vector to time values?
i tried to modified the cp code but it still didnt work out
thank you so much
Star Strider
Star Strider am 22 Jan. 2019
Bearbeitet: Star Strider am 23 Jan. 2019
My pleasure.
Using this is significantly faster, and appears to be as accurate:
cp = findchangepts(data, 'Statistic','mean', 'MinDistance',4E+3, 'MaxNumChanges',8);
Calculate the absolute times as:
tv = [t(1) t(cp)] % Time Values (Segment Times)
and the intervals between successive change point segments as:
timediff = diff([0 tv]) % Serial Intervals (Segment Difference Times)
With your data, the results are:
Segment Times = 0.00000E+00 1.28867E-05 2.52191E-05 3.53367E-05 4.78518E-05 5.74961E-05 7.07605E-05 8.01827E-05
Segment Difference Times = 0.00000E+00 1.28867E-05 1.23324E-05 1.01175E-05 1.25151E-05 9.64426E-06 1.32645E-05 9.42215E-06
You then have to write the necessary code to find the other intervals you are interested in. Use the ‘tv’ (‘Segment Times’) vector for those calculations.
EDIT —
Added plot figure.
The plot:
how to automatic segmentation signal (2) - 2019 01 22.png
Mr noobys
Mr noobys am 23 Jan. 2019
Thank you soo much star strider !
thats really help me a lot!
Star Strider
Star Strider am 23 Jan. 2019
As always, my pleasure!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

weii chieun lim
weii chieun lim am 4 Jul. 2019

0 Stimmen

Hi Mr noobys , can i know how do you denoising the pcg signal ? tq

Kategorien

Community Treasure Hunt

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

Start Hunting!

Translated by