Noninvasive Fetal ECG: The PhysioNet/Computing in Cardiology Challenge 2013 1.0.0
(806 bytes)
function residual = MECGcancellation(peaks,ECG,fs)
% MECG cancellation using blanking
%
% inputs:
% fs: sampling frequency
% ECG: matrix of abdominal ECG channels.
% peaks: MQRS markers in seconds. Each marker corresponds to the
% position of a MQRS.
%
% output:
% residual: residual containing the FECG.
% ---- constants ----
Qstart = floor(0.1*fs);
Sstop = floor(0.1*fs);
N = length(peaks); % number of MECG QRS
residual = ECG;
% ---- MECG cancellation ----
for i=1:N
left=min(peaks(i)-1,Qstart);
right=min(length(ECG)-peaks(i),Sstop);
residual(peaks(i)-left:peaks(i)+right) = 0;
end
% % the starting and end have "edge" effect
% residual(1:10)=0;
% residual(end-9:end)=0;
end