# Device-Free Indoor Activity Recognition System
## 2 Methodology
### Preprocessing  
We collect CSI from WiFi signals that emit from WiFi router (TP-LINK) which has two transmitter antennas, and the receiver is a Lenovo ThinkPad X201 which was equipped with Intel Wifi Link (IWL) 5300 Network Interface Controller (NIC) that has three receiver antennas (Intel Corporation, Santa Clara, CA, USA). The laptop is installed with Ubuntu version 14.04 and run the Open Source CSI-Tools [21]. As is known in the OFDM system, we can get \(2\times 3\) the Multiple-Input and Multiple-Output (MIMO) system. Thus, we get six streams. In each stream, there are 30 subcarriers because 5300 NIC reports CSI 30 groups of subcarriers for each stream [21]. Thus, the CSI we get can be represented as Equation (1):  
\[H=\left[\begin{array}{cccc}H_{\text{I},\text{J1}}&H_{\text{I},\text{J2}}&... &H_{\text{I},\text{J30}}\\ \vdots&\vdots&\vdots&\vdots\\ H_{\text{I}6,\text{J1}}&H_{\text{I}6,\text{J2}}&...&H_{\text{I}6,\text{J30}} \end{array}\right], \tag{1}\]  
where \(H\) is the CSI, \(i\) and \(j\) are the streams and subcarriers, respectively. Each element in the CSI matrix in Equation (1) is expressed as the following:  
\[H_{i,j}=\parallel H_{i,j}(f_{k})\parallel e^{j\angle H_{i,j}(f_{k})}+n, \tag{2}\]  
where \(\parallel H_{i,j}(f_{k})\parallel\) is the amplitude, \(\angle H_{i,j}(f_{k})\) is the phase, and \(f_{k}\) is the central frequency, where \(n\) is the electromagnetic noise from the adjoining devices. Here, we use only the amplitude information of CSI.  
Figure 1: System architecture and workflow, Channel State Information (CSI); Sparse Representation Classification (SRC).  
Figure 2 shows the 30 subcarriers that represent one CSI stream value of the walking activity. However, the real trend of CSI is drowned in the noise from the bordering environments. To remove the noise and obtain the actual trend and the useful information of CSI, we employ a weighted moving average (WMA). From Figure 2 (bottom), we see that the weighted moving average eliminates noise effectively and keeps the real trend of CSI.  
Figure 3 shows the whole streams that we got from a walking activity experiment. The values of subcarriers in each stream are different. Accordingly, to reduce the computing complexity, we aggregate all 30 subcarriers of each stream into one single value (stream vector) by calculating the average value of the 30 subcarriers of each stream as portrayed in Figure 4.  
Figure 3: Thirty subcarriers of each stream.  
Figure 2: Original CSI information (**top**) and CSI after Weighted Moving Average (WMA) (**bottom**).  
As shown in Figure 4, the CSI streams have a distinctive sensitivity to the fluctuation of CSI due to human motion, so the values of the six streams are different. In Figure 4, streams 1 and 4 do not have enough sensitivity to the human activity, so, as shown in the figure, stream 1 and stream 4 are almost flat. Therefore, such streams must be eliminated. To this end, we use the bad stream elimination algorithm, which was described in the previous work [22], to eliminate bad streams. The bad stream elimination algorithm calculates the difference between the maximum peaks and valleys (Max-Min), the mean value (Means) and standard deviation (STD) as features in every spatial diversity. These three features are put into the Naive Bayesian classifier as vectors. Thereafter, the Naive Bayesian classifier is used to find and eliminate bad streams in case significant error happens when we choose bad streams as our source data. Thus, our system chooses only the best streams that can provide us useful information and also avoid false detection.