A wearable electroencephalogram system and method for contact impedance compensation and inertial sparse denoising
Patent Information
- Application Number
- CN202611176807.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-05
- Publication Date
- 2026-10-23
AI Technical Summary
将上述方案进行简单组合,至多能获得一个可多模态采集、硬件集成化并具备上位机去噪能力的脑电设备,而根本无法得到一种在嵌入式前端对干电极接触阻抗进行闭环动态补偿、并利用惯性数据进行实时稀疏分解去噪的系统性解决方案
[0050]利用芯片内可编程增益放大器优先保证信号信噪比,从根本上确保长时间记录中脑电幅值的准确性与基线稳定性;同时提出基于惯性数据构建专用过完备字典的稀疏分解运动伪影去除方法,无需参考通道或远端服务器,直接在微控制器上借助同步运动信息,通过运动状态分级滤波与多尺度时移构建匹配佩戴者运动模式的专属干扰模板,结合递推系数求解和通道相关性复用策略,在满足实时性要求的同时消除云端延迟与隐私风险,从数据源头净化信号,为实时脑机接口提供关键技术支撑;此外,采用模块化设计并复用模拟前端芯片恒流源与可编程增益放大器,实现无额外电路开销的阻抗在线监测与闭环补偿,所采用的戈泽尔算法、自适应平滑滤波、改进贪婪匹配等均为轻量级算法,配合增量式字典更新与通道相关性复用等优化,进一步压缩运算负载,使系统在小型化、低功耗和低成本下具备强大的前端信号智能处理能力,高度适用于实际穿戴式应用。
Smart Images

Figure CN122954433A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of bioelectric signal acquisition and wearable device technology, specifically relating to a wearable EEG system and method with contact impedance compensation and inertial sparsity denoising. Background Technology
[0002] Electroencephalography (EEG) is a technique that records the spontaneous, rhythmic electrical activity of brain nerve cell groups using electrodes. It is widely used in brain science research, the diagnosis of neurological diseases such as epilepsy, and brain-computer interfaces. With advancements in wearable and IoT technologies, portable devices capable of long-term, low-intensity EEG monitoring in everyday natural environments are in high demand. These devices often use dry electrodes to simplify the wearing process, avoiding the problems of long preparation times and poor user experience associated with traditional wet electrodes that require the application of conductive gel.
[0003] However, dry electrode wearable EEG acquisition systems face two major common technical challenges in practical applications, which severely restrict their signal quality and reliability in dynamic environments.
[0004] First, there is the issue of fluctuating contact impedance of dry electrodes. The impedance at the contact interface between dry electrodes and the scalp is unstable and easily affected by various factors such as wearing tightness, hair obstruction, sweat secretion, and head movement, resulting in dynamic changes. Increased contact impedance directly leads to attenuation of the amplitude of the acquired EEG signal and low-frequency baseline drift, introducing severe distortion. In existing technologies, some solutions (such as utility model patent CN222285483U) integrate an impedance detection module, but its function is limited to binary judgment of "lead detachment," that is, it can only determine whether the electrode is completely detached from the scalp, and cannot monitor the continuous value of contact impedance in real time and quantitatively. More importantly, existing technologies completely lack a mechanism for closed-loop and dynamic compensation of the signal acquisition link gain based on dynamic impedance changes, resulting in continuous degradation of signal quality due to increased impedance even if the electrode is not completely detached.
[0005] Secondly, there is the problem of motion artifact interference. Wearable devices introduce large-amplitude, wide-bandwidth motion artifacts when users perform everyday actions such as turning their heads and walking. These artifacts often overlap with EEG signals, severely contaminating the useful signal. Current mainstream denoising solutions heavily rely on post-processing algorithms on the host computer. For example, the solution disclosed in CN222285483U uses a lightweight network model running on the host computer for denoising; invention patent application CN121300619A only uses motion sensor data as an auxiliary feature for emotion classification, rather than for artifact removal. None of these solutions simultaneously utilize inertial sensor reference signals for real-time, efficient motion artifact separation at the resource-constrained embedded acquisition end. This edge-cloud separation processing mode not only introduces latency but also fails to immediately improve signal quality at the data source.
[0006] Furthermore, existing technical solutions are typically piecemeal combinations addressing single problems. For example, patent CN109077722A focuses on the hardware synchronous acquisition architecture of multimodal signals such as EEG and ECG; CN121300619A focuses on backend emotion computing and music generation applications; and CN222285483U focuses on hardware circuit integration and upper-computer software noise reduction. Simply combining these solutions can at most yield a multimodal acquisition device with hardware integration and upper-computer noise reduction capabilities, but it cannot provide a systematic solution for closed-loop dynamic compensation of dry electrode contact impedance at the embedded front end and real-time sparse decomposition noise reduction using inertial data. In summary, existing technologies urgently need a wearable EEG system and method that can fundamentally and synergistically solve the two major problems of impedance instability and motion interference, achieving signal self-purification and self-stabilization at the acquisition front end. Summary of the Invention
[0007] To address the shortcomings of the prior art, this application provides a wearable EEG system and method with contact impedance compensation and inertial sparsity denoising.
[0008] In a first aspect, this application proposes a wearable EEG system with contact impedance compensation and inertial sparsity denoising, including a multi-channel EEG signal acquisition and system control module. The multi-channel EEG signal acquisition and system control module includes an analog front-end chip and a microcontroller. The analog front-end chip integrates a programmable gain amplifier, an analog-to-digital converter, and a programmable constant current source. It also includes:
[0009] The online contact impedance monitoring and dynamic compensation module is configured to control the programmable constant current source to inject an excitation current with a constant amplitude and a frequency outside the bandwidth of the EEG signal into the electrode pair under test within a preset monitoring period, and to collect the response voltage. The contact impedance value is calculated in real time based on the ratio of the response voltage to the fundamental amplitude of the excitation current, and the corresponding gain compensation amount is found in the pre-calibrated impedance-gain mapping relationship based on the contact impedance value, so as to control the programmable gain amplifier to perform analog domain gain compensation.
[0010] The inertial data synchronous acquisition and preprocessing module is configured to synchronously acquire multi-channel EEG data output by the analog front-end chip and acceleration and angular velocity data output by the six-axis inertial measurement unit under the same interrupt source triggering, and perform physical quantity conversion and synthesis on the acceleration and angular velocity data to obtain a motion feature sequence characterizing the intensity and rate of change of head movement.
[0011] The motion interference waveform template library construction module is configured to extract multiple basic waveform segments from the motion feature sequence, perform multi-scale time translation and frequency band selective filtering based on motion state classification on each basic waveform segment, and merge all processed waveform segments into an overcomplete dictionary;
[0012] The motion artifact separation and removal module is configured to use the overcomplete dictionary as a sparse representation basis to perform an iterative sparse decomposition algorithm on the EEG data after analog domain gain compensation, estimate the motion artifact components, and obtain the motion artifact-suppressed EEG signal by subtracting the motion artifact components from the EEG data.
[0013] In some embodiments, the online contact impedance monitoring and dynamic compensation module is further configured to:
[0014] When the contact impedance value exceeds the preset reliable contact threshold but does not reach the detachment threshold, the gain compensation amount is applied to the analog gain control terminal of the programmable gain amplifier.
[0015] When the adjustment of the analog gain control terminal has reached its upper limit but the contact impedance value continues to increase, the gain compensation amount is applied to the EEG data in the form of a digital gain coefficient to achieve digital domain compensation.
[0016] In some embodiments, when calculating the contact impedance value, the online contact impedance monitoring and dynamic compensation module uses the Gosser algorithm to extract the amplitude of the collected response voltage at a single frequency point. The target frequency of the Gosser algorithm is set to be consistent with the fundamental frequency of the excitation current.
[0017] In some embodiments, the inertial data synchronous acquisition and preprocessing module acquires the motion feature sequence in the following manner:
[0018] The acceleration data is converted into an acceleration vector, and the angular velocity data is converted into an angular velocity vector;
[0019] Calculate the magnitude of the acceleration vector to obtain the acceleration amplitude;
[0020] Calculate the magnitude of the angular velocity vector to obtain the angular velocity amplitude;
[0021] Calculate the first-order backward difference of the acceleration amplitude and the angular velocity amplitude respectively to obtain the rate of change of acceleration amplitude and the rate of change of angular velocity amplitude;
[0022] The acceleration amplitude, the angular velocity amplitude, the rate of change of the acceleration amplitude, and the rate of change of the angular velocity amplitude are combined into a four-dimensional vector to form the motion feature sequence.
[0023] In some embodiments, the inertial data synchronous acquisition and preprocessing module is further configured to: use an exponentially weighted moving average filter with an adaptively adjustable smoothing factor to smooth each dimension of the four-dimensional vector to obtain a smoothed motion feature sequence; wherein the smoothing factor takes different values depending on whether the absolute value of the difference between the current sample value and the previous smoothed value exceeds a dynamic threshold, the dynamic threshold being proportional to the previous smoothed value and supplemented with a preset absolute constant.
[0024] In some embodiments, the motion interference waveform template library construction module includes:
[0025] A waveform extraction unit is used to extract multiple basic waveform segments from the motion feature sequence with a preset fixed time window and step size.
[0026] A classification unit is used to calculate the average acceleration amplitude and average angular velocity amplitude of each of the basic waveform segments within the time window, and to classify the basic waveform segments into one of at least three motion state levels based on the relationship between the combination of the two average amplitudes and at least two preset threshold intervals.
[0027] The filter bank includes multiple bandpass filters that correspond one-to-one with the at least three motion state levels, wherein the passband range of the bandpass filters corresponding to different motion state levels is different, and the passband corresponding to the more intense motion state level is wider.
[0028] Each basic waveform segment extracted by the waveform extraction unit is filtered by a bandpass filter corresponding to its motion state level and then included in the overcomplete dictionary.
[0029] In some embodiments, the motion interference waveform template library construction module further includes a time translation unit, which performs translation operations on each filtered waveform segment on the time axis, including at least three types of offsets: advance, no offset, and lag, to generate multiple waveform copies; all of the waveform copies are imported into the overcomplete dictionary.
[0030] Secondly, this application proposes a wearable method for acquiring and processing electroencephalogram (EEG) signals, including:
[0031] Simultaneously acquire multi-channel EEG data and motion data from a six-axis inertial measurement unit, and process the motion data to generate motion feature sequences;
[0032] A complete dictionary was constructed from the motion feature sequence;
[0033] During the intervals of EEG data acquisition, current is periodically injected into the electrodes through a constant current source inside the simulated front-end chip to calculate the contact impedance value between the electrodes and the scalp.
[0034] The corresponding gain compensation amount is found in the preset impedance-gain mapping relationship based on the contact impedance value. Analog domain compensation is preferentially performed by adjusting the gain factor of the programmable gain amplifier inside the analog front-end chip. When the analog domain compensation cannot completely offset the signal attenuation, digital domain gain compensation is performed on the EEG data.
[0035] Based on the overcomplete dictionary, iterative sparse decomposition is performed on the gain-compensated EEG data to estimate and remove motion artifacts, and output a clean EEG signal.
[0036] In some embodiments, calculating the contact impedance value of the electrode-scalp specifically includes:
[0037] The constant current source is controlled to generate a square wave excitation current with a specific fundamental frequency outside the frequency band of EEG signals ranging from 0.5Hz to 100Hz.
[0038] The voltage response signal generated on the electrode pair under test under the action of the excitation current is acquired synchronously.
[0039] The Gossel algorithm is applied to the voltage response signal, the iteration coefficients of which are matched with the specific fundamental frequency, to extract the voltage amplitude that corresponds only to the specific fundamental frequency from the voltage response signal;
[0040] The extracted voltage amplitude is divided by the known fundamental current amplitude of the square wave excitation current, and the quotient is the contact impedance value.
[0041] In some embodiments, constructing a complete dictionary from the motion feature sequence specifically includes:
[0042] According to the preset time window length and sliding step size, extract several multidimensional motion feature subsequences from the motion feature sequence;
[0043] Based on the parameters characterizing motion intensity in each segment of the multidimensional motion feature subsequence, they are classified into multiple preset motion state levels;
[0044] For each subsequence after classification, frequency domain shaping is performed using a bandpass filter corresponding to the motion state level;
[0045] For each subsequence after frequency domain shaping, perform at least time axis forward shift, backward shift, and translation without offset operations to generate multiple waveform atoms;
[0046] After all waveforms are atomically vectorized, they are arranged in columns to form the overcomplete dictionary.
[0047] Thirdly, this application proposes an electronic device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the method described above.
[0048] Fourthly, this application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the method described above.
[0049] The beneficial effects of this invention are:
[0050] By prioritizing the signal-to-noise ratio using an on-chip programmable gain amplifier, the accuracy of EEG amplitude and baseline stability during long-term recordings are fundamentally ensured. Simultaneously, a sparse decomposition motion artifact removal method based on inertial data and a dedicated overcomplete dictionary is proposed. This method eliminates the need for reference channels or remote servers, directly utilizing synchronous motion information on the microcontroller. Through motion state-level filtering and multi-scale time shifting, a dedicated interference template matching the wearer's motion pattern is constructed. Combined with recursive coefficient solving and channel correlation reuse strategies, this method eliminates cloud latency and privacy risks while meeting real-time requirements, purifying the signal at the data source and providing key technical support for real-time brain-computer interfaces. Furthermore, a modular design and reuse of the analog front-end chip's constant current source and programmable gain amplifier enable online impedance monitoring and closed-loop compensation without additional circuit overhead. The Gosser algorithm, adaptive smoothing filtering, and improved greedy matching employed are all lightweight algorithms. Combined with incremental dictionary updates and channel correlation reuse optimizations, the computational load is further reduced, enabling the system to possess powerful front-end signal intelligent processing capabilities in a miniaturized, low-power, and low-cost manner, making it highly suitable for practical wearable applications. Attached Figure Description
[0051] Figure 1 This is a system structure block diagram of the present invention.
[0052] Figure 2 This is a schematic diagram of the hardware control logic.
[0053] Figure 3 Build a flowchart for the dictionary.
[0054] Figure 4 This is a flowchart of the present invention. Detailed Implementation
[0055] Exemplary embodiments of the invention will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of the invention are shown in the drawings, it should be understood that the invention may be implemented in various forms and should not be limited to the embodiments set forth herein; rather, these embodiments are provided so that a more thorough understanding of the invention can be achieved and that the full scope of the invention can be conveyed to those skilled in the art.
[0056] In the first aspect, this application proposes a wearable EEG system with contact impedance compensation and inertial sparsity denoising, including a multi-channel EEG signal acquisition and system control module. This module uses an ADS1299 chip as an analog front end, which is responsible for the amplification, filtering and digitization of EEG signals, and the system control and data reading are performed by an STM32F103RCT6 microcontroller via the SPI bus.
[0057] The brain signal capture and command center of this system consists of a dedicated chip (ADS1299) for processing weak electrical signals and a microcomputer (STM32F103RCT6 microcontroller) for overall coordination and computation. The ADS1299 chip is a highly integrated analog front-end with multiple parallel signal processing channels. Each channel contains a programmable gain amplifier, which can adjust the amplification factor according to instructions, amplifying the extremely weak EEG signals acquired from the scalp to a level easily processed by subsequent circuits. Next, the signal passes through a built-in filter that effectively removes high-frequency noise and extremely low-frequency drift unrelated to EEG signals. Finally, a high-precision analog-to-digital converter converts the amplified and purified analog voltage signal into a digital sequence. This conversion process has extremely high resolution, capturing extremely subtle changes in the signal, laying the foundation for subsequent precise analysis.
[0058] The STM32F103RCT6 microcontroller is the core control and scheduling unit of the entire system. It connects and communicates with the ADS1299 chip via a high-speed serial communication bus. The microcontroller sends data read commands to the ADS1299 chip according to a preset rhythm. Upon receiving the command, the ADS1299 immediately packages the converted digital data from all channels and sends it to the microcontroller via the bus. After receiving this raw data, the microcontroller does not directly store or forward it, but immediately initiates a series of background intelligent processing tasks, such as executing impedance compensation and motion artifact removal algorithms, which will be described in detail later. After processing, the cleaner EEG data is sent to the host computer via a wireless module for display and further analysis. Simultaneously, the microcontroller is also responsible for managing the overall system operation, including power management, peripheral coordination, and timing control, ensuring that all components operate smoothly and collaboratively.
[0059] The multi-channel EEG signal acquisition and system control module includes an analog front-end chip and a microcontroller. The analog front-end chip integrates a programmable gain amplifier, an analog-to-digital converter, and a programmable constant current source. It also includes:
[0060] The online contact impedance monitoring and dynamic compensation module is configured to control the programmable constant current source to inject an excitation current with a constant amplitude and a frequency outside the bandwidth of the EEG signal into the electrode pair under test within a preset monitoring period, and to collect the response voltage. The contact impedance value is calculated in real time based on the ratio of the response voltage to the fundamental amplitude of the excitation current, and the corresponding gain compensation amount is found in the pre-calibrated impedance-gain mapping relationship based on the contact impedance value, so as to control the programmable gain amplifier to perform analog domain gain compensation.
[0061] In some embodiments, the online contact impedance monitoring and dynamic compensation module is further configured to:
[0062] When the contact impedance value exceeds the preset reliable contact threshold but does not reach the detachment threshold, the gain compensation amount is applied to the analog gain control terminal of the programmable gain amplifier.
[0063] When the adjustment of the analog gain control terminal has reached its upper limit but the contact impedance value continues to increase, the gain compensation amount is applied to the EEG data in the form of a digital gain coefficient to achieve digital domain compensation.
[0064] In some embodiments, when calculating the contact impedance value, the online contact impedance monitoring and dynamic compensation module uses the Gosser algorithm to extract the amplitude of the collected response voltage at a single frequency point. The target frequency of the Gosser algorithm is set to be consistent with the fundamental frequency of the excitation current.
[0065] The online contact impedance monitoring and dynamic compensation module is implemented through a combination of hardware circuitry and embedded algorithms. Its purpose is to monitor and compensate for signal attenuation caused by dynamic changes in electrode-scalp contact impedance in real time. The implementation process can be broken down into the following four ordered sub-steps:
[0066] Step 1: Periodic excitation injection and signal path switching.
[0067] This step is executed by hardware circuitry. The system's main controller configures the ADS1299 chip via the communication bus, enabling its internal constant current source to operate during preset intervals in the measurement cycle. The constant current source is programmed to generate a square wave current with extremely low amplitude and a fixed frequency. This frequency is selected outside the main EEG frequency band to avoid interfering with the valid EEG signal. Simultaneously, the controller, through an array of analog switches, temporarily switches the signal path of the current electrode channel from the input of a conventional EEG amplifier to the input of a differential measurement amplifier dedicated to measuring the response voltage. This switching action is strictly synchronized with the current injection, ensuring that the excitation current is accurately applied to the target electrode pair. The hardware control logic for this step can be implemented via... Figure 2 The flowchart is shown.
[0068] Step 2: Response signal analysis and impedance calculation.
[0069] This step is the core of the embedded algorithm. The controller reads the digital sequence of response voltages acquired by the ADS1299 during excitation. To accurately extract the amplitude of the response voltage at the same frequency as the excitation current from this sequence, the algorithm does not employ computationally intensive full-frequency domain analysis, but instead uses a digital signal processing method that performs efficient iterative calculations for a single frequency. This method recursively calculates the acquired discrete voltage sequence by pre-setting coefficients related to the target frequency, ultimately outputting the real and imaginary parts of this frequency component in the complex plane. By calculating the magnitude of this complex number, the amplitude of the response voltage can be obtained.
[0070] After obtaining the response voltage amplitude, based on basic circuit principles, the contact impedance of the electrode pair can be calculated in real time by dividing the voltage amplitude by the known fundamental amplitude of the injected current. Since the injected current is a square wave, its fundamental amplitude needs to be adjusted according to the waveform characteristics. This algorithm involves only a few basic calculations and is very suitable for efficient execution on resource-constrained microcontrollers.
[0071] Step 3: Dynamic compensation decision based on lookup table.
[0072] Before leaving the factory, the system undergoes calibration experiments to establish an impedance-gain correction lookup table. This table records the corresponding relationship between the gain compensation coefficients required to maintain a constant signal amplitude under different contact impedance values. The compensation coefficient is defined as the ratio of the signal amplitude under the ideal low impedance state to the signal amplitude under the current impedance state, and its value is approximately inversely proportional to the impedance value. After the controller calculates the real-time impedance, it searches this lookup table to find the two calibration points closest to the impedance value, and calculates the accurate compensation coefficient using a linear interpolation method.
[0073] Depending on the magnitude of the real-time impedance and the system configuration, the controller will make different compensation decisions:
[0074] Analog Gain Adjustment: If the real-time impedance varies within a moderate range and the change is relatively slow, the controller can directly adjust the gain setting of the programmable gain amplifier of the corresponding channel inside the ADS1299 via the communication bus. For example, the amplification factor can be increased from 12x to 24x to directly compensate for signal attenuation at the analog front end.
[0075] Digital gain compensation: For higher frequency or larger impedance fluctuations, or when the analog gain has been adjusted to its upper limit, compensation is performed in the digital domain. The controller multiplies the original digital code value of the channel read by the controller with the calculated software compensation coefficient to obtain the compensated data.
[0076] User Alarm: If the real-time impedance exceeds the preset failure threshold, it indicates a severe problem with electrode contact, and compensation can no longer guarantee signal quality. In this case, the controller will illuminate a dedicated LED indicator to prompt the user to check and readjust the electrode fit.
[0077] Step 4: Compensation Execution and Data Update.
[0078] Based on the decision, the controller executes corresponding communication commands to adjust the analog gain or performs arithmetic operations to complete digital compensation. For channels using digital compensation, the compensated data overwrites the data in the original buffer for subsequent motion artifact removal module processing. The entire monitoring and compensation process is completed within milliseconds, with negligible impact on continuous EEG acquisition.
[0079] The inertial data synchronous acquisition and preprocessing module is configured to synchronously acquire multi-channel EEG data output by the analog front-end chip and acceleration and angular velocity data output by the six-axis inertial measurement unit under the same interrupt source triggering, and perform physical quantity conversion and synthesis on the acceleration and angular velocity data to obtain a motion feature sequence characterizing the intensity and rate of change of head movement.
[0080] In some embodiments, the inertial data synchronous acquisition and preprocessing module acquires the motion feature sequence in the following manner:
[0081] The acceleration data is converted into an acceleration vector, and the angular velocity data is converted into an angular velocity vector;
[0082] Calculate the magnitude of the acceleration vector to obtain the acceleration amplitude;
[0083] Calculate the magnitude of the angular velocity vector to obtain the angular velocity amplitude;
[0084] Calculate the first-order backward difference of the acceleration amplitude and the angular velocity amplitude respectively to obtain the rate of change of acceleration amplitude and the rate of change of angular velocity amplitude;
[0085] The acceleration amplitude, the angular velocity amplitude, the rate of change of the acceleration amplitude, and the rate of change of the angular velocity amplitude are combined into a four-dimensional vector to form the motion feature sequence.
[0086] In some embodiments, the inertial data synchronous acquisition and preprocessing module is further configured to: use an exponentially weighted moving average filter with an adaptively adjustable smoothing factor to smooth each dimension of the four-dimensional vector to obtain a smoothed motion feature sequence; wherein the smoothing factor takes different values depending on whether the absolute value of the difference between the current sample value and the previous smoothed value exceeds a dynamic threshold, the dynamic threshold being proportional to the previous smoothed value and supplemented with a preset absolute constant.
[0087] The inertial data synchronous acquisition and preprocessing module is responsible for accurately and synchronously acquiring motion data and performing characteristic preprocessing on it, laying the data foundation for the subsequent construction of a waveform template library capable of describing complex motion artifact morphologies. Its implementation process can be broken down into the following four ordered sub-steps:
[0088] Step 1: Hardware synchronization triggering and data acquisition.
[0089] To ensure strict temporal alignment between EEG signals and motion data, this module employs a hardware interrupt synchronization mechanism. The main controller is configured with a high-precision timer to generate interrupts at a fixed frequency, set to the sampling rate of the EEG signals. In each timer interrupt service routine, the controller executes the following sequence of atomic operations: First, it reads the latest frame of multi-channel EEG data from the EEG acquisition chip via the communication bus; second, it sends a data read request to the Inertial Measurement Unit (IMU) via another communication bus to obtain the raw values of the three-axis acceleration and three-axis angular velocity at the current moment. This co-triggered, sequential reading method ensures at the hardware level that each frame of EEG data has a temporally corresponding frame of IMU data, eliminating random delays that may be caused by software scheduling.
[0090] Step 2: IMU raw data calibration and physical quantity conversion.
[0091] Raw data read from an IMU typically contains bias and scaling factor errors, requiring real-time calibration to obtain accurate physical quantities. For accelerometers, the conversion process involves subtracting a pre-calibrated bias value from the raw code value and then multiplying it by a pre-calibrated scaling factor to obtain an acceleration vector in units of gravitational acceleration. Similarly, for gyroscopes, the conversion process involves subtracting the bias value from the raw code value and then multiplying it by a scaling factor to obtain an angular velocity vector in degrees per second or radians per second. These calibration parameters are obtained through calibration experiments of the IMU in static and rotating states and stored in the microcontroller's non-volatile memory.
[0092] Step 3: Calculation of motion feature synthesis quantity.
[0093] Using raw six-axis data directly as input for subsequent processing would result in excessive computational complexity. Therefore, this step fuses and compresses the six-dimensional data into a lower-dimensional feature sequence that more comprehensively reflects the intensity and patterns of head movement. We calculate the following two core synthetic quantities:
[0094] Acceleration amplitude: A scalar sequence is obtained by summing the squares of the triaxial accelerations and then taking the square root. This sequence reflects the overall intensity of the linear acceleration of head movements and can capture movements such as nodding, shaking, and swaying while walking.
[0095] Angular velocity amplitude: A scalar sequence is obtained by summing the squares of the three-axis angular velocities and then taking the square root. This sequence reflects the overall intensity of head rotation and is crucial for capturing movements such as rapid head turns.
[0096] To further characterize the dynamic properties of the motion, such as its start, stop, and change of direction, we calculate the difference between these two composite quantities at adjacent time points, i.e., their first derivatives, which are called the rate of change of acceleration amplitude and the rate of change of angular velocity amplitude, respectively. Finally, for each synchronization time point, we obtain a four-dimensional feature vector integrating information on motion intensity and rate of change.
[0097] Step 4: Smoothing and noise reduction of feature sequences.
[0098] IMU data and its derived feature sequences may contain high-frequency electronic noise. To address this, we employ a computationally lightweight, edge-preserving exponentially weighted moving average filter for smoothing. This filter is an infinite impulse response filter, whose current output is a weighted average of the current input and the output from the previous time step. The smoothing factor is a constant between 0 and 1, determining the filter's response speed to new data. A smoothing factor closer to 1 results in a faster response; a factor closer to 0 provides a stronger smoothing effect.
[0099] To address the characteristics of motion artifact signals, we employ an adaptive smoothing factor strategy: calculating the absolute difference between the current sampling point and the previous smoothed output. When this difference exceeds a dynamic threshold, it indicates significant motion, and a larger smoothing factor is used to quickly track signal changes; otherwise, a smaller smoothing factor is used to adequately suppress noise. This adaptive filtering is applied to each of the four feature channels to obtain the smoothed feature sequence, which is the output of this module. This sequence is then sent to the motion interference waveform template library construction module to generate an incomplete dictionary.
[0100] The motion interference waveform template library construction module is configured to extract multiple basic waveform segments from the motion feature sequence, perform multi-scale time translation and frequency band selective filtering based on motion state classification on each basic waveform segment, and merge all processed waveform segments into an overcomplete dictionary;
[0101] In some embodiments, the motion interference waveform template library construction module includes:
[0102] A waveform extraction unit is used to extract multiple basic waveform segments from the motion feature sequence with a preset fixed time window and step size.
[0103] A classification unit is used to calculate the average acceleration amplitude and average angular velocity amplitude of each of the basic waveform segments within the time window, and to classify the basic waveform segments into one of at least three motion state levels based on the relationship between the combination of the two average amplitudes and at least two preset threshold intervals.
[0104] The filter bank includes multiple bandpass filters that correspond one-to-one with the at least three motion state levels, wherein the passband range of the bandpass filters corresponding to different motion state levels is different, and the passband corresponding to the more intense motion state level is wider.
[0105] Each basic waveform segment extracted by the waveform extraction unit is filtered by a bandpass filter corresponding to its motion state level and then included in the overcomplete dictionary.
[0106] In some embodiments, the motion interference waveform template library construction module further includes a time translation unit, which performs translation operations on each filtered waveform segment on the time axis, including at least three types of offsets: advance, no offset, and lag, to generate multiple waveform copies; all of the waveform copies are imported into the overcomplete dictionary.
[0107] The motion interference waveform template library construction module, based on the smoothed four-dimensional motion feature sequence obtained through the aforementioned preprocessing, generates an overcomplete waveform template library with a size much larger than the signal length and capable of covering various potential motion interference forms through a series of systematic operations. This dictionary is crucial for the subsequent sparse decomposition algorithm to accurately separate motion artifacts from complex mixed signals. Its construction process can be decomposed into the following four core sub-steps:
[0108] Step 1: Extraction and normalization of basic waveform segments.
[0109] First, a series of basic waveform segments are extracted non-overlappingly from a continuous, smooth feature sequence using a fixed-length sliding window. Each segment is a matrix, where rows represent time points and columns represent different feature channels. To eliminate the impact of differences in units and numerical ranges between different feature channels on subsequent similarity calculations, each column of each extracted basic segment is standardized. Standardization involves subtracting the mean of the column from each value and then dividing by the standard deviation. After standardization, each feature channel sequence becomes a sequence with a mean of 0 and a standard deviation of 1, ensuring that all features have equal importance when constructing the template.
[0110] Step 2: Multi-scale time translation and waveform copy generation.
[0111] The timing of motion artifacts appearing in EEG signals is not strictly aligned with the motion features captured by the IMU; there may be a slight delay or advance. To cover this temporal uncertainty in the dictionary, we perform multi-scale temporal shifting operations on each standardized base waveform segment. Specifically, we define a set of time offsets, and for each offset, we generate a temporally staggered waveform copy by shifting the data in each column of the base segment. Through this operation, a base segment can generate multiple temporally staggered copies, greatly enriching the dictionary's coverage of temporal phase changes in motion artifacts.
[0112] Step 3: Frequency band selective filtering based on motion state perception.
[0113] While motion artifacts primarily concentrate their energy at low frequencies, different intensities and types of motion can excite interference in different frequency bands. Therefore, this invention employs a frequency-selective filtering strategy based on motion state perception. First, based on the statistical characteristics of acceleration and angular velocity amplitudes in the base segment, a lightweight rule categorizes them into states such as "slow motion," "normal motion," and "rapid motion." Then, a specific bandpass filter parameter is assigned to each state. For example, a filter with an extremely low cutoff frequency is used for the "slow motion" state to emphasize drift; a filter covering typical daily activity frequencies is used for the "normal motion" state; and a filter with a wider passband is used for the "rapid motion" state to preserve rapidly changing components. For each translated waveform copy, the corresponding bandpass filter is applied for filtering based on the motion state of its source segment. This step ensures that the templates in the dictionary not only have a time offset but also spectral characteristics that match the motion intensity, improving the matching accuracy between the templates and real motion artifacts.
[0114] Step 4: Compile and structure the complete dictionary.
[0115] All waveform copies obtained after translation and selective filtering are compiled to form the final overcomplete dictionary. Assuming several basic segments are extracted from the feature sequence, and each segment generates several translated copies, the total number of atoms in the dictionary equals the product of the number of basic segments and the number of copies. Each atom is a matrix, but in subsequent algorithms, it will be vectorized into a column vector. Therefore, the entire dictionary can be represented as a matrix with a number of rows much smaller than the number of columns, satisfying the overcompleteness property. To improve the search efficiency of subsequent algorithms, the dictionary can be grouped according to the motion state of its source segments during storage, forming sub-dictionaries. During the search, the motion state can be roughly determined based on the IMU features corresponding to the current EEG signal frame to be processed, prioritizing the search in the corresponding sub-dictionary, thereby reducing unnecessary computation. The dictionary construction process is as follows: Figure 3 As shown.
[0116] The motion artifact separation and removal module is configured to use the overcomplete dictionary as a sparse representation basis to perform an iterative sparse decomposition algorithm on the EEG data after analog domain gain compensation, estimate the motion artifact components, and obtain the motion artifact-suppressed EEG signal by subtracting the motion artifact components from the EEG data.
[0117] The motion artifact separation and removal module based on sparse decomposition employs an improved iterative greedy matching algorithm. Its core idea is that EEG signals contaminated by motion artifacts can be approximated as a linear combination of a few waveform templates (atoms) in an overcomplete dictionary, while clean EEG signals and random noise cannot be effectively represented by these motion templates, thus appearing as residues after sparse decomposition. The algorithm iteratively searches for the dictionary atoms most relevant to the current signal residue and progressively constructs a motion interference subspace. Finally, it subtracts the projection onto this subspace from the original signal, thereby achieving motion artifact separation and removal.
[0118] Specifically, the single-channel EEG signal segment to be processed is considered as a high-dimensional vector, with its dimension equal to the number of time points. The overcomplete dictionary is a matrix with the number of rows equal to the signal length and the number of columns much greater than the number of rows, where each column is a waveform template atom. The algorithm aims to find a sparse vector with the vast majority of elements being zero, such that the product of the dictionary matrix and this vector (i.e., the weighted sum of the selected minority atoms) approximates the original signal as closely as possible. This approximation result mainly characterizes the motion artifact component. Subtracting the motion artifact component from the original signal yields the clean EEG signal.
[0119] The iterative process of the algorithm is as follows:
[0120] Initialization: Set the original signal to the initial residual signal, set the selected atom set to empty, and set the iteration counter.
[0121] Atom matching: In each iteration, the inner product (i.e., correlation coefficient) between the current residual signal and all atoms in the dictionary is calculated, and the index of the atom with the largest absolute value of the inner product is found. This step aims to find the part of the current residual signal that is most similar to a certain motion template.
[0122] Update index set and atom matrix: Add the selected atom index to the set and add the corresponding atom vector as a new column to the selected atom matrix.
[0123] Coefficient Determination: To ensure that the linear combination of selected atoms best approximates the original signal, a least-squares problem needs to be solved, namely, finding a set of optimal weighting coefficients that minimizes the difference between the weighted sum of the selected atoms and the original signal. This solution can be obtained by solving a system of linear equations.
[0124] Signal Update: Using the currently solved optimal coefficients, calculate the best approximation of the motion artifacts for the currently selected atom pairs. Then, update the residual signal by subtracting the currently reconstructed motion disturbance from the original signal.
[0125] Iteration Termination Judgment: Check if the preset termination conditions are met, such as the number of iterations reaching the upper limit, or the energy of the current residual signal being lower than a preset threshold. If not met, return to step 2 to continue iteration; if met, terminate the iteration.
[0126] Output: After the iteration terminates, the final motion artifact estimate is the weighted sum of the selected atoms, and the clean EEG signal is the final residual signal.
[0127] Secondly, this application proposes a wearable method for acquiring and processing electroencephalogram (EEG) signals, including:
[0128] Simultaneously acquire multi-channel EEG data and motion data from a six-axis inertial measurement unit, and process the motion data to generate motion feature sequences;
[0129] A complete dictionary was constructed from the motion feature sequence;
[0130] During the intervals of EEG data acquisition, current is periodically injected into the electrodes through a constant current source inside the simulated front-end chip to calculate the contact impedance value between the electrodes and the scalp.
[0131] The corresponding gain compensation amount is found in the preset impedance-gain mapping relationship based on the contact impedance value. Analog domain compensation is preferentially performed by adjusting the gain factor of the programmable gain amplifier inside the analog front-end chip. When the analog domain compensation cannot completely offset the signal attenuation, digital domain gain compensation is performed on the EEG data.
[0132] Based on the overcomplete dictionary, iterative sparse decomposition is performed on the gain-compensated EEG data to estimate and remove motion artifacts, and output a clean EEG signal.
[0133] In some embodiments, calculating the contact impedance value of the electrode-scalp specifically includes:
[0134] The constant current source is controlled to generate a square wave excitation current with a specific fundamental frequency outside the frequency band of EEG signals ranging from 0.5Hz to 100Hz.
[0135] The voltage response signal generated on the electrode pair under test under the action of the excitation current is acquired synchronously.
[0136] The Gossel algorithm is applied to the voltage response signal, the iteration coefficients of which are matched with the specific fundamental frequency, to extract the voltage amplitude that corresponds only to the specific fundamental frequency from the voltage response signal;
[0137] The extracted voltage amplitude is divided by the known fundamental current amplitude of the square wave excitation current, and the quotient is the contact impedance value.
[0138] In some embodiments, constructing a complete dictionary from the motion feature sequence specifically includes:
[0139] According to the preset time window length and sliding step size, extract several multidimensional motion feature subsequences from the motion feature sequence;
[0140] Based on the parameters characterizing motion intensity in each segment of the multidimensional motion feature subsequence, they are classified into multiple preset motion state levels;
[0141] For each subsequence after classification, frequency domain shaping is performed using a bandpass filter corresponding to the motion state level;
[0142] For each subsequence after frequency domain shaping, perform at least time axis forward shift, backward shift, and translation without offset operations to generate multiple waveform atoms;
[0143] After all waveforms are atomically vectorized, they are arranged in columns to form the overcomplete dictionary.
[0144] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions in the embodiments of this invention will be clearly and completely described below in conjunction with a specific application scenario and several optional implementation methods. This embodiment details a wearable EEG signal acquisition and processing system and its working method applied to brain-computer interface research in dynamic environments.
[0145] System hardware configuration:
[0146] The system hardware platform in this embodiment mainly includes: an 8-channel EEG simulation front-end based on the ADS1299 chip, which integrates a multi-channel programmable gain amplifier, a 24-bit analog-to-digital converter, and a programmable constant current source; an STM32F103RCT6 microcontroller, which acts as the main controller responsible for system scheduling, data processing, and algorithm execution; a six-axis inertial measurement unit (IMU) for acquiring three-axis acceleration and three-axis angular velocity data, such as the ICM-42688-P; a power management module that provides a stable ±2.5V low-noise power supply with ripple less than 10mVpp; and a flexible electrode cap composed of claw-type silver chloride dry electrodes, supporting flexible 8-channel configuration. After system startup, the main controller first completes initialization, including configuring the system clock to 72MHz, initializing the SPI1 interface (for connecting to the ADS1299) and SPI2 interface (for connecting to the IMU), and configuring the necessary general-purpose input / output pins. Next, the main controller configures the internal registers of the ADS1299 chip via SPI1, writing the following parameters: setting the sampling rate of the 8 channels to 250Hz, setting the initial gain of the programmable gain amplifiers of all channels to 12x, enabling the internal bandpass filter (with cutoff frequencies set to 0.5Hz and 40Hz), and configuring it to continuous conversion mode.
[0147] Implementation Method 1: Impedance Monitoring and Analog / Digital Hybrid Gain Compensation Process.
[0148] This embodiment describes in detail how the system utilizes the programmable constant current source resources on the ADS1299 chip to achieve low-cost, high-precision online impedance monitoring and hybrid compensation without additional circuitry.
[0149] The system is configured to perform impedance monitoring every 10 seconds. At the start of the monitoring cycle, the main controller sends a command register write instruction to the ADS1299 via the SPI1 bus, activating its internal programmable constant current source. This source is configured to generate a square wave with a frequency of 55.5Hz and a peak current of 100nA. 55.5Hz was chosen because it falls within the gap between the system's bandpass filter (0.5-40Hz) and the mains frequency of 50Hz / 60Hz, minimizing interference with the EEG signal. Almost simultaneously, the main controller controls an external analog switch array (e.g., TS5A23159) connected to the electrodes to seamlessly switch the input paths of the current test channel pair (e.g., channel 1 and the reference electrode) from their respective programmable gain amplifier front ends to the input of an external, high-input-impedance differential instrumentation amplifier (e.g., INA333). This differential instrumentation amplifier is set to a gain of 5 and is dedicated to measuring the impedance response voltage. Subsequently, the main controller initiates continuous sampling, reading 256 sampling points (approximately 1 second of data) from the differential instrumentation amplifier at a frequency of 250Hz.
[0150] To accurately extract the 55.5Hz response voltage amplitude from these 256 sampling points, the main controller executes the Gossel algorithm. This algorithm performs single-frequency detection on the input digital sequence, extracting only the amplitude information of the target frequency component without performing a complete spectrum analysis. Its implementation logic is as follows: the algorithm maintains a second-order recursive structure, iteratively updating each input sample using a constant coefficient pre-calculated based on the target frequency and sampling rate. This recursive process constitutes a narrowband bandpass filter with a resonant response to the target frequency. Once all samples have been input, the final state of this recursive structure directly maps to the complex amplitude of the target frequency component, and its magnitude is then calculated as the response voltage amplitude. This process avoids the extensive computation required to calculate the entire spectrum; it only requires a pre-set coefficient corresponding to 55.5Hz for efficient operation. Simultaneously, the fundamental amplitude of the square wave is known, pre-generated and stored in the firmware based on the Fourier series decomposition theory of the square wave waveform. After obtaining the response voltage amplitude, the system uses this value, combined with the fixed gain of the external differential instrumentation amplifier, to calculate the current contact impedance value.
[0151] Assume the calculated contact impedance is 150kΩ. The microcontroller then accesses a two-dimensional impedance-gain lookup table calibrated at the factory using a precision resistor box and written into its internal Flash memory. This lookup table defines the analog and digital gain coefficients corresponding to different impedance ranges. By performing range positioning and interpolation search within this lookup table, the microcontroller determines the gain compensation strategy corresponding to the impedance value. For the value of 150kΩ, the decision logic is as follows: the analog gain has been adjusted to twice the preset upper limit (PGA switching from 12x to 24x), but this analog adjustment is still insufficient to fully compensate for signal attenuation, so additional compensation is needed in the digital domain. The compensation execution unit immediately takes action, first sending a command to the ADS1299 via SPI1 to switch the PGA gain of the corresponding channel from 12x to 24x. Subsequently, in the post-processing flow, the EEG data code value after analog compensation is multiplied by the digital gain coefficient obtained from the lookup table interpolation to obtain the final compensation value. This hybrid compensation mechanism ensures that signal attenuation can still be effectively and losslessly offset when electrode impedance fluctuates significantly.
[0152] As an optional alternative to this implementation, the excitation waveform of the constant current source can be configured as a sine wave instead of a square wave. When configured as a sine wave, the main controller writes a control word to a specific register of the ADS1299 via the SPI bus, enabling the internal sine wave generator and setting the frequency to 55.5Hz. In this case, since the excitation is a pure sine wave, the response voltage can be directly used for impedance calculation without fundamental frequency conversion, making the logic more straightforward. However, in this mode, the power consumption of the internal sine wave generator is slightly higher than in the square wave mode, making it suitable for applications with higher signal-to-noise ratio requirements but less power consumption sensitivity. This embodiment prefers the square wave mode to balance accuracy and power consumption.
[0153] As an alternative to this embodiment, the single-frequency amplitude extraction method for impedance calculation is not limited to the Gossel algorithm. In another embodiment, a sliding window-based Fast Fourier Transform (FFT) can be used, and the spectral lines near 55.5 Hz can be interpolated to obtain more accurate frequency and amplitude estimates. However, since the FFT requires calculating the spectral lines of the entire frequency band, its computational load and memory requirements are much greater than those of the Gossel algorithm for a single frequency point only, which will significantly increase the load and power consumption of the microcontroller. Therefore, this embodiment prefers the Gossel algorithm on resource-constrained microcontrollers, which can be used as a hardware accelerator for peripherals to implement single-point spectrum analysis with very few MIPS.
[0154] Implementation Method 2: Adaptive smoothing of motion features and overcomplete dictionary construction process.
[0155] This implementation focuses on how to extract robust motion features from IMU data and use these features to build a dedicated overcomplete dictionary that is highly adapted to the current wearer's motion pattern.
[0156] First, the system performs synchronous acquisition and preprocessing of IMU data. Within the same 250Hz timer interrupt service routine, the system sequentially reads 8 channels of EEG data from the ADS1299 and 12 bytes of raw data (6 axes, 2 bytes per axis) from the ICM-42688-P. Physical quantity calibration is performed on the raw IMU data, converting the raw analog-to-digital conversion code values into acceleration and angular velocity vectors with physical units. Subsequently, the system performs motion feature synthesis: calculating the magnitude of the acceleration vector as the acceleration amplitude, which directly reflects the linear total intensity of head movement; and calculating the magnitude of the angular velocity vector as the angular velocity amplitude, which reflects the total intensity of head rotation. To further characterize the dynamic changes in motion, the system calculates the changes in these two amplitudes between adjacent sampling points, i.e., their first-order backward difference, obtaining the rate of change of acceleration amplitude and the rate of change of angular velocity amplitude, respectively. Thus, at each synchronous sampling moment, the system obtains a four-dimensional motion feature vector integrating motion intensity and change information.
[0157] To suppress high-frequency electronic noise from the IMU while maintaining a fast response to actual motion, the system employs a novel adaptive smoothing filtering strategy. The core of this strategy is not the use of a fixed smoothing intensity, but rather the dynamic adjustment of the smoothing intensity based on the dynamic changes in the signal itself. For each dimension of the four-dimensional feature, the filter independently maintains a historical smoothed output value. At each new sampling point, the system first determines the magnitude of the change in the current input value relative to the historical smoothed output value. The system presets a dynamic threshold, which is proportional to the historical smoothed output value and supplemented with an absolute constant, to distinguish between "normal noise fluctuations" and "changes caused by actual motion." When the magnitude of the change exceeds the dynamic threshold, the system determines that significant motion has occurred. At this point, the filter automatically switches to a high-response mode, assigning a higher weight to the current input value to achieve close tracking of rapid signal changes. When the magnitude of the change is below the threshold, the system determines that the current state is stable, and the filter automatically switches to a high-suppression mode, assigning a higher weight to the historical smoothed output value to effectively filter out high-frequency random noise. This mechanism enables the smoothed feature sequence to respond quickly to sudden actions such as turning a head or standing up, while also providing excellent noise reduction when stationary or in slow motion.
[0158] Next, the system constructs or updates a complete dictionary online based on the smoothed motion feature sequence. The system uses a circular buffer to retain the motion feature sequence of the most recent 30 seconds. Every second, the system retrieves the data from the most recent 30 seconds and begins constructing the dictionary. First, a fixed time window of 1 second is used, sliding across the 30-second data in 0.5-second steps to extract multiple overlapping basic segments. For each extracted segment, Z-score standardization is performed to ensure that the data distribution of each feature dimension has a mean of 0 and a standard deviation of 1, thus eliminating the influence of dimensional differences on subsequent processing.
[0159] Then, the system classifies the motion state of each standardized segment. The classification is based on the combination of the average acceleration amplitude and the average angular velocity amplitude within the segment window. The system presets three motion state levels, and the classification logic is as follows:
[0160] State 1 (Slow Movement / Stationary): Both means are in the very low range, representing a quiet sitting posture or very slow movement.
[0161] State 2 (normal activity): The two mean values are in the middle range, representing normal daily activities such as turning the head, writing, and walking.
[0162] State 3 (Rapid Movement): At least one average value exceeds the preset high threshold, representing vigorous movements such as shaking the head, jumping, or running.
[0163] The system pre-stores three digital bandpass filter banks, each corresponding to one of the three states. These filters, implemented with preset coefficients, perform frequency domain shaping on the input sequence. The main difference between the filters for different states lies in their passband frequency range: the filter for state one retains extremely low-frequency components, primarily covering baseline drift; the filter for state two covers typical frequency bands of daily activities; and the filter for state three has the widest passband to retain high-frequency interference components introduced by rapid motion. Each standardized segment, based on its corresponding motion state level, is fed into the corresponding filter for processing, ensuring that the generated template possesses spectral characteristics matching the motion intensity.
[0164] As an extension of this implementation, the time-shifting operation has been increased from three to five types: advancing the filtered feature segments by 0.2 seconds, advancing by 0.1 seconds, keeping them unchanged, delaying by 0.1 seconds, and delaying by 0.2 seconds. This operation aims to simulate the slight time alignment deviation that may exist between motion features and EEG artifacts. Each filtered segment and its four time-shifted copies are vectorized into one-dimensional column vectors, and then arranged column-wise to form an overcomplete dictionary for the current time period. This dictionary is a matrix with a column number (number of atoms) much larger than the row number (signal length), and its redundancy provides a rich representation basis for subsequent sparse decomposition.
[0165] Furthermore, the system does not build the entire dictionary from scratch every time. A fixed-size circular atom library is maintained in the microcontroller's memory. When new data arrives in one second, the system generates new atoms only based on the new data (because of the overlapping sliding extraction, only a few atoms corresponding to new fragments need to be generated each time), and injects these new atoms into the atom library, while simultaneously discarding a corresponding number of the oldest atoms according to the "first-in, first-out" principle. This incremental dictionary update mechanism avoids a large number of repetitive periodic calculations, allowing the dictionary to continuously and smoothly adapt to the wearer's constantly changing movement patterns with extremely low computational overhead.
[0166] Implementation Method 3: Iterative sparse decomposition denoising process based on optimization strategy.
[0167] This implementation details the core iterative process of the sparse decomposition denoising algorithm and particularly emphasizes how to reduce computational complexity by optimizing the steps in embedded implementations.
[0168] The algorithm takes a 1-second, gain-compensated EEG signal segment from one channel as the input signal. The core idea is to treat the contaminated EEG signal as a sum of motion artifacts—linear combinations of a few atoms (waveform templates) from an overcomplete dictionary—and a residual signal (clean EEG signal and random noise) that cannot be effectively represented by the dictionary. The algorithm aims to find the sparse atom combination in the dictionary that best approximates the motion artifact component and remove it from the original signal.
[0169] Step 1: Atom Matching and Selection. The algorithm first initializes the residual signal to the original input signal and clears the selected atom set. At the beginning of each iteration, the algorithm calculates the inner product of the current residual signal and each atom in the dictionary. The absolute value of this inner product directly reflects the waveform matching degree between the atom and the current residual signal. To improve the robustness and efficiency of atom selection, this embodiment adopts an improved matching strategy: instead of simply selecting the single atom with the largest absolute value of the inner product, it first finds the top three candidate atoms with the largest absolute values of the inner product. Then, it calculates the coherence between these three candidate atoms and each atom in the current selected atom set, and selects the candidate atom with the smallest average coherence with the selected atom set as the best atom for this iteration. This strategy, when selecting a new atom, additionally considers its difference from the selected atoms, which helps to introduce more new information dimensions in each iteration, avoids selecting highly similar redundant atoms, and thus accelerates the convergence of the algorithm.
[0170] Step 2: Update the selected atom set. Add the best atom index selected in Step 1 to the selected atom index set, and append the atom vector to the right side of the selected atom matrix.
[0171] Step 3: Coefficient Solving and Update. The goal of this step is to find an optimal set of weighting coefficients after determining the selected atom matrices, so that the linear combination of these selected atoms best approximates the original input signal. Mathematically, this is a least-squares problem of solving an overdetermined system of equations. To avoid solving an ever-increasing system of equations from scratch in each iteration, this embodiment adopts a recursive update strategy. The core logic is: after each iteration, the system saves an intermediate calculation result (i.e., the inverse of the autocorrelation matrix) corresponding to the currently selected atom matrix. When a new atom is added, the system does not directly solve the new system of equations, but uses the properties of the block matrix, based on the saved old inverse matrix, combined with the information of the newly added atom, to directly derive the new inverse matrix through a low-dimensional update operation. This method reduces the computational complexity of coefficient solving from being proportional to the cube of the number of iterations to being proportional to the square of the number of iterations, significantly reducing the computational burden on the microcontroller under the constraint of a small number of iterations (e.g., less than 10).
[0172] Step 4: Residual Signal Update. Using the optimal weighting coefficients obtained in Step 3, calculate the weighted sum of all currently selected atoms. This weighted sum is the best estimate of motion artifacts for the current iteration. Subtract this motion artifact estimate from the original input signal to obtain the updated residual signal. This residual signal will be fed into the next iteration to continue searching for possible residual motion artifact components.
[0173] Stopping Criteria and Output. The algorithm terminates iterations based on a dual-condition judgment logic, satisfying either of the following: First, the number of iterations reaches a preset upper limit, set to 8 in this embodiment, to prevent the algorithm from consuming too much time; second, the energy intensity of the current residual signal has decayed to a preset noise floor level, specifically, its root mean square value is lower than a preset percentage (e.g., 1%) of the root mean square value of the original input signal or an absolute voltage threshold (e.g., 0.2μV). This condition indicates that there is no obvious residual motion artifact energy in the residual signal, and continued iteration may introduce noise. After stopping iterations, the final residual signal obtained is the clean EEG signal with motion artifact removal completed.
[0174] As a key optimization of this implementation, to further reduce the total time of the algorithm's serial execution across the eight channels, this invention introduces a channel correlation reuse strategy. Considering that all EEG channels share the same head motion source, motion artifacts, although their amplitude and polarity may differ across channels, exhibit a high correlation in their occurrence time and waveform morphology. Therefore, the algorithm first performs a complete processing flow for the first channel, including iterative search and atom selection, and records the final selected set of atom indices. For the remaining seven channels, the system assumes that their motion artifacts can be represented by the same set of atom indices, thus skipping the most time-consuming atom matching and search steps. It directly uses the atom index set determined by the first channel as the initial set, performing only fast recursive coefficient calculation and residual update. This optimization makes the total time for the system to complete denoising of all eight channels significantly less than eight times the independent processing time of a single channel, greatly improving the system's real-time throughput and ensuring sufficient time for online denoising of all channels at a 250Hz sampling rate.
[0175] After processing all eight channels, the main controller packages the cleaned EEG data via Bluetooth and sends it to the host computer for display and analysis. It then clears the data ready flag, awaiting the next data frame to be ready, and begins a new processing cycle. Through the coordinated operation of these three implementation methods, the system achieves long-term, stable, and high-fidelity recording of EEG signals in dynamic environments.
[0176] Thirdly, this application proposes an electronic device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the method described above.
[0177] Fourthly, this application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the method described above.
[0178] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the units and modules in the above system can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0179] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0180] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this disclosure.
[0181] In the embodiments provided in this disclosure, it should be understood that the disclosed apparatus / computer devices and methods can be implemented in other ways. For example, the apparatus / computer device embodiments described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. Multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces, and the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0182] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0183] Furthermore, the functional units in the various embodiments of this disclosure can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0184] If integrated modules / units are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program may include computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. A computer-readable medium may include: any entity or device capable of carrying computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content included in a computer-readable medium may be appropriately added to or subtracted according to the requirements of legislation and patent practice in a jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media may not include electrical carrier signals and telecommunication signals.
[0185] The above are merely preferred embodiments of the present invention. It should be noted that any modifications and improvements made by those skilled in the art without departing from the present technical solution should also be considered to fall within the scope of protection claimed by the present solution.
Claims
1. A wearable EEG system with contact impedance compensation and inertial sparsity denoising, characterized in that, The system includes a multi-channel EEG signal acquisition and control module, which comprises an analog front-end chip and a microcontroller. The analog front-end chip integrates a programmable gain amplifier, an analog-to-digital converter, and a programmable constant current source. The system is characterized by further comprising: The online contact impedance monitoring and dynamic compensation module is configured to control the programmable constant current source to inject an excitation current with a constant amplitude and a frequency outside the bandwidth of the EEG signal into the electrode pair under test within a preset monitoring period, and to collect the response voltage. The contact impedance value is calculated in real time based on the ratio of the response voltage to the fundamental amplitude of the excitation current, and the corresponding gain compensation amount is found in the pre-calibrated impedance-gain mapping relationship based on the contact impedance value, so as to control the programmable gain amplifier to perform analog domain gain compensation. The inertial data synchronous acquisition and preprocessing module is configured to synchronously acquire multi-channel EEG data output by the analog front-end chip and acceleration and angular velocity data output by the six-axis inertial measurement unit under the same interrupt source triggering, and perform physical quantity conversion and synthesis on the acceleration and angular velocity data to obtain a motion feature sequence characterizing the intensity and rate of change of head movement. The motion interference waveform template library construction module is configured to extract multiple basic waveform segments from the motion feature sequence, perform multi-scale time translation and frequency band selective filtering based on motion state classification on each basic waveform segment, and merge all processed waveform segments into an overcomplete dictionary; The motion artifact separation and removal module is configured to use the overcomplete dictionary as a sparse representation basis to perform an iterative sparse decomposition algorithm on the EEG data after analog domain gain compensation, estimate the motion artifact components, and obtain the motion artifact-suppressed EEG signal by subtracting the motion artifact components from the EEG data.
2. The system according to claim 1, characterized in that: The online contact impedance monitoring and dynamic compensation module is further configured as follows: When the contact impedance value exceeds the preset reliable contact threshold but does not reach the detachment threshold, the gain compensation amount is applied to the analog gain control terminal of the programmable gain amplifier. When the adjustment of the analog gain control terminal has reached its upper limit but the contact impedance value continues to increase, the gain compensation amount is applied to the EEG data in the form of a digital gain coefficient to achieve digital domain compensation.
3. The system according to claim 2, characterized in that: When calculating the contact impedance value, the online contact impedance monitoring and dynamic compensation module uses the Gosser algorithm to extract the amplitude of the collected response voltage at a single frequency point. The target frequency of the Gosser algorithm is set to be consistent with the fundamental frequency of the excitation current.
4. The system according to claim 3, characterized in that: The inertial data synchronous acquisition and preprocessing module acquires the motion feature sequence in the following way: The acceleration data is converted into an acceleration vector, and the angular velocity data is converted into an angular velocity vector; Calculate the magnitude of the acceleration vector to obtain the acceleration amplitude; Calculate the magnitude of the angular velocity vector to obtain the angular velocity amplitude; Calculate the first-order backward difference of the acceleration amplitude and the angular velocity amplitude respectively to obtain the rate of change of acceleration amplitude and the rate of change of angular velocity amplitude; The acceleration amplitude, the angular velocity amplitude, the rate of change of the acceleration amplitude, and the rate of change of the angular velocity amplitude are combined into a four-dimensional vector to form the motion feature sequence.
5. The system according to claim 4, characterized in that: The inertial data synchronous acquisition and preprocessing module is further configured to: use an exponentially weighted moving average filter with an adaptively adjustable smoothing factor to smooth each dimension of the four-dimensional vector to obtain a smoothed motion feature sequence; wherein, the smoothing factor takes different values depending on whether the absolute value of the difference between the current sample value and the previous smoothed value exceeds a dynamic threshold, the dynamic threshold being proportional to the previous smoothed value and supplemented by a preset absolute constant.
6. The system according to claim 5, characterized in that: The motion interference waveform template library construction module includes: A waveform extraction unit is used to extract multiple basic waveform segments from the motion feature sequence with a preset fixed time window and step size. A classification unit is used to calculate the average acceleration amplitude and average angular velocity amplitude of each of the basic waveform segments within the time window, and to classify the basic waveform segments into one of at least three motion state levels based on the relationship between the combination of the two average amplitudes and at least two preset threshold intervals. The filter bank includes multiple bandpass filters that correspond one-to-one with the at least three motion state levels, wherein the passband range of the bandpass filters corresponding to different motion state levels is different, and the passband corresponding to the more intense motion state level is wider. Each basic waveform segment extracted by the waveform extraction unit is filtered by a bandpass filter corresponding to its motion state level and then included in the overcomplete dictionary.
7. The system according to claim 6, characterized in that: The motion interference waveform template library construction module also includes a time translation unit, which performs translation operations on each filtered waveform segment on the time axis, including at least three types of offsets: advance, no offset, and lag, to generate multiple waveform copies; all of the waveform copies are imported into the overcomplete dictionary.
8. A wearable EEG signal acquisition and processing method applied to the system described in any one of claims 1-7, characterized in that, include: Simultaneously acquire multi-channel EEG data and motion data from a six-axis inertial measurement unit, and process the motion data to generate motion feature sequences; A complete dictionary was constructed from the motion feature sequence; During the intervals of EEG data acquisition, current is periodically injected into the electrodes through a constant current source inside the simulated front-end chip to calculate the contact impedance value between the electrodes and the scalp. The corresponding gain compensation amount is found in the preset impedance-gain mapping relationship based on the contact impedance value. Analog domain compensation is preferentially performed by adjusting the gain factor of the programmable gain amplifier inside the analog front-end chip. When the analog domain compensation cannot completely offset the signal attenuation, digital domain gain compensation is performed on the EEG data. Based on the overcomplete dictionary, iterative sparse decomposition is performed on the gain-compensated EEG data to estimate and remove motion artifacts, and output a clean EEG signal.
9. The method according to claim 8, characterized in that: The calculation of the electrode-scalp contact impedance value specifically includes: The constant current source is controlled to generate a square wave excitation current with a specific fundamental frequency outside the frequency band of EEG signals ranging from 0.5Hz to 100Hz. The voltage response signal generated on the electrode pair under test under the action of the excitation current is acquired synchronously. The Gossel algorithm is applied to the voltage response signal, the iteration coefficients of which are matched with the specific fundamental frequency, to extract the voltage amplitude that corresponds only to the specific fundamental frequency from the voltage response signal; The extracted voltage amplitude is divided by the known fundamental current amplitude of the square wave excitation current, and the quotient is the contact impedance value.
10. The method according to claim 9, characterized in that: The construction of a complete dictionary from the motion feature sequence specifically includes: According to the preset time window length and sliding step size, extract several multidimensional motion feature subsequences from the motion feature sequence; Based on the parameters characterizing motion intensity in each segment of the multidimensional motion feature subsequence, they are classified into multiple preset motion state levels; For each subsequence after classification, frequency domain shaping is performed using a bandpass filter corresponding to the motion state level; For each subsequence after frequency domain shaping, perform at least time axis forward shift, backward shift, and translation without offset operations to generate multiple waveform atoms; After all waveforms are atomically vectorized, they are arranged in columns to form the overcomplete dictionary.
Citation Information
Patent Citations
Portable physiological signal multi-mode collecting device
CN109077722A
Wearable emotion perception automatic composition equipment and method based on electroencephalogram signals
CN121300619A
Integrated electroencephalogram acquisition system based on human-computer interaction
CN222285483U