How to upsample an ECG signal and its associated data?
Afficher commentaires plus anciens
I have an ECG signal which has a sampling frequency of 250 Hz and I want to upsample it to 360 Hz.
The signal has peaks and the indexes of the peaks are also given as "peaks.mat".
The given data is described as follows:
sig.mat: ECG signal whose size is 273010X1, which has 633 peaks as specified in "peaks.mat".
peaks.mat: the sample index where the peaks occur in "sig.mat" and the size is 633X1
So, besides upsampling the signal, how to adjust the indexes of the peaks accordingly?
Thank you,
Réponses (2)
Catalytic
le 23 Juin 2024
0 votes
Star Strider
le 23 Juin 2024
0 votes
Use the resample function to upsample it, since this function is specifically designed for signal processing, and contains an anti-aliasing filter to prevernt spurious frequencies from appearing in the resampled signal.
6 commentaires
My pleasure.
Tey should not need any adjusting. The P, R, and T deflections (‘peaks’) should be at essentially the same times they were in the original trace, and the intervals should not change significantly. The times may differ slightly because the time vector is different, however they should be close. The amplitudes should also be essentially the same.
I did not see the .mat file originally, so it must have been added later. (The informattion says that it was added about an hour ago.)
LD = load('dataUpsampling.mat')
The problem here is that we need to have a time vector that should have been supplied with the original EKG data. I can go no further without it.
If the time vector and the original EKG trace that uses it appear, I will proceed with my analysis.
.
Star Strider
le 24 Juin 2024
I do need to know the time! I cannot proceed without it.
Your ‘peaks’ are what I would consider ‘locs’ (indices) in the usual findpeaks terminology.
It is likely not appropriate to use tthe original peak values and locations on a resampled signal. Recalculate everything on the resampled signal instead.
Illustration, with a possible solution —
LD = load('dataUpsampleTime.mat')
peaks = LD.peaks
sig = LD.sig;
tm = LD.tm;
Ts = mean(diff(tm))
% Tsd = std(diff(tm))
Fs = 1/Ts
[myPks,myLocs] = findpeaks(sig, 'MinPeakProminence',0.5)
figure
plot(tm, sig)
hold on
plot(tm(peaks), sig(peaks), 'vr')
plot(tm(myLocs), myPks, '^g')
hold off
grid
xlim([0 25])
sig_filt = highpass(sig, 1.5, Fs, 'ImpulseResponse','iir'); % Filter Out Baseline Variation
[myPks_filt,myLocs_filt] = findpeaks(sig_filt, 'MinPeakProminence',0.5)
figure
plot(tm, sig_filt)
hold on
plot(tm(peaks), sig_filt(peaks), 'vr')
plot(tm(myLocs_filt), myPks_filt, '^g')
hold off
grid
xlim([0 25])
I would go back and re-calculate the peak locations and peak values on the resampled signal, as I have done here. Then, use those. (Keep or remove the baseline variation. I provided an approach for tthat if you want to use it.)
.
Star Strider
le 24 Juin 2024
What are you intending to demonstrate here?
My suggestion remains that the best approach is to get the peaks and indices of the upsampled signal after upsampling it. There is really no poiint to getting those datta from the original signal and then upsampling it, then upsampling or interpolating the peaks and locations to the upsampled signal.
Just do everythiung once on the upsampled signal and be done with it.
Star Strider
le 24 Juin 2024
Modifié(e) : Star Strider
le 24 Juin 2024
My pleasure!
What do you want, then?
I’m still not clear on that.
% LD = load('dataUpsampleTime.mat')
file = websave('dataUpsampleTime.mat','https://www.mathworks.com/matlabcentral/answers/uploaded_files/1721431/dataUpsampleTime.mat');
LD = load(file);
peaks = LD.peaks
sig = LD.sig;
tm = LD.tm;
Ts = mean(diff(tm))
% Tsd = std(diff(tm))
Fs = 1/Ts
[myPks,myLocs] = findpeaks(sig, 'MinPeakProminence',0.5)
figure
plot(tm, sig)
hold on
plot(tm(peaks), sig(peaks), 'vr')
plot(tm(myLocs), myPks, '^g')
hold off
grid
xlim([0 25])
sig_filt = highpass(sig, 1.5, Fs, 'ImpulseResponse','iir'); % Filter Out Baseline Variation
[myPks_filt,myLocs_filt] = findpeaks(sig_filt, 'MinPeakProminence',0.5);
figure
plot(tm, sig_filt)
hold on
plot(tm(peaks), sig_filt(peaks), 'vr')
plot(tm(myLocs_filt), myPks_filt, '^g')
hold off
grid
xlim([0 25])
[sig450,t450] = resample(sig_filt,tm,450)
format shortG
myLocs450 = resample(myLocs, 360,450)
myLocs450 = round(myLocs450)
[MyPks450,MyLocs450] = findpeaks(sig450, 'MinPeakProminence',0.5)
figure
plot(t450, sig450)
hold on
plot(t450(myLocs450),sig450(myLocs450), 'sr')
plot(t450(MyLocs450),sig450(MyLocs450), 'sg')
hold off
xlim([0 25])
It is simply not possible to resample the location indices as well as the signal, and have the location indices ‘make sense’ in any real way. As I mentioned earlier, find the peaks and locations of the resampled signal after resampl;ing it. Interpolating the data from the original signal to the resampled signal will simply not work. Just use findpeaks on the resampled signal and be done with it.
Notice the difference between the peak locations of the actual resampled signal and the resampled locations of the original signal. That approach just doesn’t work.
.
Catégories
En savoir plus sur Multirate Signal Processing dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!




