Lock-free annular real-time streaming system applied to electroencephalogram
By designing a lock-free ring real-time flow system, the challenges of existing EEG systems in real-time and response efficiency are solved, flexible data storage and real-time processing are achieved, and the system's real-time and response speed are improved.
Patent Information
- Application Number
- CN202510071836.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-16
- Publication Date
- 2025-03-11
- Estimated Expiration
- 2045-01-16
AI Technical Summary
Existing EEG systems have challenges in real-time, including flaws in data buffering mechanisms and system overhead and response delays caused by excessive use of locks.
A lock-free ring-shaped real-time flow system is designed, including a collection unit, a lock-free ring buffer and a processing unit. Through a lock-free design and ring-shaped array structure, flexible data storage and real-time processing are achieved, reducing system overhead and thread competition.
The system can flexibly adapt to changes in different data volumes, realize real-time data processing and storage, reduce delays, and improve the system's real-time and response speed.
Smart Images

Figure CN119587047A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of brain neurophysiological detection, and in particular relates to a lock-free ring real-time streaming system applied to electroencephalogram (EEG). Background Art
[0002] Electroencephalography (EEG) is an important non-invasive technology used to record the electrical activity of the brain. It is of key significance in neuroscience research, psychology research, and clinical diagnosis of neurological diseases (such as epilepsy detection). By placing electrodes on the scalp, the EEG system can capture and amplify the tiny electrical signals generated by brain cell activity to provide real-time dynamic changes in the brain.
[0003] However, the current EEG system faces many challenges in terms of real-time performance: 1. The data buffering mechanism is defective. The existing EEG signal acquisition system uses a fixed-size buffer and operates in a one-time access mode. This design lacks flexibility and cannot adapt to changes in data flow under different experimental conditions. For example, when signal acquisition is accelerated or experimental conditions change, it is difficult for the buffer to quickly adjust access resources, which can easily lead to data loss or overflow. 2. Fixed-size buffers cannot achieve simultaneous access to multiple objects. During the data access process, a locking mechanism is required to ensure data consistency and integrity. However, the use of locks significantly increases system program overhead. In a multi-threaded environment, it will cause thread contention and waiting, affecting the response speed of the real-time system. Especially in high-load situations where data is frequently updated, too many lock operations may cause delays that exceed the real-time requirements of the system design, thereby reducing the EEG system's ability to respond to rapid dynamic EEG signal changes.
[0004] Therefore, the present invention provides a lock-free ring real-time streaming system applied to electroencephalogram to solve the above technical problems. Summary of the invention
[0005] In view of the above problems, the purpose of the present invention is to provide a lock-free ring-shaped real-time streaming system applied to electroencephalogram, which is flexible enough to adapt to the dynamic changes of data flow, and can effectively reduce system overhead and improve program execution speed and response efficiency.
[0006] The present invention provides a lock-free ring real-time streaming system applied to electroencephalogram, comprising an acquisition unit, a first lock-free ring buffer connected to the acquisition unit, a buffer unit connected to the first lock-free ring buffer, a second lock-free ring buffer connected to the buffer unit, and a processing unit connected to the second lock-free ring buffer;
[0007] The acquisition unit is used to acquire the EEG signal sent by the EEG cap and transmit the EEG signal to the first unlocked circular buffer; and the acquisition unit has the function of adjusting the transmission period length of the EEG signal to the first unlocked circular buffer;
[0008] The first lock-free ring buffer is used to store the EEG signals received from the acquisition unit in a lock-free manner; and the data storage structure of the first lock-free ring buffer is in the form of a ring array;
[0009] The buffer unit is used for performing data preprocessing operations on the EEG signals after reading the EEG signals of a preset length from the first lock-free ring buffer to obtain relevant feature data, and storing, packaging and / or transmitting the feature data to the second lock-free ring buffer;
[0010] The second lock-free ring buffer is used to store the feature data received from the buffer unit in a lock-free manner; and the data storage structure of the second lock-free ring buffer is in the form of a ring array;
[0011] The processing unit is used to suspend the thread after extracting the feature data from the second lock-free ring buffer, and classify the feature data using a deep learning algorithm.
[0012] Preferably, the data preprocessing operation includes an anomaly detection operation and a data feature extraction operation; the anomaly detection operation uses a statistical method to determine whether the EEG signal read from the first lock-free ring buffer is a useless abnormal signal. If it is determined to be an abnormal signal, the EEG signal is discarded; if it is determined to be a normal EEG signal, a subsequent data feature extraction operation is performed.
[0013] Preferably, the data feature extraction operation uses different algorithms to extract EEG signals of preset length for analysis, and after obtaining the analysis results, the feature extraction matrix is adjusted in time according to the analysis results, and feature extraction is performed on the EEG signals determined to be normal based on the adjusted feature extraction matrix to obtain feature data.
[0014] Preferably, the use of statistical methods to determine whether the EEG signal read from the first lock-free circular buffer is a useless abnormal signal specifically includes: a calculation operation, calculating the mean, variance and standard deviation of the EEG signal read from the first lock-free circular buffer to obtain a calculation result; a comparison operation, comparing the calculation result with a preset normal range value, and if it exceeds the preset normal range value, determining that the EEG signal is an abnormal signal.
[0015] Preferably, the acquisition unit, the first lock-free ring buffer, the buffer unit, the second lock-free ring buffer and the processing unit are connected via a specific high-speed communication interface.
[0016] Compared with the related art, the present invention provides a lock-free circular real-time streaming system for electroencephalogram (EEG), comprising an acquisition unit, a first lock-free circular buffer, a buffer unit, a second lock-free circular buffer and a processing unit; the acquisition unit is used to acquire EEG signals; the first lock-free circular buffer is used to store the EEG signals received from the acquisition unit in a lock-free manner; the buffer unit is used to perform data preprocessing operations on the EEG signals read from the first lock-free circular buffer to obtain relevant feature data, and store, package and / or transmit the feature data to the second lock-free circular buffer; the second lock-free circular buffer is used to store the feature data received from the buffer unit in a lock-free manner; the processing unit is used to suspend the thread after extracting the feature data from the second lock-free circular buffer, and classify the feature data using a deep learning algorithm. In the above structure, the first lock-free ring buffer and the second lock-free ring buffer do not need to use locks to achieve data consistency, thereby reducing the complexity and overhead of the program, and allowing continuous data streams to be managed in a loop structure, which can flexibly cope with different data volumes, and can process and store data in real time, reducing delays. At the same time, the first lock-free ring buffer and the second lock-free ring buffer adopt a lock-free design to allow multiple operations to be performed simultaneously, eliminating the bottleneck of thread competition, thereby improving the real-time and response speed of the system; the setting of the buffer unit can perform real-time pre-processing of EEG signal data while transmitting data, so as to perform secondary modifications to the characteristics of different groups of people, so that data pre-processing is more suitable for different individuals. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 It is a structural block diagram of a lock-free ring real-time streaming system applied to electroencephalogram of the present invention;
[0018] Figure 2 It is a schematic diagram of the structure of the first lock-free ring buffer or the second lock-free ring buffer in the present invention. DETAILED DESCRIPTION
[0019] The present invention provides a lock-free ring real-time streaming system applied to electroencephalogram (EEG), aiming to solve the problems of large program overhead, poor applicability and low response efficiency of the existing EEG system.
[0020] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0021] Please see attached Figure 1-2As shown, the present invention provides a lock-free ring real-time streaming system applied to electroencephalogram, comprising an acquisition unit 1, a first lock-free ring buffer 2 connected to the acquisition unit 1, a buffer unit 3 connected to the first lock-free ring buffer 2, a second lock-free ring buffer 4 connected to the buffer unit 3, and a processing unit 5 connected to the second lock-free ring buffer 4;
[0022] The acquisition unit 1 is used to acquire the EEG signal sent by the EEG cap and transmit the EEG signal to the first unlocked ring buffer 2; and the acquisition unit 1 has the function of adjusting the transmission period length of the EEG signal to the first unlocked ring buffer 2;
[0023] The first lock-free ring buffer 2 is used to store the EEG signals received from the acquisition unit 1 in a lock-free manner; and the data storage structure of the first lock-free ring buffer 2 is in the form of a ring array;
[0024] The buffer unit 3 is used for performing data preprocessing operations on the EEG signals after reading the EEG signals of a preset length from the first lock-free ring buffer 2 to obtain relevant feature data, and storing, packaging and / or transmitting the feature data to the second lock-free ring buffer 4;
[0025] The second lock-free ring buffer 4 is used to store the feature data received from the buffer unit 3 in a lock-free manner; and the data storage structure of the second lock-free ring buffer 4 is in the form of a ring array;
[0026] The processing unit 5 is used to suspend the thread after extracting the feature data from the second lock-free ring buffer 4, and classify the feature data using a deep learning algorithm.
[0027] In the above structure, the first lock-free ring buffer 2 and the second lock-free ring buffer 4 do not need to use locks to achieve data consistency, thereby reducing the complexity and overhead of the program, and allowing continuous data streams to be managed in a loop structure, which can flexibly cope with different data volumes, and can process and store data in real time, reducing delays. At the same time, the first lock-free ring buffer 2 and the second lock-free ring buffer 4 adopt a lock-free design to allow multiple operations to be performed simultaneously, eliminating the bottleneck of thread competition, thereby improving the real-time and response speed of the system; the setting of the buffer unit 3 can perform real-time pre-processing of EEG signal data while transmitting data, so as to perform secondary modifications to the characteristics of different groups of people, so that data pre-processing is more suitable for different individuals.
[0028] It should be noted that the first lock-free ring buffer 2 and the second lock-free ring buffer 4 are in the form of a ring array. Through multi-threaded communication and logic design, the buffer unit 3 and the processing unit 5 will not conflict when operating from an array. Therefore, there is no need to add a lock, so that the operations can be performed simultaneously, which greatly improves the concurrency of the operation. At the same time, the access logic is designed to avoid accessing erroneous data, ensure the accuracy of access, and there is almost no delay in the operation, thereby reducing latency.
[0029] In this embodiment, the data preprocessing operation includes an anomaly detection operation and a data feature extraction operation; the anomaly detection operation uses a statistical method to determine whether the EEG signal read from the first lock-free ring buffer 2 is a useless abnormal signal. If it is determined to be an abnormal signal, the EEG signal is discarded; if it is determined to be a normal EEG signal, a subsequent data feature extraction operation is performed; the data feature extraction operation uses different algorithms to extract EEG signals of preset length for analysis, and after the analysis results are obtained, the feature extraction matrix is adjusted in time according to the analysis results, and the feature extraction is performed on the EEG signal determined to be normal based on the adjusted feature extraction matrix to obtain feature data.
[0030] Specifically, the use of statistical methods to determine whether the EEG signal read from the first lock-free circular buffer is a useless abnormal signal specifically includes: a calculation operation, calculating the mean, variance and standard deviation of the EEG signal read from the first lock-free circular buffer 2 to obtain a calculation result; a comparison operation, comparing the calculation result with a preset normal range value, and if it exceeds the preset normal range value, determining that the EEG signal is an abnormal signal.
[0031] In this embodiment, the acquisition unit 1, the first lock-free ring buffer 2, the buffer unit 3, the second lock-free ring buffer 4 and the processing unit 5 are connected via a specific high-speed communication interface. The high-speed communication interface has data encryption, error checking and flow control functions to ensure safe, accurate and stable data transmission.
[0032] Compared with the related art, the present invention provides a lock-free circular real-time streaming system for electroencephalogram (EEG), comprising an acquisition unit, a first lock-free circular buffer, a buffer unit, a second lock-free circular buffer and a processing unit; the acquisition unit is used to acquire EEG signals; the first lock-free circular buffer is used to store the EEG signals received from the acquisition unit in a lock-free manner; the buffer unit is used to perform data preprocessing operations on the EEG signals read from the first lock-free circular buffer to obtain relevant feature data, and store, package and / or transmit the feature data to the second lock-free circular buffer; the second lock-free circular buffer is used to store the feature data received from the buffer unit in a lock-free manner; the processing unit is used to suspend the thread after extracting the feature data from the second lock-free circular buffer, and classify the feature data using a deep learning algorithm. In the above structure, the first lock-free ring buffer and the second lock-free ring buffer do not need to use locks to achieve data consistency, thereby reducing the complexity and overhead of the program, and allowing continuous data streams to be managed in a loop structure, which can flexibly cope with different data volumes, and can process and store data in real time, reducing delays. At the same time, the first lock-free ring buffer and the second lock-free ring buffer adopt a lock-free design to allow multiple operations to be performed simultaneously, eliminating the bottleneck of thread competition, thereby improving the real-time and response speed of the system; the setting of the buffer unit can perform real-time pre-processing of EEG signal data while transmitting data, so as to perform secondary modifications to the characteristics of different groups of people, so that data pre-processing is more suitable for different individuals.
[0033] The above-described embodiments should be understood as illustrative rather than limiting the scope of protection of the present invention, which is subject to the claims. For those skilled in the art, some non-essential improvements and adjustments made to the present invention still fall within the scope of protection of the present invention without departing from the essence and scope of the present invention.
Claims
1. A lock-free ring real-time streaming system for electroencephalogram, characterized in that: The system comprises a collection unit, a first lock-free ring buffer connected to the collection unit, a buffer unit connected to the first lock-free ring buffer, a second lock-free ring buffer connected to the buffer unit, and a processing unit connected to the second lock-free ring buffer; The acquisition unit is used to acquire the EEG signal sent by the EEG cap and transmit the EEG signal to the first unlocked circular buffer; and the acquisition unit has the function of adjusting the transmission period length of the EEG signal to the first unlocked circular buffer; The first lock-free ring buffer is used to store the EEG signals received from the acquisition unit in a lock-free manner; and the data storage structure of the first lock-free ring buffer is in the form of a ring array; The buffer unit is used for performing data preprocessing operations on the EEG signals after reading the EEG signals of a preset length from the first lock-free ring buffer to obtain relevant feature data, and storing, packaging and / or transmitting the feature data to the second lock-free ring buffer; The second lock-free ring buffer is used to store the feature data received from the buffer unit in a lock-free manner; and the data storage structure of the second lock-free ring buffer is in the form of a ring array; The processing unit is used to suspend the thread after extracting the feature data from the second lock-free ring buffer, and classify the feature data using a deep learning algorithm.
2. A lock-free ring-shaped real-time streaming system for electroencephalogram according to claim 1, characterized in that: The data preprocessing operation includes an anomaly detection operation and a data feature extraction operation; the anomaly detection operation uses a statistical method to determine whether the EEG signal read from the first lock-free ring buffer is a useless abnormal signal. If it is determined to be an abnormal signal, the EEG signal is discarded; if it is determined to be a normal EEG signal, a subsequent data feature extraction operation is performed.
3. A lock-free ring-shaped real-time streaming system for electroencephalogram according to claim 1, characterized in that: The data feature extraction operation uses different algorithms to extract EEG signals of preset length for analysis. After the analysis results are obtained, the feature extraction matrix is adjusted in time according to the analysis results, and the features of the EEG signals determined to be normal are extracted based on the adjusted feature extraction matrix to obtain feature data.
4. A lock-free ring-shaped real-time streaming system for electroencephalogram according to claim 3, characterized in that: The statistical method is used to determine whether the EEG signal read from the first unlocked circular buffer is a useless abnormal signal, specifically including: a calculation operation, calculating the mean, variance and standard deviation of the EEG signal read from the first unlocked circular buffer to obtain a calculation result; a comparison operation, comparing the calculation result with a preset normal range value, and if it exceeds the preset normal range value, determining that the EEG signal is an abnormal signal.
5. The lock-free loop real-time streaming system for electroencephalogram according to claim 1, characterized in that: The acquisition unit, the first lock-free ring buffer, the buffer unit, the second lock-free ring buffer and the processing unit are connected via a specific high-speed communication interface.
Citation Information
Patent Citations
Base station user plane data processing and optimizing method based on Linux system
CN103391256A
Communication method of symbiotic virtual machine based on multi-core lockless ring buffer area
CN106790599A
Personalized model with regular integration of data
CN107092771A
Financial anti-fraud real-time judgment method
CN111209299A
Data processing method and device, and electronic equipment
CN114090275A