# TwSense: Highly Robust Through-the-Wall Human Detection Method Based on COTS Wi-Fi Device
## 4 System Architecture
### Data Preprocessing  
The first component of processing the collected CSI data is the removal of abnormal values. From the experimental process and the collected data, there is a mixture of abnormal data not caused by human motion, so these data need to be removed. Since commercial Wi-Fi equipment is very susceptible to the influence of complex indoor and outdoor environments, especially in the condition of passing through-the-wall, it will become more serious; it will make the raw CSI data contain noise that affects the human detection results, so the CSI data should first be denoised [20]. Here, we use a denoising method based on discrete wavelet transform to remove random noise and smooth the CSI data. The PCA algorithm is used to select the optimal subcarrier in the channel to reduce the data dimension and computational complexity. In this way, the complexity of the data can be effectively reduced, and the optimal sub-carrier can be selected to represent the channel. Compared with the original CSI data, the data after using the PCA algorithm is smoother and cleaner, and a specific CSI correlation can be extracted. The quality of the CSI  
Figure 3: CSI signal and Doppler shift: (**a**) Antenna selection; (**b**) Spectrogram of Doppler. correlation determines the accuracy of the final human detection. However, when walls block all direct and reflected propagation paths between the transmitter and receiver, the change in CSI value caused by human activities becomes small, and existing denoising techniques (PCA) may lead to a poor final classification effect. The reason is that the CSI correlation directly extracted from the raw CSI measurements includes not only the correlation between human activities but also the correlation between the background environment and noise, which will seriously interfere with the CSI correlation between human activities and the changes in CSI values caused by them. Table 1 shows the signal attenuation for the different wall materials. Therefore, we must eliminate the complex indoor propagation environment and noise interference on the waveform. Here, we chose OR-PCA for correlation extraction of CSI. According to CSI magnitude matrix analysis and low-rank matrix decomposition theory, OR-PCA divides the original CSI measurement into two components: the indoor physical environment CSI value and the changed CSI value, which are separated into two components. In order to obtain only the CSI value due to human movement and thus detect the presence of a person, we need to separate the original CSI from other ambient noise, such as walls, and the separation process can be expressed as follows:  
\[\text{min}{\left\|CSI_{wall}\right\|_{\oplus}}+\gamma{\left\|CSI_{person} \right\|_{1}} \tag{10}\]  
\[s.t.\ CSI_{raw}=CSI_{wall}+CSI_{person} \tag{11}\]  
where \(CSI_{raw}\) is the original CSI value, \(CSI_{wall}\) and \(CSI_{person}\) is the CSI values from other environments, such as walls and changes caused by human actions, respectively. In Equation (6), \(B\) is equivalent to \(CSI_{person}\), which should be removed for sparse noise, but \(CSI_{person}\) contains the CSI value caused by human activities and noise, so the augmented Lagrange multiplier method is used to solve it. OR-PCA extracts the CSI value after eliminating the influence of the environment and noise on the waveform by eliminating the CSI value of the physical environment OR-PCA extracts the CSI values that contain only the changes caused by human motion as much as possible by eliminating the CSI values of interference signals generated by other environmental noises, such as walls, so that the changes in CSI values are more pronounced than raw values. In this way, even if the Wi-Fi signal passes through-the-wall, the OR-PCA  
Figure 4: The system architecture of TwSense. waveform will change significantly when the human activity state occurs.