## 2 Materials and Methods
### Location and Recognition-Based AMNBP  
Based on feature enhancement of the original signal using CEEMDAN-KL, an AMNBP coding algorithm is proposed in this paper to meet the requirements of fast location and recognition of invasion events in practical environments and to reduce the influence of the fading effect. AMNBP was based on the LBP algorithm [21; 22]. According to the characteristics of \(\Phi\)-OTDR system, signals are collected point by point along the fiber direction. CEEMDAN-KL reduces the impact of noise on the coding. Afterward, the final AMNBP coding results are optimized using the moving average sliding window, which also decreases the influence of dead-zone detection. The coding flowchart of AMNBP is shown in Figure 5. The coding steps of the AMNBP are as follows:  
1. Set the window length as \(W\), where the length shall be less than or equal to the detection event length. The data in the window is divided into four parts, and each \(W\)/4 data set corresponds to a code. 2. Compare the four coding lengths in the window with the mean values in the window. If the mean of the \(W\)/4 data set is less than or equal to the window mean, the coded value is denoted as 0; otherwise, it is denoted as 1: \[s^{\prime}(t)=\left\{ \begin{array}{l}1,\;s_{i}>ref\\ 0,s_{i}\leq ref,\end{array} \right.\] (13) \[ref=\frac{4}{W}\sum_{i=1}^{W/4}s_{i}.\] (14)
3. Slide along a step and obtain the moving neighbor binary code in turn. 4. The binary coding sequence is converted to a decimal. To ensure the differentiation degree of the acquired sequence of different events with the same background noise, it is necessary to readjust the relationship between the mean value of all data and the mean value of the noise to obtain the decimal sequence: \[s^{\prime\prime}(i)=\left\{ \begin{array}{l}s^{\prime}(i)*\frac{s^{\prime }(i)_{W/4}}{2},\;if:\widehat{s}\geq\overline{n}\\ s^{\prime}(i)*\frac{\overline{n}}{s},\;if:\widehat{s}<\overline{n}.\end{array} \right.\] (15)  
To select an appropriate window length, the optimal window selection was found by calculating the AMNBP value of the signal at different window lengths, and the standard knocker was used for multiple tests in practical environments. The sampling frequency was 4 kHz. This means that each point of data represented 0.25 milliseconds. The sampling frequency and spatial resolution determine the fine granularity of the final determined location. To facilitate the inspection, the AMNBP value of the signal was compared with the AMNBP value of the noise. The difference in AMNBP values between various scales of the window is shown in Figure 6, where the black dashed line is the difference between the initial moving neighbor binary pattern (MNBP) of the percussive signal and the noise. After the adaptive adjustment, the red solid line was obtained, and the blue curve represents the trend of AMNBP difference. To prevent the occurrence of underreporting, we selected the first high point and obtained the optimal distinguishing effect when the window number was equal to 400 (i.e., at 0.1 s). By comparing the AMNBP value of the detection signal and the noise, the signal could be quickly detected and located, as shown in Figure 7. To facilitate the presentation in the paper, this graph is transposed. The abscissa in the figure represents the time. Each grid corresponds to 100 data points, the sampling rate is 4 kHz, and the corresponding time length is 0.1 s. The vertical coordinate represents the distance, and the resolution is 1 m. It can be found from Figure 7 that there was a corresponding time within the range of three meters (255-257 m), which occurred intermittently with time. Figure 5: The coding flowchart of adaptive MNBP (AMNBP). Figure 6: The relationship between the window length and the AMNBP differences. The two-dimensional heat map drawn using the AMNBP coding sequence can quickly locate the target events accurately. It can be seen from the figure that the minimum unit of location depends on the spatial separation rate and sampling frequency of the \(\Phi\)-OTDR system.