Real-time brain topography
Through sliding time window and multi-threaded high concurrency technology, real-time dynamic display of EEG topographic maps is achieved, solving the problem of difficult real-time brain energy activity representation in the existing technology, and improving the real-time and efficiency of scientific research and clinical applications.
Patent Information
- Application Number
- CN202311419912.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-30
- Publication Date
- 2025-05-02
AI Technical Summary
The existing technology is difficult to realize real-time representation and visualization of real-time energy activities of the human brain, which limits the real-time and efficiency of scientific research and clinical applications.
Using sliding time window and multi-threaded high concurrency technology, an EEG data reception module, an EEG signal processing module and a drawing module are designed to realize the real-time dynamic display of the EEG terrain map.
Real-time and rapid feedback on energy changes in different areas of the brain is achieved, the efficiency and accuracy of scientific research and clinical applications are improved, and the value of electroencephalograms in clinical applications is expanded.
Smart Images

Figure CN119919528A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of brain-computer interface technology, and specifically to a technology for real-time representation and visualization of the recent activity energy of the human brain. Background Art
[0002] The brain is the central organ of the human nervous system and is responsible for generating signals to control our bodies. It consists of three main parts: the cerebrum, cerebellum, and brainstem. The brain can be further divided into five different areas: the frontal, parietal, temporal, occipital, and motor cortices, each with a unique function. For example, the frontal lobe is located at the front of the brain and is primarily responsible for planning and problem solving. The occipital lobe is located at the back of the brain and is responsible for processing visual information. The temporal lobes are located on both sides of the brain and are involved in auditory signal recognition, memory, and language. The parietal lobe is located in front of the occipital lobe and is involved in functions such as perception, sensation, arithmetic, and spelling. Finally, the motor cortex is located between the frontal and parietal lobes and is responsible for controlling body movement.
[0003] Electroencephalography (EEG) is a method of measuring the brain's electrical signals by placing small electrodes on the scalp and recording the tiny voltage fluctuations generated by ionic currents within the brain's neurons. EEG topography (EEG topomap) is a neuroimaging technique that visualizes EEG signals spatially. EEG data is collected through electrodes and converted into an EEG topomap to present the voltage or power amplitude of the original EEG signal.
[0004] EEG maps are currently mainly used in scientific research, and usually require data processing after the experiment is completed before they can be generated. This method limits the real-time and rapid feedback on the energy changes in the subjects' brains. To solve this problem, we used sliding time windows and multi-threaded high concurrency technology to achieve real-time dynamic display of EEG maps. The application of this technology not only enables researchers to conveniently, intuitively and quickly understand the energy changes in different areas of the subjects' brains at continuous moments, but can also be widely used in clinical treatment and evaluation. In scientific research, researchers can more conveniently record the complete changes in brain activity in the experiment, thereby increasing the interpretability of research results. In clinical practice, this technology enables doctors to monitor and evaluate patients' brain activity more intuitively. This is very helpful for the diagnosis and treatment of many neurological diseases. By observing EEG maps in real time, doctors can better understand the patient's brain function status and make corresponding interventions and adjust treatment plans as needed.
[0005] In general, the real-time dynamic display of EEG maps through sliding time windows and multi-threaded high-concurrency technology not only provides researchers with more convenient tools, but also greatly expands the value of EEG maps in clinical applications. This technology brings more information, interpretability and practicality, which helps to promote the improvement of research and diagnosis and treatment in related fields. Summary of the invention
[0006] Based on the above problems, this study proposes a method for displaying real-time EEG maps using sliding time windows and multi-threaded concurrent technology. The method includes three main modules: an EEG data receiving module, a drawing module, and an EEG map sending module. These modules receive and draw the real-time transmitted EEG data and send the drawn EEG map in real time through multi-threaded concurrent technology. The purpose of the present invention is achieved through the following technical solutions:
[0007] Based on the above problems, this study proposes a method for displaying real-time EEG topography using sliding time windows and multi-threaded concurrent technology. The method includes three main modules: EEG data receiving module, EEG signal processing module, and drawing module. These modules receive, analyze, and draw real-time transmitted EEG data through multi-threaded concurrent technology, and send the drawn EEG topography in real time. The purpose of the present invention is achieved through the following technical solutions:
[0008] 1) EEG data receiving module: The EEG data receiving module receives the original EEG signal from the data receiving thread. During the receiving process, the module parses the incoming data packet and extracts information such as the subject number, experimental process mark and experimental task type mark, and the 16-channel EEG of the current sampling point. Once the real-time data reception reaches the set time window length, the module will intercept the EEG of the latest 500 sampling points from the received data, that is, remove the EEG of the earliest 50 sampling points, and then store the information related to the specific subject in a new dictionary, where the id of the new dictionary is incremented according to the global variable, and directly loops from 0 to 99. In addition, in order to achieve continuous data processing, the sliding time window will repeat the data interception and storage operations when new data is incoming according to the preset time interval.
[0009] 2) EEG signal processing module: When the EEG data in the data dictionary in step 1) is passed into the drawing function, the original EEG data needs to be notch filtered and bandpass filtered first, and the electrode channel information of the EEG topographic map needs to be created. Then the EEG data needs to be fast Fourier transformed and the power spectrum density of 8-30Hz needs to be calculated.
[0010] 3) Drawing module: After calculating the power spectral density, we obtained the power spectral density value of each electrode. Next, in order to generate a continuous EEG topography, we created a high-density two-dimensional grid on the scalp surface, which contains multiple virtual reference points. These reference points need to be processed by an interpolation algorithm. For each point on the high-density two-dimensional grid, we used spherical interpolation for interpolation calculation. The process of the algorithm is as follows:
[0011] For each point on a high-density two-dimensional grid, the interpolation algorithm module has the following flow:
[0012] First, the coordinates of the electrodes and grid points are projected onto a reference sphere. Subsequently, the spherical distance between each grid point and all 16 electrodes on the sphere is calculated, and based on the spherical distance, the power spectral density value at each grid point is calculated using the spherical interpolation method. The interpolation algorithm takes into account the positions of all electrode points and their corresponding power spectral density values to ensure that the interpolation result can reflect the spatial distribution of electrode data on the scalp surface. Finally, we obtain the power spectral density value of each point on the high-density two-dimensional grid, forming a continuous EEG topography. According to the size of the power spectral density value, the EEG topography will be rendered, and the area with lower power spectral density values will be displayed in blue, while the area with higher power spectral density values will be displayed in red, so that the spatial distribution of EEG activity can be intuitively displayed. Finally, the EEG topography will be encoded as a base64 string and returned for further use and storage. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] Figure 1 It is a framework diagram of a method for implementing real-time EEG topography;
[0014] Figure 2 Flowchart of EEG signal processing module;
[0015] Figure 3 Flowchart of EEG signal processing module; DETAILED DESCRIPTION
[0016] The present invention will be further described below with reference to specific embodiments, but the present invention is not limited to these embodiments.
[0017] The present invention encompasses any substitution, modification, equivalent method and scheme made on the essence and scope of the present invention. In order to make the public have a thorough understanding of the present invention, specific details are described in detail in the following preferred embodiments of the present invention, and those skilled in the art can fully understand the present invention without the description of these details.
[0018] like Figure 1 As shown, the implementation of the real-time EEG topography method of the present invention includes the following steps:
[0019] 1) The present invention adopts the rabbitMQ queue communication mode to realize the real-time EEG topographic map method. In order to ensure the smooth implementation of the method, it is first necessary to set the parameters such as the rabbitMQ connection and channel between the data receiving thread and the server. Secondly, in order to ensure effective data transmission, we declare that the queue name for receiving messages from the server rabbitMQ is eeg_data_queue_topomap, specify the queue name to be monitored in the connection channel as eeg_data_queue_topomap, and define the callback function of the data receiving thread so that when receiving a new raw EEG data packet, it can process and parse the data in time, ensuring the reliability and efficiency of data transmission. The thread receives continuous raw data from the server through continuous wake-up operations, and uses the raw EEG data receiving module to classify and store these data. For different patients, tasks and events, the module effectively stores the data according to a specific classification method. This thread is in an uninterrupted loop and runs independently of the drawing thread. By adjusting the length of the sliding window in the raw EEG data receiving module, a seamless connection with the drawing thread is achieved. Specifically, data is accumulated by continuously calling this thread, and drawing operations are performed after the accumulation reaches a certain condition. By placing the drawing operation in another thread, the process of blocking data reception during the drawing process can be avoided. When the data receiving thread receives new data, it can process the data immediately without waiting for the drawing operation to complete. This ensures continuous data processing and does not cause data loss or accumulation due to delays in drawing operations.
[0020] 2) Every time the server transmits new raw EEG data to the eeg_data_queue_topomap queue, the callback function is triggered to perform specific operations. The callback function parses the received raw EEG data packet and extracts information related to the subject number, experimental process tag, and experimental task type tag. When the data reception reaches the preset time window length, the module will intercept the information related to the specific subject from the received data and store it in the data dictionary corresponding to the corresponding subject. It is worth noting that in order to avoid potential problems when multiple threads access the data dictionary at the same time, we adopted an innovative method. After meeting the data length requirements, the data is assigned to the dynamic data dictionary, where the dictionary name index value is continuously cycled from 0 to 100, thereby effectively solving possible multi-thread conflicts.
[0021] 3) When the data receiving thread generates a new dynamic data dictionary, the drawing thread in the loop detection state will detect the generation of the dictionary. In order to avoid occupying the global function variables for too long, the drawing thread will create a temporary drawing array to receive the values in the data dictionary. By temporarily storing the data in the temporary drawing array, the continuous occupation of the global function variables can be effectively avoided. This design ensures the timely processing and transmission of data, and maintains the efficiency and reliability of the program while realizing the function.
[0022] 4) After the temporary drawing array is passed to the drawing module, a 50Hz notch filter is first performed to remove the mains interference, and a Butterworth 1-30Hz bandpass filter is performed to remove noise. Next, the original EEG data of the 16 channels are Fourier transformed and the power spectral density is calculated, and the average power of each frequency band is calculated. When drawing the topographic map, the power spectral density of the remaining channels is calculated based on the channel information and the average power data, combined with the spherical interpolation method. The power value is mapped to the color space to generate an image data representing the topographic map. Next, a corresponding number of contour lines are drawn on the image, and the color corresponding to each power value is identified using the specified color bar. Finally, the drawn topological map is stored as a string in base64 format. In this process, a variety of signal processing algorithms and image processing techniques are used to effectively realize the visualization of the data and ensure the accuracy and readability of the results.
[0023] 5) After getting the string representing the topographic map, the drawing thread needs to make several settings to ensure that the connection and channel between the message and the server can operate normally. In addition, the message body format needs to be prepared, and the name of the queue to be sent is set to "results_queue_topomap", which needs to be monitored by the server in real time. Once the brain topographic map in base64 format is returned, it can be sent to the front end for display.
[0024] The sampling rate of the collected EEG data is 250Hz, and the total length of each fixed time window is 500 sampling points. The length of the sliding window is 50 sampling points. This design ensures that 5 EEG maps of size 3*3 inches are generated within 1 second. The real-time change effect is achieved through the continuous opening operation of the server. This setting can timely display the dynamic changes of EEG signals, which helps researchers or doctors to monitor and analyze EEG activities in real time. At the same time, it ensures the timeliness and accuracy of the generated maps, providing reliable data support for subsequent research and diagnosis.
[0025] The above only describes the preferred embodiments of the present invention, but it should not be understood as limiting the claims. The present invention is not limited to the above embodiments, and its specific structure is allowed to be changed. In short, all changes made within the protection scope of the independent claims of the present invention are within the protection scope of the present invention.
Claims
1. A method for drawing a real-time brain topography map, characterized in that: The method comprises the following steps: S1: RabbitMQ queue communication is used to realize the sending and receiving of data in the real-time EEG topography method, and data transmission is carried out through the connection between the data receiving thread and the server. S2: Every time the server transmits new raw EEG data, it triggers the callback function in the data receiving thread to process and parse the data. Each time, 16*1 EEG data will be stored to the maximum window + sliding window size. It is stored in a dynamically named data dictionary, which will be continuously generated and deleted after drawing to prevent it from taking up too much space. S3: After the dynamically named data dictionary is passed into the EEG signal processing module, the EEG signal processing module will detect the generation of a new data dictionary and create a temporary EEG drawing array for data processing. If no new data dictionary is generated, the drawing thread will wait until a new dictionary is generated before processing the EEG data. S4: After the EEG data enters the EEG analysis module, it first undergoes notch filtering and bandpass filtering, then undergoes Fourier transform and power spectral density calculation, and calculates the average power of each frequency band. S5: In the drawing module, based on the channel information and average power data, a high-density two-dimensional grid is created on the scalp surface, which contains multiple virtual reference points. These reference points need to be processed by the interpolation algorithm. For each point on the high-density two-dimensional grid, we use the spherical interpolation method for interpolation calculation. For each point on the high-density two-dimensional grid, the process of the interpolation algorithm module is as follows: First, the coordinates of the electrodes and grid points are projected onto a reference sphere. Subsequently, the spherical distance between each grid point and all 16 electrodes on the spherical surface is calculated, and based on the spherical distance, the power spectral density value at each grid point is calculated using the spherical interpolation method. The interpolation algorithm takes into account the position of all electrode points and their corresponding power spectral density values to ensure that the interpolation result can reflect the spatial distribution of electrode data on the scalp surface. Finally, we obtained the power spectral density value of each point on the high-density two-dimensional grid, forming a continuous EEG topography map. S6: After obtaining the base64 string representing the topographic map, the message body is set in the information sending function in the drawing thread and the result is transmitted to the front end for real-time display.
2. A real-time brain topography method according to claim 1, characterized in that: In step S1, RabbitMQ queue communication is used to realize the sending and receiving of data in the real-time EEG topography method. The server and the host subscribe to each other's queues to achieve high-precision, low-latency message push.
3. A real-time brain topography method according to claim 1 or 2, characterized in that: In step S2, a collection method combining a fixed time window and a sliding time window is adopted in the data accumulation process to ensure the real-time reception of the latest EEG data.
4. A real-time brain topography method according to claim 1 or 2, characterized in that: In step S2, after the new EEG data is accumulated and intercepted, a dictionary is dynamically named in the form of globals()[f'a_{global_id}'] to store the new EEG data dictionary.
5. A real-time brain topography method according to claims 1-3, characterized in that: In step S3, the drawing thread always uses the try...except method for detection. If a new dynamic dictionary is passed in, the data analysis module and the drawing module in the try are triggered.
6. A real-time brain topography method according to claims 1-4, characterized in that: In step S4, a 50 Hz Chebyshev notch filter and a 1-30 Hz Butterworth bandpass filter are used for filtering to complete data preprocessing.
7. A real-time brain topography method according to claims 1-5, characterized in that: In step S4, short-time Fourier transform is used to convert the EEG signal into time-frequency domain, and the average power spectrum density value of each frequency band is calculated.
8. A real-time brain topography method according to claims 1-6, characterized in that: In step S5, the spherical interpolation method is used to draw the processed EEG raw data. In the interpolation algorithm, a high-density two-dimensional network point is established, and the positions of all electrode points and their corresponding power spectrum density values are calculated, and then rendered according to the value size, low energy is displayed in blue, and high energy is displayed in red.
9. A real-time brain topography method according to claims 1-7, characterized in that: In step S6, the generated brain topography map is converted into a base64 string and transmitted to the server in real time to complete the real-time display.