## 4 Signal Pretreatment
### Error Correction  
In many cases, there exist multiple unexpected glitches in signals after binarization due to the noise effects. As Figure 6 shows, the red circle marks in the block binarization indicate hopping points. Thus, we design the error correction algorithm to eliminate these abnormal hopping voltages and guarantee an accurate subsequent decoding process. The first step is to compute a threshold of durations for the purpose of localizing the emerging glitch positions. By using the algorithm in Section 2.2, duration data corresponding to each level can be partitioned into three clusters with three centroids in an ascending sort order, denoted by \(C_{d}=[C_{d1}\), \(C_{d2}\), \(C_{d3}]\). Then, if \(C_{d2}/C_{d1}>3.5\), it means that data samples clustered around \(C_{d1}\) are from the glitches, and the basic dot duration unit is given by \(D_{0}=C_{d2}\). Otherwise, it means the waveform is good, no jump level exists, and \(D_{0}=C_{d1}\). Then, the duration threshold can be obtained as \(D_{T}=e_{1}{}^{*}\!D_{0}\), where \(e_{1}\) denotes an adjustable parameter. In addition, we assume \(e_{1}=0.3\) at this time. The ratio 3.5 and \(e_{1}=0.3\) are established based on the experimental dataset observations for the optimal decoding result. To increase the identifying accuracy, we introduce the average voltage amplitude as the second judgement criteria beyond the duration data. The average voltage amplitude refers to the statistical average of all sampled voltage values during a period of one level (\"0\" or \"1\"). Assume two new voltage thresholds, described as  
\[ \begin{array}{l}V_{TH}=V_{T}+V_{pp}\times e_{2}\\ V_{TL}=V_{T}-V_{pp}\times e_{2}\end{array}  \tag{5}\]  
where \(V_{T}\) is the binarization voltage threshold computed in Section 4.2, \(V_{pp}\) denotes the peak-peak voltage value, and \(e_{2}\) represents another adjustable parameter; it is also established based on the experimental dataset observations and is set at 0.25 in this case for the optimal decoding result. In addition, using a different value may lead to erratic performance in our experiment. Let us denote \(D_{c}\) and \(V_{ac}\) to the current duration and average voltage value during one level, respectively; then, the glitches can be localized under the following constraint:  
\[D_{c}\;<\;D_{T}\;\parallel V_{TL}\;<\;V_{ac}\;<\;V_{T}\;\parallel\;V_{T}\;< \;V_{ac}\;<\;V_{TH}. \tag{6}\]  
After marking the hopping glitches, it is time to identify their position relations to the normal voltage level. To be precise, there should be six different statuses of the emerging voltage spikes, which can represent all potential situations. In addition, the voltage spike can be either low or high. As long as the duration of a level is less than the computed duration threshold, it is considered as a voltage spike and merging is performed until meeting a complete voltage level (duration higher than threshold). These six cases are distinguished according to whether the transition part can form a complete level and its adjacent level condition (high or low). As the Figure 8 shows: (a) If several consecutive spikes can form a complete level after merging their duration (no longer a spike) and its adjacent level is low, then the combined one is set at high, denoted by the red line; (b) similar to (a), if the adjacent is high, then the combined one is set at low; (c) if the combined spike is still a spike after merging their duration and its adjacent level is low, then change it to low level, denoted by the red line; (d) similar to (c), if the adjacent level is high, change it to low level; (e) and (f) if the combined spike still cannot form a complete level after merging their duration, and its previous and next complete levels are of different types (one high and one low), then superimpose half of its duration time to the preceding and succeeding complete levels, respectively. Take the string \"SOS\" as an example; Figure 9 presents its corresponding signal waveform during the whole pretreatment process.