Hi guys,
I have a signal from a photophlethysmographic (PPT) sensor showing contours of the heart pulse.
My signal needs to be cut/subdivided into signal pieces for a single heart beat. Each single heart beats needs to be saved in the workspace.
So when the slope of the signal is getting values different than 0, the data should be cut and saved to workspace.
Is there any possibilities I could do so ? Does anybody have suggestions ?

댓글 수: 3

Naman Chaturvedi
Naman Chaturvedi 2019년 1월 2일
Hi Jawad,
It is not quite clear from your query what you want to achieve. Can you share what your output should look like?
Jawad Jawadi
Jawad Jawadi 2019년 1월 3일
Hi Naman,
first of all , thank you for your reply.
If this is my signal:
Then I would like to cut the signal into following segments:
In order to cut the signal into single undulations:
The goal is cut the signal according to the above mentioned undulations and save it to the workspace.
Later I want to normalize the signals and stack them to calculate and disply a density map.
Here is my code so far:
________________________________________________________
dataset = xlsread('data.xlsx','EA0165','A1:G1578');
Time=dataset(:,1);
A1=dataset(:,2);
V2=dataset(:,3);
A3=dataset(:,4);
V4=dataset(:,5);
Timesystol=dataset(:,6);
A = fillmissing(V2,'linear');
B = movmedian(A,3);
detrended_B=detrend(B);
trend = B - detrended_B;
C = movmedian(detrended_B,3);
D =movmedian(C,[5 3]);
figure(4)
hold on
plot(D,'g');
____________________________________________________________
Can you help me ?
John D'Errico
John D'Errico 2019년 1월 3일
편집: John D'Errico 2019년 1월 3일
This is not an answer, since I don't have your data signal, nor even the signal processing toolbox. But since it looks like you want to use the local minima to break the signal up, just use findpeaks.
  1. Find the locations of each local minimum. help findpeaks
  2. Use those locations to break your signal into pices, probably as independent cells orf a cell array.
  3. Subtract off the local average value for each section. This will detrend the problem, helping them to now overlap.
You do NOT want to create the segments as separate variables in your workspace. That is a particular place in programming hell where you do not want to live. Instead, learn to use arrays, and here, cell arrays or even structures.

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

 채택된 답변

Chris Turnes
Chris Turnes 2019년 1월 3일

1 개 추천

I don't have your data, but using something that looks roughly similar (attached), here's an approach. Furthering John's comment, if you have access to R2017b or beyond, you can use islocalmin to find the minima.
>> tf = islocalmin(x, 'FlatSelection', 'center');
>> t = 1:length(x);
>> plot(t, x, t(tf), x(tf), 'rx')
>> legend('Input', 'Local minima')
locmin.png
Once you have them, you can do a cute little trick to segment the signal: you can call cumsum to get unique labels for each heartbeat:
>> glabels = 1 + cumsum(tf);
With these labels, you can uniquely identify any individual heartbeat you've detected without having to explicitly construct each one. For example, to plot the 4th heartbeat you've segmented:
>> idxFourth = glabels == 4;
>> plot(t, x, t(idxFourth), x(idxFourth));
>> legend('All', 'Fourth')
fourth.png
You could also mean-center each heartbeat as John suggests by using the grouptransform function of R2018b (though you'll need to pack your data into a table):
>> Tx = table(x', glabels', 'VariableNames', { 'Data', 'Heartbeat' });
>> Txmc = grouptransform(Tx, 'Heartbeat', 'meancenter');
>> plot(t, Txmc.Data)
meancenter.png

댓글 수: 4

Jawad Jawadi
Jawad Jawadi 2019년 1월 6일
Dear Chris,
Dear John,
thank you for your swift replies. I managed with your help and instructions to sectionwise extract each heart cycle.
Unfortunately the last step did not work out.
I have attached the signal.
Below you see the code that I used in order to get the same result:
D is my vector.
Tx = table(D', glabels', 'VariableNames', { 'Data', 'Heartbeat' });
Txmc = grouptransform(Tx', 'Heartbeat', 'meancenter');
plot(t, Txmc.Data);
Any idea what I forgot or did wrong ?
Chris Turnes
Chris Turnes 2019년 1월 7일
편집: Chris Turnes 2019년 1월 7일
I think this issue is just that you have column vectors instead of row vectors. The table constructor uses each row as a table row, so when you do D' you are getting a table with 1 row, where the first (and second) variable is a 1 x 1576 row vector.
I should have perhaps instead have suggested building the table as:
Tx = table(D(:), glabels(:), 'VariableNames', { 'Data', 'Heartbeat' });
Txmc = grouptransform(Tx, 'Heartbeat', 'meancenter');
plot(t, Txmc.Data);
I think that should get you what you need.
Jawad Jawadi
Jawad Jawadi 2019년 1월 7일
Dear Chris,
thanks for your quick reply.
The function grouptransform seems not to be accepted by MATLAB.
I get the reply that the function or variable 'grouptransform' is undefined.
Do I have to previously define grouptransform ?
I am on Matlab 2018a.
grouptransform was introduced in R2018b, unfortunately, so it seems you won't have access to that function. An alternative approach is to simply loop through the number of groups you have and manually re-normalize using indexing. For example, something like
for k = 1:max(glabels)
thisGroup = D(glabels == k);
D(glabels == k) = thisGroup - mean(thisGroup);
end

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Interpolation에 대해 자세히 알아보기

제품

릴리스

R2018a

질문:

2018년 12월 28일

댓글:

2019년 1월 7일

Community Treasure Hunt

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

Start Hunting!

Translated by