<s>
The	O
Pan	B-Algorithm
–	I-Algorithm
Tompkins	I-Algorithm
algorithm	I-Algorithm
is	O
commonly	O
used	O
to	O
detect	O
QRS	B-Algorithm
complexes	I-Algorithm
in	O
electrocardiographic	B-Application
signals	O
(	O
ECG	B-Application
)	O
.	O
</s>
<s>
The	O
QRS	B-Algorithm
complex	I-Algorithm
represents	O
the	O
ventricular	B-Application
depolarization	I-Application
and	O
the	O
main	O
spike	O
visible	O
in	O
an	O
ECG	B-Application
signal	O
(	O
see	O
figure	O
)	O
.	O
</s>
<s>
In	O
the	O
first	O
derivation	O
of	O
Einthoven	O
of	O
a	O
physiological	O
heart	O
,	O
the	O
QRS	B-Algorithm
complex	I-Algorithm
is	O
composed	O
by	O
a	O
downward	O
deflection	O
(	O
Q	O
wave	O
)	O
,	O
a	O
high	O
upward	O
deflection	O
(	O
R	B-Algorithm
wave	I-Algorithm
)	O
and	O
a	O
final	O
downward	O
deflection	O
(	O
S	O
wave	O
)	O
.	O
</s>
<s>
The	O
Pan	B-Algorithm
–	I-Algorithm
Tompkins	I-Algorithm
algorithm	I-Algorithm
applies	O
a	O
series	O
of	O
filters	O
to	O
highlight	O
the	O
frequency	O
content	O
of	O
this	O
rapid	O
heart	O
depolarization	O
and	O
removes	O
the	O
background	O
noise	O
.	O
</s>
<s>
Then	O
,	O
it	O
squares	O
the	O
signal	O
to	O
amplify	O
the	O
QRS	B-Algorithm
contribution	O
,	O
which	O
makes	O
identifying	O
the	O
QRS	B-Algorithm
complex	I-Algorithm
more	O
straightforward	O
.	O
</s>
<s>
Pan	O
and	O
Tompkins	O
reported	O
that	O
the	O
99.3	O
percent	O
of	O
QRS	B-Algorithm
complexes	I-Algorithm
was	O
correctly	O
detected	O
.	O
</s>
<s>
A	O
filter	O
bandwidth	O
of	O
5-15	O
Hz	O
is	O
suggested	O
to	O
maximize	O
the	O
QRS	B-Algorithm
contribute	O
and	O
reduce	O
muscle	O
noise	O
,	O
baseline	O
wander	O
,	O
powerline	O
interference	O
and	O
the	O
P	O
wave/T	O
wave	O
frequency	O
content	O
.	O
</s>
<s>
In	O
the	O
original	O
algorithm	O
proposed	O
in	O
1985	O
,	O
the	O
band-pass	O
filter	O
was	O
obtained	O
with	O
a	O
low-pass	B-Algorithm
filter	I-Algorithm
and	O
a	O
high-pass	O
filter	O
in	O
cascade	O
to	O
reduce	O
the	O
computational	O
cost	O
and	O
allow	O
a	O
real-time	O
detection	O
,	O
while	O
ensuring	O
a	O
3	O
dB	O
passband	O
in	O
the	O
5	O
–	O
12Hz	O
frequency	O
range	O
,	O
reasonably	O
close	O
to	O
the	O
design	O
goal	O
.	O
</s>
<s>
for	O
a	O
second-order	O
low-pass	B-Algorithm
filter	I-Algorithm
with	O
a	O
gain	O
of	O
36	O
and	O
a	O
processing	O
delay	O
of	O
5	O
samples	B-Algorithm
;	O
</s>
<s>
for	O
a	O
high-pass	O
filter	O
with	O
a	O
unity	O
gain	O
and	O
a	O
processing	O
delay	O
of	O
16	O
samples	B-Algorithm
.	O
</s>
<s>
As	O
a	O
third	O
step	O
,	O
a	O
derivative	O
filter	O
is	O
applied	O
to	O
provide	O
information	O
about	O
the	O
slope	O
of	O
the	O
QRS	B-Algorithm
.	O
</s>
<s>
for	O
a	O
5-point	O
derivative	O
filter	O
with	O
gain	O
of	O
0.1	O
and	O
a	O
processing	O
delay	O
of	O
2	O
samples	B-Algorithm
.	O
</s>
<s>
The	O
filtered	O
signal	O
is	O
squared	O
to	O
enhance	O
the	O
dominant	O
peaks	O
(	O
QRSs	O
)	O
and	O
reduce	O
the	O
possibility	O
of	O
erroneously	O
recognizing	O
a	O
T	B-Algorithm
wave	I-Algorithm
as	O
an	O
R	O
peak	O
.	O
</s>
<s>
Then	O
,	O
a	O
moving	O
average	O
filter	O
is	O
applied	O
to	O
provide	O
information	O
about	O
the	O
duration	O
of	O
the	O
QRS	B-Algorithm
complex	I-Algorithm
.	O
</s>
<s>
The	O
number	O
of	O
samples	B-Algorithm
to	O
average	O
is	O
chosen	O
in	O
order	O
to	O
average	O
on	O
windows	O
of	O
150	O
ms.	O
</s>
<s>
In	O
order	O
to	O
detect	O
a	O
QRS	B-Algorithm
complex	I-Algorithm
,	O
the	O
local	O
peaks	O
of	O
the	O
integrated	O
signal	O
are	O
found	O
.	O
</s>
<s>
This	O
is	O
a	O
physiological	O
constraint	O
due	O
to	O
the	O
refractory	O
period	O
during	O
which	O
ventricular	B-Application
depolarization	I-Application
cannot	O
occur	O
even	O
in	O
the	O
presence	O
of	O
a	O
stimulus	O
.	O
</s>
<s>
Each	O
fiducial	O
mark	O
is	O
considered	O
as	O
a	O
potential	O
QRS	B-Algorithm
.	O
</s>
<s>
To	O
reduce	O
the	O
possibility	O
of	O
wrongly	O
selecting	O
a	O
noise	O
peak	O
as	O
a	O
QRS	B-Algorithm
,	O
each	O
peak	O
amplitude	O
is	O
compared	O
to	O
a	O
threshold	O
(	O
ThresholdI	O
)	O
that	O
takes	O
into	O
account	O
the	O
available	O
information	O
about	O
already	O
detected	O
QRS	B-Algorithm
and	O
the	O
noise	O
level	O
:	O
</s>
<s>
At	O
the	O
beginning	O
of	O
the	O
QRS	B-Algorithm
detection	O
,	O
a	O
2	O
seconds	O
learning	O
phase	O
is	O
needed	O
to	O
initialize	O
SignalLevelI	O
and	O
NoiseLevelI	O
as	O
a	O
percentage	O
of	O
the	O
maximum	O
and	O
average	O
amplitude	O
of	O
the	O
integrated	O
signal	O
,	O
respectively	O
.	O
</s>
<s>
If	O
PEAKI	O
is	O
above	O
the	O
ThresholdI	O
,	O
the	O
algorithm	O
implements	O
a	O
further	O
check	O
before	O
confirming	O
the	O
peak	O
as	O
a	O
true	O
QRS	B-Algorithm
,	O
taking	O
into	O
consideration	O
the	O
information	O
provided	O
by	O
the	O
bandpass	O
filtered	O
signal	O
.	O
</s>
<s>
A	O
check	O
is	O
performed	O
to	O
continuously	O
assess	O
the	O
RR	O
intervals	O
(	O
namely	O
the	O
temporal	O
interval	O
between	O
two	O
consecutively	O
QRS	B-Algorithm
peaks	O
)	O
to	O
overcome	O
this	O
issue	O
.	O
</s>
<s>
If	O
no	O
QRS	B-Algorithm
is	O
detected	O
in	O
a	O
window	O
of	O
166%	O
of	O
the	O
average	O
RR	O
(	O
RRaverage1	O
or	O
RRaverage2	O
,	O
if	O
the	O
heart	O
rhythm	O
is	O
regular	O
or	O
irregular	O
,	O
respectively	O
)	O
,	O
the	O
algorithm	O
adds	O
the	O
maximal	O
peak	O
in	O
the	O
window	O
as	O
a	O
potential	O
QRS	B-Algorithm
and	O
classify	O
it	O
considering	O
half	O
the	O
values	O
of	O
the	O
thresholds	O
(	O
both	O
ThresholdII	O
and	O
ThresholdIF	O
)	O
.	O
</s>
<s>
The	O
algorithm	O
takes	O
particularly	O
into	O
consideration	O
the	O
possibility	O
of	O
a	O
false	O
detection	O
of	O
T	B-Algorithm
waves	I-Algorithm
.	O
</s>
<s>
If	O
a	O
potential	O
QRS	B-Algorithm
falls	O
up	O
to	O
a	O
160	O
ms	O
window	O
after	O
the	O
refractory	O
periody	O
from	O
the	O
last	O
correctly	O
detected	O
QRS	B-Algorithm
complex	I-Algorithm
,	O
the	O
algorithm	O
evaluates	O
if	O
it	O
could	O
be	O
a	O
T	B-Algorithm
wave	I-Algorithm
with	O
particular	O
high	O
amplitude	O
.	O
</s>
<s>
In	O
this	O
case	O
,	O
its	O
slope	O
is	O
compared	O
to	O
the	O
one	O
of	O
the	O
precedent	O
QRS	B-Algorithm
complex	I-Algorithm
.	O
</s>
<s>
If	O
the	O
slope	O
is	O
less	O
than	O
half	O
the	O
previous	O
one	O
,	O
the	O
current	O
QRS	B-Algorithm
is	O
recognized	O
as	O
a	O
T	B-Algorithm
wave	I-Algorithm
and	O
discarded	O
,	O
and	O
it	O
also	O
updates	O
the	O
NoiseLevel	O
(	O
both	O
in	O
the	O
filtered	O
signal	O
and	O
the	O
integrated	O
signal	O
)	O
.	O
</s>
<s>
Once	O
the	O
QRS	B-Algorithm
complex	I-Algorithm
is	O
successfully	O
recognized	O
,	O
the	O
heart	O
rate	O
is	O
computed	O
as	O
a	O
function	O
of	O
the	O
distance	O
in	O
seconds	O
between	O
two	O
consecutive	O
QRS	B-Algorithm
complexes	I-Algorithm
(	O
or	O
R	O
peaks	O
)	O
:	O
</s>
