Professional Documents
Culture Documents
Paper 10
Paper 10
Abstract: Presented is the algorithm of the subtraction criterion for linearity (so called D-filter)
method for removing powerline interference from ECG
signals, in case of powerline frequency variations. The Di = ( X i − n − X i ) − ( X i − X i + n ) = X i −n − 2 X i + X i + n , (1)
existing MatLab prototype version is adapted for real time is second difference of the signal samples’ values, as the first
execution on DSP and programmable logic (FPGA) plat- difference is taken among the samples, with distance in
forms. The algorithm is ported and experimented in case of between them equal to the PL interference period, for
odd sample number in one period of the interference. The eliminating its influence in the estimate for linearity of the
corresponding formulas for even sample number are given section.
too. Key moment is the use of the ongoing interference
values, which are stored in a temporary buffer and then used 2. The PL interference is removed with a non-
for recalculating the filter’s coefficients. Test results of the recursive symmetric digital filter “moving average” (so called
prototype MatLab code and its two implementations (for DSP F-filter)
and FPGA) show that the presented real time al-gorithms ( n −1) / 2
1
successfully compensate the presence of powerline frequency Yi =
n
∑ X i + j , n = 2m + 1 (odd sampling );
(2)
interfering the ECG signal. Given are the changes in the DSP j =− ( n −1) / 2
port of the algorithm and the generated structure by the
1 ⎛ n / 2−1 X + X i+n / 2 ⎞
FPGA configuration code. Yi = ⎜ ∑ X i + j + i − n / 2 ⎟ , n = 2m
⎜
n ⎝ j =− n / 2 +1 2 ⎟
⎠
Keywords: powerline interference, ECG signal, subtraction
and only the useful signal remains. At the same time, simple
method
subtraction between the filtered and non-filtered signals gives
1. INTRODUCTION the momentary value of the interference
The subtraction method for eliminating powerline (PL)
interferences in Electro Cardiographic Signals (ECS) [1, 4] Bi = X i − Yi . (3)
shows very promising results and is subject of in-tense which is stored in a temporary buffer.
investigation and refinement. [2, 6, 7, 9, 10]. It’s structure
comprises three major stages and is shown in fig. 1. 3. If the signal sample being processed does not
belong to a linear section, its value is taken from the
Subtraction Method temporary buffer
Bi = Bi − n (4)
Σ
Xi +
Delay buffer which is identical in phase with the current one. This value
Subtractor - Yi
compensates the signal
Interference Linear segment Yi = X i − Bi (5)
extracting detection
Di (being subtracted from the signal) and is stored again in the
Bi Linear segment M-criterion temporary buffer.
Bi or Bi-n
The temporary buffer keeps n preceding values of the
Bi-n Non-linear segment PL interference Bi −1 , Bi − 2 ,…, Bi −n . This delay buffer is used to
Interference compensate the phase shift of the D- and K-filters, introduced
temporal buffer because they are non-casual (physically unrealizable).
0.02
for i=1+n: 1: LX;
for j=end_XB: -1: 2;
XB(j)=XB(j-1); % delay buffer shift 0.01
end
XB(1) = X(i); % store into Delay Buffer
Ds = abs(XB(1)-2*XB(mid_XB)+XB(end_XB)); 0
Cr = Ds;
if Cr < M; % linear segment 0 0.5 1 1.5 2 2.5
Ys=XB(start_XB)/n; d - zoomed error
for j=start_XB+1: 1: stop_XB;
Ys=Ys+XB(j)/n; Figure 2 – subtraction method operational results
end
Ys=XB(mid_XB)-(XB(mid_XB)-Ys)/(1-KF);
Bs=XB(mid_XB)-Ys; % interferense The third graphic (fig. 2c) shows the output signal,
else % non-linear segment
Bs = BB(n)+n*KF*(BB(mid1_BB)-BB(mid2_BB)); obtained after eliminating the PL interference from the input
Ys=XB(mid_XB)-Bs; one. Notable is the exact match with the initial one. The same
end
for j=n: -1: 2;
diagram contains also, the criterion for linearity, which takes
BB(j)=BB(j-1); % shift interf. buffer only two values and classifies the corresponding section as
end linear or non-linear. Storing the input and output signals in
BB(1) = Bs; % store sample
Y(i-n) = Ys; % outgoing filtered sample buffers allows to make comparison between them, with ease.
End The difference (absolute value) between their sample values
gives the error made by the operation of the processing
Accurate processing of the signal is based on algorithm when filtering the signal. This error is displayed in
preliminary detection and estimate of linear and non-linear the last diagram (fig. 2d). Notable is the scale of the error –
sections in it. Depending on this criterion, the processing below 10 μV or 0,5 samples of the ADC. The last result is
continues in two different ways. The digital filtered released especially demonstrative for the operation of the so realized
by this algorithm needs the pre-history and the post-history of digital filter and its precision.
the current signal sample being processed. That’s why the 3. REAL TIME DSP IMPLEMENTATION
incoming signal is stored in a delay buffer, where a series of
sequential samples around the moment of interest are After confirming the functionality of the subtraction
available. method for removing PL interferences from electro cardio
The results of operation of the so realized digital filter signals theoretically in MatLab, software realization of the
are shown graphically in fig. 2. The first diagram (fig. 2a) algorithm was made in C for real time execution by DSP. The
contains part of a real electro cardio signal, free of any development platform used is Analog Devices’ BF537-
interferences. When synthesizing and adding interference to STAMP operating with processor Blackfin-537. The system
it, the signal takes the form from the second diagram (fig. 2b). is complemented with an ADC and a DAC used as I/O
devices of the system. The interconnection with the main
board is done via the serial port. When receiving input data algorithm are identical with those of the theoretic experiments
from the ADC, a serial port interrupt on receive is triggered, in MatLab. The notable difference is only in the scale of the
which starts the subroutine for processing the input sample vertical axis. This discrepancy is due to preliminary scaling
just received. Upon completing the computations, the output the input signals (magnify the magnitude 50 times), for the
sample is sent back the serial line to the DAC for producing purpose of reducing the computational errors when working
the output (filtered) signal. The mere processing takes less with floating point signal sample values. As a result, the
time than the length of the interval between two successive vertical axis unit becomes sampling numbers. Absolutely
serial port interrupts on receive, which allows this procedure evident is the variation of the error caused by the operational
to be executed in real time. The software initializes the clock procedure (fig. 3d), which is kept in the interval less than
frequency that leads the serial data transfer, thus regulates the ±0.5 samples.
length of the interval between the interrupts, setting the
desired input signal sampling rate to 250Hz. The
development platform used (BF537-STAMP) operates on
500MHz and completes the necessary computations in 7 μs,
which is significantly shorter time than the limit of 4 ms
between the arrival of two input samples, for real time
execution. This suggests that the same filtering algorithm can
be executed by slower processors with ease [3, 8].
Next is listed the main part of the processing
subroutine, realized in C.
void Process_Data(void)
{
for(j = end_XB - 1; j > 0; j--)
{
XB[j]=XB[j-1]; // delay buffer shift
}
XB[0] = x[i]; // store ingoing sample
Ds = abs(XB[0]-2*XB[mid_XB-1]+XB[end_XB-1]);
// estimate linearity
Cr = Ds;