Cut a signal into heart cycle pieces
7 次查看(过去 30 天)
显示 更早的评论
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 个评论
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.
- Find the locations of each local minimum. help findpeaks
- Use those locations to break your signal into pices, probably as independent cells orf a cell array.
- 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
2019-1-3
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')
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')
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)
4 个评论
Chris Turnes
2019-1-7
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 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Measurements and Statistics 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!