Research Article

Robust and Accurate Anomaly Detection in ECG Artifacts Using Time Series Motif Discovery

Algorithm 1

Proper length motif discovery algorithm for ECG.
Input: single-lead ECG ,
   : sampling rate
Output: motif: the 1st motif in single-lead ECG
(1) For = startingLength() to.length/2
(2)  := extractSubsequence()
(3)  := Z-norm()
(4)   := motifCandidateDiscovery()
(5)  Group:= createGroup()
(6)  ifGroup.bitsave < 0 then break
(7)  while hasNextNeighbor()
(8)   := NextNeighbor(, Group.center, )
(9)   bs:= BitsaveOfAdd(Group, )
(10)   if bs > Group.bitsavethen
(11)      Group.bitsave += bs
(12)      Group:= AddToGroup(Group, )
(13)   else break
(14)  end
(15)  motif = updateWithMaxBitsave(motif, group)
(16) end for
(17) returnmotif