CSI fingerprint preprocessing (median, mean, Hampel, Wiener filter, state statistics filter)

Table of contents

foreword

1. Box-line method

2. Median filter

3. Mean filter

4. Hampel filter

5. Wiener filter

6. State statistics filter


foreword

Due to the influence of factors such as equipment, temperature, and laboratory items, unprocessed CSI data cannot be used directly, and the data needs to be processed for outliers to ensure the stability of the data and reduce human activities and sudden interference in the environment. For the impact on CSI, the following will briefly discuss the processing of CSI amplitude data by several filters that come with MATLAB. Some upgraded filter programs are up to you to think about.

1. Box-line method

The box-line method is mainly used to reflect the characteristics of the original data distribution, and can also compare the distribution characteristics of multiple sets of data. We can first use the box-line method to visualize outliers. The box-line method to visualize outliers and the box-line method comparison are given below Figure, if you are interested, you can find out by yourself.

  Figure 1 Box-line method to visualize outliers

  Figure 2 Comparison chart of box-line method 

2. Median filter

Median filtering is a nonlinear filtering method that can effectively remove noise in a signal while retaining edge information in the signal. The basic idea of ​​median filtering is to replace the value of each sampling point in the signal with the median value within a certain range around the point.

In MATLAB, you can use the medfilt1 function to perform median filtering on the signal. The syntax of this function is:

y = medfilt1(x, w)

x represents the data we want to process; w represents the window size of the mean filter, and y represents the filtered result.

load('raw_amp');
best_amp= medfilt1(raw_amp, 5);
figure(1)
plot(raw_amp);
title('原始幅值');
ylabel('幅值');
figure(2)
plot(best_amp);
title('中值滤波');
ylabel('幅值');

Magnitude images before and after median filtering:

 Figure 3 Before median filter processing

  Figure 4 After median filter processing

3. Mean filter

Mean filtering is a linear filtering method that can be used to smooth signals and remove noise. The basic idea of ​​mean filtering is to replace the value of each sampling point with the average value within a certain range around the point.

The smoothdata function can be used in MATLAB to perform mean filtering on the signal. The syntax of this function is:

y = smoothdata(x, 'movmean', w)

 x represents the data we want to process; w represents the window size of the mean filter, and y represents the filtered result.

best_amp2 = smoothdata(raw_amp, 'movmean', 5);
figure(3)
plot(raw_amp);
title('原始幅值');
ylabel('幅值');
figure(4)
plot(best_amp2);
title('均值滤波');
ylabel('幅值');

 Magnitude images before and after mean filtering:

Figure 5 Before mean filtering 

Figure 6 After mean filtering

4. Hampel filter

Hampel filter is a median-based outlier detection and filtering method. It identifies outliers by median filtering the signal and computing the distance of each data point from the median. If the distance is greater than a certain threshold, the data point is considered an outlier and replaced with the median. This method has anti-noise ability and good ability to identify outliers. It is commonly used in data cleaning, anomaly detection, and signal preprocessing.

MATLAB can use the hampel function to filter the signal. The syntax of this function is: 

y=hampel(x,k,nsigma)

x represents the data we want to process; k represents the number of samples around each sample in the specified window, the default is 3; nsigma represents the standard deviation of the specified multiple; y represents the filtered result. 

great_data = hampel(raw_amp,5,2);
figure(5)
plot(1:1:30,raw_amp);
title('原始幅值');
ylabel('幅值');
figure(6)
plot(1:1:30,great_data);
title('Hampel低通滤波');
ylabel('幅值');

 Magnitude images before and after Hampel filtering:

Figure 7 Before Hampel filter processing  

Figure 8 After Hampel filtering  

5. Wiener filter

Wiener filtering is a two-dimensional adaptive denoising filter that adjusts the filter effect according to local variance. It is effective for removing Gaussian noise.

The two functions wiener2 and deconvwnr of the Wiener filter can both complete the function of the Wiener filter, but the two have differences, and those who are interested can understand it by themselves. The Wiener filter code in MATLAB is as follows:

y=wiener2(x,[m,n]);

x refers to the amplitude of the original CSI; y refers to the amplitude after Wiener filtering; [m,n] specifies that the filter window size is m*n, and the default value is 3*3.

load('raw_amp');
m=5;
n=5;
best_amp3=wiener2(raw_amp,[m,n]);
figure(7)
plot(raw_amp);
title('原始幅值');
ylabel('幅值');
figure(8)
plot(best_amp3);
title('维纳滤波');
ylabel('幅值');

  Magnitude images before and after Wiener filtering:

 Figure 9 Before Wiener filtering  

 Figure 10 After Wiener filtering  

6. State statistics filter

Its filtering concept is an extension of the median filter. The median filter is to arrange them in order of size for a given n values ​​​​{al, a2,..., an}, and take the middle value as the value of the filter. output. The state statistics filter sorts the n non-zero values ​​from small to large and then the element at the kth position is taken as the output of the filter. The state statistical filter in MATLAB can be expressed by the ordfilt2 function:

y=ordfilt2(x,order,domain);

x refers to the amplitude of the original CSI; y refers to the amplitude after state statistics filtering; order is the order value output by the filter; domain is the filtering window;

(1) y=ordfilt2(x,13,ones(5,5)), when the pixel values ​​in the template are all non-zero, it is equivalent to a median filter with a template of 5×5 (order=13, which happens to be a window middle value);

(2) y=ordfilt2(x,1,ones(5,5)), when the pixel values ​​in the template are all non-zero, it is equivalent to 5×5 minimum value filtering (order=1, just the minimum of the window value);

(3) y=ordfilt2(x,25,ones(5,5)), when the pixel values ​​in the template are all non-zero, it is equivalent to the maximum value filtering of 5×5 (order=25, just the maximum of the window value);

load('raw_amp');
order = 10;
domain = ones(5,5);
best_amp4=ordfilt2(raw_amp,order,domain);
figure(8)
plot(raw_amp);
title('原始幅值');
ylabel('幅值');
figure(9)
plot(best_amp4);
title('状态统计滤波器');
ylabel('幅值');

 Magnitude images before and after state statistical filter processing:

  Figure 11 State statistics filter before processing

Figure 12 After state statistics filter processing 

For related articles on CSI , please refer to: Kalman filtering, Gaussian filtering, and simple average of CSI data preprocessing The equation is an algorithm for optimally estimating the system state through the input and output observation data of the system. Since the observation data includes the influence of noise and interference in the system, the optimal estimation can also be regarded as a filtering process. The Kalman filter algorithm makes a correction between the estimated and observed values. .......................... https://blog.csdn.net/qq_53860947/article/details/126175335

CSI Fingerprint Positioning for Indoor Positioning , MI-MO) and orthogonal frequency division multiplexing (Orthogonal Frequency Division Multiplexing, OFDM) and other technologies, so that the channel characteristics between WiFi transceiver devices can be estimated at the physical layer, and channel status information (Channel status information, CSI ) is stored in the form of https://blog.csdn.net/qq_53860947/article/details/126180830

Guess you like

Origin blog.csdn.net/qq_53860947/article/details/130467451