How to normalize and re-sample ECG signal?

There is an ECG signal I want to normalize and re-sample at 200Hz. The signal is stored in first row of 16265m.mat
This recording is downloaded from website of PhysioNet . It's length is 10 seconds.

 Accepted Answer

I have no idea what you mean by ‘normalize’. When I looked it up, it seemed relatively noise-free, and the baseline was smooth and not offset. The sampling frequency is 128 Hz, so the easiest way to resample it is to use the Signal Processing Toolbox resample function:
y = resample(x, 200, 128);
The resample function incorporates filtering of the resampled signal, so I prefer it for signal processing.

4 Comments

Explorer
Explorer on 21 Jan 2016
Edited: Explorer on 21 Jan 2016
Please have a look on screenshot I have attached in order to understand what actually "normalize" means.
Wouldn't it be wrong to re-sample a signal that is already sampled before normalizing?
I am trying to code up an algorithm that actually classifies ventricular arrhythmia ECGs and its first step is pre-processing of ECG signals which includes Normalizing signals, Re-sampling, etc.
Normalizing signals is necessary as the recording I have are of different sampling frequency. Don't you think so?
Recordings from following database have different sampling frequency.
MIT BIH Normal Sinus Rhythm Database = 128 Hz,
CU Ventricular Tacharrhythmia = 250 Hz
MIT BIH Malignant Ventricular Ectopy = 250Hz,
MIT BIH SupraVentricular Arrhy... = 128 Hz
‘Normalising’ in the context of that method refers to normalising the sampling frequency. So once you resample it to 200 Hz and do the bandpass filtering, your preprocessing is done. (My filter design procedure is: How to design a lowpass filter for ocean wave data in Matlab?.)
It would not be wrong to resample a signal if you want to do signal processing on it, especially if you want to use the same filters on every EKG trace. This is also important if you want to do Fourier transforms on them, because EKG traces sampled at the same sampling frequency and of the same length (time) will have the same frequency resolutions after the Fourier transformation.
Apparently they resampled it because they wanted all their signals sampled at 200 Hz, likely so that they could use the same filters and other signal processing procedures on them. (This is called ‘oversampling’ and is a common technique to make signal proceeing easier.) If they want it resampled to 200 Hz, then using my resample statement will work for your trace. They obviously were dealing with normal sinus rhythm (NSR) because that will work with a 2-48 Hz bandpass filter. (Irregular rhythms such as atrial fibrillation/flutter and ventricular tachyarrhythmias require a 1-100 Hz passband. Use a notch filter to get rid of mains frequency noise in that instance, as described in Remove the 60 Hz Hum from a Signal.) That particular trace did not look as though it needed any filtering because the baseline was stable and any mains power frequency contamination was negligible.
Classifying ventricular arrhythmias is not a trivial procedure, especially since many of them (those not due to drug toxicity or electrolyte abnormalities) are in the setting of very sick hearts that include infarcted segments of the ventricular myocardium and significant ventricular conduction system abnormalities (bundle branch blocks). That requires you to identify the infarct site as well as characterise the arrhythmia.
Explorer
Explorer on 24 Jan 2016
Edited: Explorer on 24 Jan 2016
Thank you for your detailed reply. I have used the function you asked to normalize the sampling frequency and here it is . The recordings I am re-sampling are from MIT-BIH Normal Sinus Rhythm, CU Ventricular Tacharrhythmia, MIT-BIH Malignant Ventricular Ectopy and MIT-BIH SupraVentricular Arrhythmia.
As you said above, bandpass filtering will be useful only for Normal Sinus Rhythm and it will not work for irregular rhythms.
But the recordings I am going to process include irregular rhythms so I need to use notch filter (Band Stop Filter). But what range of frequencies will be in pass band and what range will be in stop band. These things are not mentioned in paper I am referring. So do you have idea about these frequency ranges?
Please also code, if possible.
My pleasure.
I didn’t say that passband filtering is only appropriate for NSR. A 2-48 Hz passband is only appropriate to NSR (although you can use a 1-100 Hz passband). Quoting from my earlier Comment, ‘Irregular rhythms such as atrial fibrillation/flutter and ventricular tachyarrhythmias require a 1-100 Hz passband’
For bandpass filters, I usually define the passband and stopband as (using the current example):
Fs = 250; % Sampling Frequency
Fn = Fs/2; % Nyquist Frequency
Wp = [2 100]/Fn; % Filter Passband (Normalised)
Ws = Wp .* [0.5 1/0.5]; % Filter Stopband (Normalised)
Then follow the rest of the filter design procedure I linked to in my previous Comment. Either the Butterworth or Chebyshev Type II design will work. For EKGs, because the low frequency cutoff is close to 0, I prefer the Chebyshev with a 1 dB passband ripple and 10 dB stopband ripple. If you have problems getting a stable filter, increase the stopband ripple, perhaps to 25 dB or so.
I haven’t looked that the file you linked to. I only look at those attached to MATLAB Answers posts. Attach it using the ‘paperclip’ icon, and complete both the ‘Choose file’ and ‘Attach file’ steps.

Sign in to comment.

More Answers (1)

I haven't seen the signal, but how about using interp1()?

Asked:

on 20 Jan 2016

Edited:

on 25 Jan 2016

Community Treasure Hunt

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

Start Hunting!