## 3 Signal Quality Index Algorithm
### Post-Process  
In the post-process, the SQIs of the PPG pulses were classified by a SoNFIN [19]. SoNFIN is a five-layer fuzzy neural network, whose fundamental framework is shown in Figure 6. In addition, the fuzzy model of the SoNFIN can be represented by the following expression [20]:  
\[\begin{array}{rl}\text{Rule }j:&\text{If }x_{1}\text{ is }A_{1j}\text{ and }\cdots\text{ and }x_{n}\text{ is }A_{nj}\\ &\text{Then }y_{j}\text{ is }w_{0j}+\sum\limits_{i=1}^{n}w_{ij}x_{j}\end{array}\]  
where \(x_{i}\) is the input variable, \(y_{j}\) is the output variable, \(A_{ij}\) is a fuzzy set, and \(w_{0j}+\sum\limits_{i=1}^{n}w_{ij}x_{i}\) is the traditional TSK model. The five layers are described in detail as follows.  
Layer 1: No computation is performed in this layer. Each node in this layer corresponds to one input variable. Only input values containing the four parameters are transmitted forward to the next layer directly:  
\[u_{i}^{(1)}=x_{i}. \tag{7}\]  
Layer 2: For the fuzzy set \(A_{ij}\), a Gaussian membership function is used to describe the degree that the input variable \(x_{j}\) belongs to the \(i\)-th fuzzy set. Its mathematical function is defined as follows:  
\[u_{ij}^{(2)}=\exp(\frac{-\left[u_{i}^{(1)}-m_{ij}\right]^{2}}{\sigma_{ij}^{2}}) \tag{8}\]  
where \(m_{ij}\) and \(\sigma_{ij}\) are the center and width of the membership function, respectively. This function is implemented by each node.  
Figure 5: The PPG signal (solid line) and the smoothed PPG signal (dashed line). E, C, and A are the peaks, and E, D, and B are the valleys in the smoothed PPG signal, respectively. (**a**) Schematic explanation for the difference ratio of intervals (dl). (**b**) Schematic explanation for the difference ratio of magnitudes (dM).  
Layer 3: A node in this layer represents one fuzzy logic rule and performs the precondition matching of a rule. Here, we employ the following product operation for each Layer 3 node:  
\[u_{j}^{(3)}=\prod_{i}u_{ij}^{(2)}. \tag{9}\]  
Layer 4: Nodes in this layer are called the consequent nodes. Each node is linked to Layer 3 output, and the linear association of the weights in this layer is as follows:  
\[u_{j}^{(4)}=u_{j}^{(3)}(w_{0j}+\sum_{i=1}^{n}w_{ij}x_{i}). \tag{10}\]  
Layer 5: Each node in this layer corresponds to one output variable. The node integrates all the actions recommended by Layer 5 and acts as a defuzzifier with  
\[o=u^{(5)}=\frac{\sum\limits_{j=1}^{p}u_{j}^{(4)}}{\sum\limits_{j=1}^{p}u_{j}^{ (3)}}=\frac{\sum\limits_{j=1}^{p}u_{j}^{(3)}(w_{0j}+\sum\limits_{i=1}^{n}w_{ ij}x_{i})}{\sum\limits_{j=1}^{p}u_{j}^{(3)}}. \tag{11}\]  
The number of output nodes is equal to that of classification. In the study, the number of the output node is one, and its value represents SQI.  
Two types of training (structure and parameter training) were used concurrently to construct the SoNFIN. Initially, there were no rules in the SoNFIN, with all rules constructed by the online structure training. For the structure training, a predefined threshold, H, was used as a criterion for the generation of fuzzy rules. When the output of Layer 3 was below H for every rule, a new rule was generated. Therefore, more rules were generated for a larger value of H. The initial width of  
Figure 6: Fundamental framework of the five-layer self-constructing neural fuzzy inference network (SoNFIN).  
each generated Gaussian fuzzy set was decided by a predefined constant \(\sigma\). To train the parameters, the objective is to minimize the error function (\(V_{error}\)),  
\[V_{error}=(d-o)^{2} \tag{12}\]  
where \(d\) is the designed output. The consequent part and the fuzzy-set parameters were tuned by a recursive least-squares algorithm and a gradient-descent algorithm, respectively. The details of the training algorithm were found elsewhere [19]. In the study, the threshold \(H\) was set to \(10^{-11}\), the initial value of the parameter \(\sigma\) was set to 0.05, and 2000 times of iteration were performed in the training procedure. The consequent learning rate was set to 0.001.