


preprocessingNew Pre-processing of ECG signal
Pre-processing using normalization and filtering.
Process:
1. Each second was detrended by removing the mean from each sample and
dividing by the standard deviation.
2. The signal is then band-passed filtered at 16Hz-26Hz using a
butterworth filter.
Inputs:
sig - The raw ECG
fs - The sampling frequency
Outputs:
sig - The preprocessed signal
detrended - The signal after the first step only (no time shifting).
Reference:
Kota, S., Swisher, C.B. & al (2017). "Identification of QRS complex in
non-stationary electrocardiogram of sick infants."
Computers in Biology and Medicine 87 (2017) 211–216

0001 function [ sig, detrended ] = preprocessingNew(sig, fs) 0002 %preprocessingNew Pre-processing of ECG signal 0003 % Pre-processing using normalization and filtering. 0004 % 0005 % Process: 0006 % 1. Each second was detrended by removing the mean from each sample and 0007 % dividing by the standard deviation. 0008 % 2. The signal is then band-passed filtered at 16Hz-26Hz using a 0009 % butterworth filter. 0010 % 0011 % Inputs: 0012 % sig - The raw ECG 0013 % fs - The sampling frequency 0014 % 0015 % Outputs: 0016 % sig - The preprocessed signal 0017 % detrended - The signal after the first step only (no time shifting). 0018 % 0019 % 0020 % Reference: 0021 % Kota, S., Swisher, C.B. & al (2017). "Identification of QRS complex in 0022 % non-stationary electrocardiogram of sick infants." 0023 % Computers in Biology and Medicine 87 (2017) 211–216 0024 0025 0026 % every second of the ECG signal was normalized by the standard deviation of the signal in that second. 0027 numSecs = floor(length(sig) / fs); 0028 sigFullSecs = sig(1:numSecs*fs); 0029 sigSplit = reshape(sigFullSecs, fs, numSecs); 0030 newsig = sigSplit; 0031 0032 parfor i = 1:numSecs 0033 currSec = sigSplit(:,i); 0034 M = mean(currSec); 0035 S = std(currSec); 0036 normalizedSec = arrayfun(@(a) (a - M)/ S, currSec); 0037 newsig(:,i) = normalizedSec; 0038 end 0039 sigExtend = reshape(newsig,[],1); 0040 sig(1:length(sigExtend)) = sigExtend; 0041 0042 % ECG was detrended using a 120-ms smoothing filter with a zero-phase distortion. 0043 sig(isnan(sig)) = 0; 0044 0045 detrended = sig; 0046 0047 f1=16; %cuttoff low frequency to get rid of baseline wander 0048 f2=26; %cuttoff frequency to discard high frequency noise 0049 Wn=[f1 f2]*2/fs; % cutt off based on fs 0050 N = 3; % order of 3 less processing 0051 [a,b] = butter(N,Wn); %bandpass filtering 0052 ecg_h = filtfilt(a,b,sig); 0053 sig = ecg_h/ max( abs(ecg_h)); 0054 0055