## 4 Proposed System Architecture
hardware-induced distortions in CSI measurements. These distortions introduce nonlinear variations in amplitude and phase, leading to inconsistencies. To mitigate these distortions, we followed a structured process. First, we conducted baseline data collection by capturing a reference dataset using a coaxial cable connection. This setup eliminated environmental multipath effects, allowing us to establish a baseline for identifying systematic nonlinear distortions introduced by the hardware. Next, we performed error template extraction by analyzing deviations from the expected flat amplitude response and linear phase progression. From this analysis, we derived nonlinear amplitude and phase variations, which were stored as an error template representing hardware-specific biases in CSI measurements. Finally, during real-time correction, we refined the collected CSI data by dividing the measured amplitude values by the stored nonlinear amplitude template and subtracting the extracted nonlinear phase distortions from the raw phase values. This process effectively removed systematic hardware-induced errors, ensuring that the refined CSI data accurately represented the true signal characteristics. By implementing this pre-processing step, we mitigated extreme deviations in phase and amplitude that could otherwise be considered outliers. Additionally, we employed interpolation techniques to handle missing data, further enhancing the consistency and reliability of the processed CSI measurements. In our study, we implemented several pre-processing techniques to ensure the accuracy and consistency of the CSI data by verifying normalization. One of the primary methods we used was the Nonlinear Amplitude and Phase Removal technique by comparing the processed CSI amplitude-frequency and phase-frequency characteristics with an ideal flat and linear response, respectively. The effectiveness of this normalization was confirmed by observing a significant reduction in systematic distortions errors, ensuring that the refined CSI data maintained its true physical characteristics of both amplitude and phase value. Additionally, we employed radio chain offset (RCO) correction to address phase inconsistencies among transceiver antenna pairs. RCO arises due to random phase fluctuations that occur when the network interface card (NIC) is powered on, introducing biases in CSI phase measurements. Since RCO remains stable over consecutive packets, we developed a method to mitigate its effects by subtracting the phase values obtained during subsequent measurements from the initial phase reference. This technique successfully reduced the impact of phase distortions, leading to more stable and uniform CSI phase data. By applying this correction, we ensured that phase values were normalized across different packets, improving the accuracy of angle-of-arrival (AoA) and time-of-flight (ToF) estimations. To further enhance the reliability of CSI data, we implemented central frequency offset (CFO) correction to account for frequency desynchronization between the transmitter and receiver. CFO introduces an unwanted frequency shift in CSI measurements, affecting both amplitude and phase characteristics. To counteract this, we incorporated multiple high throughput-long training fields (HT-LTFs) within Wi-Fi frames, allowing us to analyze the phase differences induced by CFO over a fixed time interval (\(\Delta t=4\) us, _as per the 802.11 standard_). This approach enabled us to estimate and compensate for CFO, effectively aligning the frequency characteristics across all subcarriers. By applying this correction, we eliminated frequency-dependent distortions, ensuring that CSI data remained accurate and consistent. Together, these normalization techniques significantly improved the quality of the CSI data, making it more robust for subsequent signal processing tasks such as localization and human activity recognition.