![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/709567/image.png)
How can I create an idealized cycle from quasiperiodic data?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Samuel Harvey
am 11 Aug. 2021
Kommentiert: Star Strider
am 30 Aug. 2021
I have data of blood velocity (attached) over several cardiac cycles. I'm trying to create a single idealized cycle that takes into account the natural variations in duration and velocity from cycle to cycle, while removing the noise. This is what the data looks like at the moment:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/709537/image.jpeg)
The standard way I've done it in the past is to manually pick points over a single cycle, then interpolate them. The blue interpolated line is roughly what I'm looking for as an output.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/709542/image.png)
Is there any way I can create this kind of idealized cycle from the data I have?
0 Kommentare
Akzeptierte Antwort
Star Strider
am 11 Aug. 2021
This is called ‘ensemble averaging’. See for example Combining repetitive curves into one average curve and similar posts.
Try this —
LD = load('normalized_velocities.mat');
norm_values = LD.norm_values;
t = 1:numel(norm_values);
plocs = find(islocalmax(norm_values, 'MinProminence',0.1));
plocs = [plocs numel(t)];
vlocs = find(islocalmin(norm_values, 'MinProminence',0.005));
for k = 1:numel(plocs)-1
ixm(k) = max(vlocs(vlocs<plocs(k))); % Min Before Peak
end
% for k = 1:numel(ixm)-1
% ix{k} = ixm(k):ixm(k+1);
% pulse{k} = norm_values(ix{k});
% n(k) = numel(ix{k});
% end
for k = 1:numel(ixm)-1
ix{k} = plocs(k)-11:ixm(k+1);
pulse{k} = norm_values(ix{k});
n(k) = numel(ix{k});
end
ens = zeros(1,max(n)); % Preallocate
for k = 1:numel(pulse)
ens(k,1:n(k)) = pulse{k}(1:n(k));
end
ensavg = mean(ens,'omitnan');
figure
plot(t, norm_values,'.-')
hold on
plot(t(plocs), norm_values(plocs), '^r')
plot(t(vlocs), norm_values(vlocs), 'vg')
hold off
grid
figure
plot((0:max(n)-1), ens, '.-')
grid
figure
plot((0:max(n)-1), ensavg)
grid
producing:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/709567/image.png)
Experiment to get the result you want.
.
7 Kommentare
Star Strider
am 30 Aug. 2021
O.K.
The initial ‘ens’ vector is created to correspond to the maximum length of the discovered waveform segments, so it should be no longer than the longest one.
.
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!