Electroencephalogram signal processing method, device and equipment and storage medium
By performing baseline removal and splicing on EEG signals through sliding windowing, the problem of poor EEG signal quality was solved, the signal display quality was improved, and the accuracy of decoding analysis was enhanced.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-22
- Publication Date
- 2026-03-27
AI Technical Summary
The raw EEG signals acquired by existing EEG acquisition equipment are of poor quality, which affects the effectiveness of subsequent decoding and analysis.
By performing sliding window processing on multi-channel EEG signals, baseline removal is performed, and the baseline-removed signals are spliced together to remove problems such as signal drift, zero bias, and tomography.
It improves the display quality of EEG signals, reduces the impact of baseline drift on decoding analysis, and improves the accuracy of analysis results.
Smart Images

Figure CN115633971B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of signal processing, and in particular to an electroencephalogram signal processing method, device, equipment and storage medium. BACKGROUND
[0002] In recent years, people's research on electroencephalogram signals is increasingly in-depth, and electroencephalogram signal analysis technology is gradually applied in many fields such as disease diagnosis, brain-computer interface, mental state monitoring, etc. Electroencephalogram signal acquisition plays a key role as a preliminary step in electroencephalogram signal decoding analysis. However, the raw electroencephalogram signals collected by the current electroencephalogram acquisition device generally have poor quality, which affects the subsequent decoding analysis of the electroencephalogram signals. SUMMARY
[0003] The present application provides an electroencephalogram signal processing method, device, equipment and storage medium to solve the defects that the electroencephalogram signals collected by the current electroencephalogram acquisition device have poor quality, which affects the subsequent decoding analysis of the electroencephalogram signals.
[0004] The present application provides an electroencephalogram signal processing method, comprising:
[0005] Obtaining raw electroencephalogram signals of multiple channels;
[0006] Performing sliding window processing on the raw electroencephalogram signals in a target channel, and performing baseline removal processing on the raw electroencephalogram signals in the window obtained by the sliding window processing to obtain a first electroencephalogram signal; the target channel is any channel of the multiple channels;
[0007] Performing splicing processing on the first electroencephalogram signal to obtain a target electroencephalogram signal.
[0008] According to the electroencephalogram signal processing method provided by the present application, the step of performing baseline removal processing on the raw electroencephalogram signals in the window obtained by the sliding window processing to obtain a first electroencephalogram signal comprises:
[0009] Calculating the mean value of the raw electroencephalogram signals in the window obtained by the sliding window processing to obtain a first sub-signal;
[0010] Determining a first weight vector according to the window width of the sliding window processing; the number of elements of the first weight vector is the same as the window width of the sliding window processing;
[0011] Performing weighted processing on the raw electroencephalogram signals in the window based on the first weight vector to obtain a second sub-signal;
[0012] Determining an intermediate variable according to the first sub-signal and the second sub-signal;
[0013] determine a local fitting curve according to the first weight vector and the intermediate variable, and perform baseline removal on the original electroencephalogram signal in the window based on the local fitting curve to obtain a first electroencephalogram signal.
[0014] According to the electroencephalogram signal processing method provided by the application, the intermediate variable comprises a first variable and a second variable; the step of determining a local fitting curve according to the first weight vector and the intermediate variable comprises:
[0015] determine a second weight vector according to the first weight vector; the second weight vector has the same number of elements as the first weight vector;
[0016] determine a local fitting curve according to the second weight vector, the first weight vector and the intermediate variable;
[0017] the local fitting curve yfit=wt*(w1*a+b);
[0018] wherein a=y2-y1, b=y2-(a*window+1) / 2;
[0019] yfit is a local fitting curve; wt is a second weight vector; w1 is a first weight vector; a is a first variable in the intermediate variable, and b is a second variable in the intermediate variable; window is a window width of sliding window processing; y1 is a first sub-signal, and y2 is a second sub-signal.
[0020] According to the electroencephalogram signal processing method provided by the application, the step of performing baseline removal on the original electroencephalogram signal in the window based on the local fitting curve to obtain a first electroencephalogram signal comprises:
[0021] obtain a normalization vector;
[0022] superimpose each element in the second weight vector with a corresponding element in the normalization vector, and update the element in the normalization vector;
[0023] perform normalization processing on the local fitting curve based on the updated normalization vector to obtain a target fitting curve;
[0024] subtract the target fitting curve from the original electroencephalogram signal in the window to perform baseline removal on the original electroencephalogram signal in the window to obtain a first electroencephalogram signal.
[0025] According to a method for processing electroencephalogram (EEG) signals provided by the present invention, the first EEG signal includes at least a first target signal and a second target signal; the first target signal and the second target signal are obtained by removing the baseline of the original EEG signals in adjacent windows during sliding window processing; the step of splicing the first EEG signal to obtain the target EEG signal includes:
[0026] A first target sub-signal is generated by extracting a first preset number of elements from the latter part of the first target signal;
[0027] A second preset number of elements are extracted from the latter part of the second target signal to generate a second target sub-signal;
[0028] The first target sub-signal and the second target sub-signal are spliced together to obtain the target EEG signal; the target EEG signal, the first target signal, and the second target signal have the same number of elements.
[0029] According to a brainwave signal processing method provided by the present invention, the step of splicing the first target sub-signal and the second target sub-signal to obtain a target brainwave signal includes:
[0030] Determine the tail element of the first target sub-signal and the first element of the second target sub-signal;
[0031] Calculate the target mean of the tail element and the first element, and determine the first target variable corresponding to the first target sub-signal and the second target variable corresponding to the second target sub-signal based on the target mean;
[0032] Based on the first target variable, determine the first target weight vector corresponding to the first target sub-signal and the second target weight vector corresponding to the second target sub-signal;
[0033] Based on the first target weight vector and the second target weight vector, the first target sub-signal and the second target sub-signal are weighted and spliced to obtain the target EEG signal.
[0034] According to a method for processing electroencephalogram (EEG) signals provided by the present invention, the step of performing sliding window processing on the raw EEG signals in the target channel includes:
[0035] Create a cache queue corresponding to the target channel, and cache the raw EEG signals in the target channel into the cache queue;
[0036] Obtain preset sliding window parameters; the sliding window parameters include window width and sliding length;
[0037] When the length of the buffered raw electroencephalogram signals in the buffer queue reaches a preset length, the raw electroencephalogram signals buffered in the buffer queue are subjected to a sliding window processing according to the sliding window parameters; wherein the window width is less than or equal to the preset length; and the sliding length is less than the window width.
[0038] The application further provides an electroencephalogram signal processing device, comprising:
[0039] a signal acquisition module configured to acquire raw electroencephalogram signals of multiple channels;
[0040] a signal processing module configured to perform a sliding window processing on the raw electroencephalogram signals in a target channel, and perform a baseline removal processing on the raw electroencephalogram signals in the window obtained through the sliding window processing to obtain a first electroencephalogram signal; the target channel is any one of the multiple channels;
[0041] a signal splicing module configured to perform a splicing processing on the first electroencephalogram signal to obtain a target electroencephalogram signal.
[0042] The application further provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the electroencephalogram signal processing method according to any one of the above-mentioned methods when executing the program.
[0043] The application further provides a non-transitory computer readable storage medium having a computer program stored thereon, wherein the computer program is executable by a processor to implement the electroencephalogram signal processing method according to any one of the above-mentioned methods.
[0044] The application further provides a computer program product comprising a computer program, wherein the computer program is executable by a processor to implement the electroencephalogram signal processing method according to any one of the above-mentioned methods.
[0045] The electroencephalogram signal processing method, device, equipment and storage medium provided by the application can remove signal drift, zero offset, and fault layer in the raw electroencephalogram signals by performing a sliding window processing on the raw electroencephalogram signals in multiple channels, performing a baseline removal processing on the raw electroencephalogram signals in the window, and splicing the electroencephalogram signals after the baseline removal processing. BRIEF DESCRIPTION OF DRAWINGS
[0046] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0047] Figure 1 This is one of the flowcharts of the electroencephalogram (EEG) signal processing method provided by the present invention;
[0048] Figure 2 This is the second flowchart of the EEG signal processing method provided by the present invention;
[0049] Figure 3 This is a schematic diagram of the electroencephalogram signal processing device provided by the present invention;
[0050] Figure 4 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation
[0051] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0052] The following is combined Figures 1-2 The present invention describes the electroencephalogram (EEG) signal processing method.
[0053] The EEG signal processing method provided by this invention is applied to EEG acquisition devices, particularly first-generation EEG acquisition devices, to process the raw EEG signals acquired by the device to improve the quality of the raw EEG signals and facilitate subsequent decoding and analysis. Specifically, refer to... Figure 1 , Figure 1 This is one of the flowcharts illustrating the electroencephalogram (EEG) signal processing method provided in this embodiment of the invention, based on... Figure 1 The electroencephalogram (EEG) signal processing method provided in this embodiment of the invention includes:
[0054] Step 100: Acquire raw EEG signals from multiple channels;
[0055] In this embodiment, when processing the EEG signal, the raw EEG signal from multiple channels is first acquired. This raw EEG signal is a brainwave signal acquired by the EEG device acquisition instrument at a specific sampling rate.
[0056] In step 200, the original brain electrical signals in a target channel are subjected to sliding window processing, and the original brain electrical signals in the window obtained through the sliding window processing are subjected to baseline removal processing to obtain first brain electrical signals; the target channel is any channel in the plurality of channels.
[0057] Based on the sliding window segmentation processing, the original brain electrical signals in the plurality of channels are subjected to independent component analysis to obtain the first brain electrical signals. When the original brain electrical signals in the plurality of channels are subjected to independent component analysis, any channel in the plurality of channels is taken as a target channel, the original brain electrical signals in the target channel are subjected to sliding window processing, and the original brain electrical signals in the window obtained through the sliding window processing are subjected to baseline removal processing to obtain the first brain electrical signals.
[0058] In step 300, the first brain electrical signals are subjected to splicing processing to obtain target brain electrical signals.
[0059] The first brain electrical signals are subjected to splicing processing, that is, the original brain electrical signals in different windows obtained through the sliding window processing are subjected to baseline removal processing to obtain the first brain electrical signals, and the brain electrical signals subjected to baseline removal processing corresponding to adjacent windows are subjected to splicing processing to obtain the target brain electrical signals. The target brain electrical signals are displayed in a brain electrical device acquisition instrument, which can improve the display quality of the brain electrical signals and facilitate subsequent decoding and analysis of the brain electrical signals. When the first brain electrical signals are subjected to splicing processing, the brain electrical signals subjected to baseline removal processing in the current window can be spliced with the brain electrical signals subjected to baseline removal processing in the previous window after the window is slid once, or the brain electrical signals subjected to baseline removal processing in any adjacent windows can be uniformly subjected to splicing processing after the window sliding is completed, which is not limited herein.
[0060] Further, in step 200, the original brain electrical signals in the target channel are subjected to sliding window processing, specifically including:
[0061] In step 201, a cache queue corresponding to the target channel is created, and the original brain electrical signals in the target channel are cached in the cache queue.
[0062] In step 202, preset sliding window parameters are obtained; the sliding window parameters include a window width and a sliding length.
[0063] In step 203, when the original brain electrical signals cached in the cache queue reach a preset length, the original brain electrical signals cached in the cache queue are subjected to sliding window processing according to the sliding window parameters; the window width is less than or equal to the preset length; and the sliding length is less than the window width.
[0064] For the raw electroencephalogram signals collected by the electroencephalograph, the raw electroencephalogram signals are buffered through a buffer queue, and the sliding window processing is performed based on the buffer queue. Specifically, a buffer queue corresponding to a target channel is created, and the raw electroencephalogram signals in the target channel are buffered into the buffer queue. In this embodiment, the target channel is any one of the plurality of channels, and the buffer queue corresponding to the target channel is created, that is, the buffer queue corresponding to each channel is created, and the raw electroencephalogram signals of the same channel are buffered into the same buffer queue. For example, if the electroencephalograph collects raw electroencephalogram signals of N channels, N buffer queues are created to correspond to the N channels.
[0065] It should be noted that the buffer queue follows the first-in first-out principle. When the raw electroencephalogram signals in the target channel are processed by the sliding window, the preset sliding window parameters are first obtained, and the sliding window parameters include the window width and the sliding length. When the length of the raw electroencephalogram signals buffered in the buffer queue reaches the preset length L, the raw electroencephalogram signals buffered in the buffer queue are processed by the sliding window according to the sliding window parameters. It should be noted that the window width during the sliding window processing is less than or equal to the length L of the raw electroencephalogram signals buffered in the buffer queue. Since the signal processing mode such as filtering or baseline removal is performed on a group of time series signals rather than a single frame signal, a certain amount of data needs to be buffered through the buffer queue before processing. When the length of the raw electroencephalogram signals buffered in the buffer queue reaches the preset length L, the raw electroencephalogram signals in the buffer queue are processed by the sliding window, and the raw electroencephalogram signals in the window obtained by the sliding window processing are processed by the baseline removal. Then, according to the sliding length M, M data of the raw electroencephalogram signals in the window are updated, for example, the first M data of the raw electroencephalogram signals in the window are deleted in the buffer queue, and M new data are added, so as to realize the sliding of the window. The sliding length M of the window during the sliding window processing is less than the window width.
[0066] In the sliding window processing, the processing can be performed in a fixed window or sliding window manner, which can be set according to the length of the cache queue and actual needs, and is not specifically limited here. The fixed window manner is more suitable for the case where the cache queue is short, and the window is fixed and does not move. After the baseline processing of the data in the previous window, the sliding window effect is realized by updating the cached original electroencephalogram signals in the cache queue. That is, after processing the data in the previous window, the newly collected original electroencephalogram signals are cached at the tail of the cache queue, and the same number of data at the head of the queue are deleted. When the updated data reaches the set value (i.e., the sliding length of the sliding window processing), the data in the window is calculated again, so that the window is fixed and does not move, and the cache queue slides with a fixed step (i.e., the sliding length of the sliding window processing), and finally the sliding window effect is realized. For the sliding window manner, it is suitable for the case where the cache queue is long. Unlike the fixed window, in the sliding window manner, the cache queue is fixed and does not move, and the sliding window slides with a fixed step (i.e., the sliding length of the sliding window processing). The original electroencephalogram signals in the window are baseline processed each time the window slides, thereby realizing the sliding window effect.
[0067] Further, in step 200, the original electroencephalogram signals in the window are baseline processed, specifically including:
[0068] Step 204, calculating the mean value of the original electroencephalogram signals in the window obtained by the sliding window processing to obtain a first sub-signal;
[0069] Step 205, determining a first weight vector according to the window width of the sliding window processing; the number of elements of the first weight vector is the same as the window width of the sliding window processing;
[0070] Step 206, performing weighted processing on the original electroencephalogram signals in the window based on the first weight vector to obtain a second sub-signal;
[0071] Step 207, determining an intermediate variable according to the first sub-signal and the second sub-signal;
[0072] Step 208, determining a local fitting curve according to the first weight vector and the intermediate variable, and performing baseline processing on the original electroencephalogram signals in the window based on the local fitting curve to obtain a first electroencephalogram signal.
[0073] In the baseline processing of the original brain electrical signal in the window, first, the mean value of the original brain electrical signal in the window is calculated to obtain a first sub-signal, denoted as y1; a first weight vector w1 is determined according to the window width window of the sliding window processing, wherein the number of elements of w1 is the same as the window width of the sliding window processing, and the element value in w1 is (xi-window) / window, xi is an element in a number sequence composed of the window width window, for example, [1, 2, 3, …, window]. The original brain electrical signal in the window is weighted based on the first weight vector w1 to obtain a second sub-signal, denoted as y2; the weighting processing specifically includes multiplying the original brain electrical signal in the window by the first weight vector w1 and then dividing by the window width window. The intermediate variable is determined according to the first sub-signal y1 and the second sub-signal y2, and the local fitting curve is determined according to the first weight vector w1 and the intermediate variable; the original brain electrical signal in the window is de-baselined based on the local fitting curve to remove the baseline drift, zero bias and fault layer of the original brain electrical signal in the window, and a first brain electrical signal is obtained.
[0074] Further, the intermediate variable includes a first variable a and a second variable b, and in step 209, the local fitting curve is determined according to the first weight vector w1 and the intermediate variable, specifically including:
[0075] In step 2081, a second weight vector is determined according to the first weight vector; the number of elements of the second weight vector is the same as that of the first weight vector;
[0076] In step 2082, a local fitting curve is determined according to the second weight vector, the first weight vector and the intermediate variable;
[0077] In step 2083, the local fitting curve yfit=wt*(w1*a+b);
[0078] Wherein, a=y2-y1, b=y2-(a*window+1) / 2;
[0079] yfit is the local fitting curve; wt is the second weight vector; w1 is the first weight vector; a is the first variable in the intermediate variable, and b is the second variable in the intermediate variable; window is the window width in the sliding window parameter; y1 is the first sub-signal, and y2 is the second sub-signal.
[0080] The second weight vector wt is determined according to the first weight vector w1, the number of elements of the second weight vector wt is the same as that of the first weight vector w1, and the element value of wt is determined according to the element value of w1, specifically, the element value of wt is (1-ki| 2 ) 2, ki is the element value in w1. According to the first weight vector w1, the second weight vector wt and the intermediate variable, the local fitting curve is determined, which is yfit = wt * (w1 * a + b). Wherein, a = y2 - y1, b = y2 - (a * window + 1) / 2; yfit is the local fitting curve; a is the first variable in the intermediate variable, and b is the second variable in the intermediate variable; window is the window width of the sliding window processing; y1 is the first sub-signal, and y2 is the second sub-signal.
[0081] Further, in step 208, the original electroencephalogram signal in the window is processed based on the local fitting curve to obtain the first electroencephalogram signal, which can also include:
[0082] Step 2084, obtaining a normalization vector;
[0083] Step 2085, superimposing each element in the second weight vector with the corresponding element in the normalization vector, and updating the elements in the normalization vector;
[0084] Step 2086, based on the updated normalization vector, the local fitting curve is normalized to obtain a target fitting curve;
[0085] Step 2087, subtracting the target fitting curve from the original electroencephalogram signal in the window to process the original electroencephalogram signal in the window to obtain the first electroencephalogram signal.
[0086] A normalization vector norm is obtained, the length of the normalization vector is the same as the length of the original electroencephalogram signal in the target channel, that is, the number of elements of the normalization vector is the same as the length of the original electroencephalogram signal cached in the cache queue; each element in the second weight vector wt is superimposed with the corresponding element in the normalization vector norm, and the elements in the normalization vector are updated; based on the updated normalization vector, the local fitting curve is normalized, that is, all elements greater than zero in the local fitting curve are divided by the corresponding element value in the normalization vector norm to obtain a target fitting curve; finally, the original electroencephalogram signal in the window is subtracted from the target fitting curve, that is, the first electroencephalogram signal after the baseline drift is removed. Wherein, when the elements in the normalization vector are updated, the corresponding elements in norm are updated once the window is slid, that is, the elements corresponding to the current window in norm are superimposed with the weight vector wt until the window sliding processing is completed.
[0087] For the first electroencephalogram signal obtained by baseline processing, at least comprising a first target signal and a second target signal, the first target signal and the second target signal are obtained by baseline processing on the original electroencephalogram signal in adjacent windows in the sliding window processing; in step 300, when the first electroencephalogram signal obtained by baseline processing is spliced, specifically comprising:
[0088] Step 301, a first preset number of elements are taken from the rear of the first target signal to generate a first target sub-signal;
[0089] Step 302, a second preset number of elements are taken from the rear of the second target signal to generate a second target sub-signal;
[0090] Step 303, the first target sub-signal and the second target sub-signal are spliced to obtain a target electroencephalogram signal; the target electroencephalogram signal, the first target signal and the second target signal have the same number of elements.
[0091] For the first electroencephalogram signal obtained by baseline processing, a first target sub-signal is generated by taking a first preset length of elements from the rear of the first target signal therein, and a second target sub-signal is generated by taking a second preset length of elements from the rear of the second target signal therein; the first target sub-signal and the second target sub-signal are spliced to obtain a target electroencephalogram signal. Wherein, the signal length of the target electroencephalogram signal, the first target signal and the second target signal is the same as the signal length L of the original electroencephalogram signal in the target channel which is processed by sliding window, the first preset length and the second preset length can be the same or different, which is not limited here.
[0092] Preferably, assuming that the first preset length and the second preset length are the same, the last M data of the first target signal and the second target signal corresponding to the adjacent two windows are taken to form the first target sub-signal and the second target sub-signal, M is a positive integer greater than 0, and the value of M is half of the window width; the last M data of the first target signal is taken to generate the first target sub-signal, denoted as M1; the last M data of the second target signal is taken to generate the second target sub-signal, denoted as M2; M1 and M2 are spliced, and any adjacent window in the electroencephalogram signal obtained by baseline processing is spliced in this way to obtain a target electroencephalogram signal, which has the same length L as the original electroencephalogram signal processed by sliding window.
[0093] Further, in step 303, the first target sub-signal and the second target sub-signal are spliced to obtain a target electroencephalogram signal, specifically comprising:
[0094] Step 3031, the tail element of the first target sub-signal and the head element of the second target sub-signal are determined;
[0095] Step 3032, calculating the target mean of the tail element and the head element, and determining the first target variable corresponding to the first target sub-signal and the second target variable corresponding to the second target sub-signal according to the target mean;
[0096] Step 3033, determining the first target weight vector corresponding to the first target sub-signal and the second target weight vector corresponding to the second target sub-signal according to the first target variable;
[0097] Step 3034, performing weighted processing on the first target sub-signal according to the first target weight vector, and performing weighted splicing processing on the second target sub-signal according to the second target weight vector, to obtain a target electroencephalogram signal.
[0098] In the splicing processing of M1 and M2, first, the tail element M1_end of M1 and the head element M2_start of M2 are taken, the target mean of the tail element M1_end of M1 and the head element M2_start of M2 is calculated, and is denoted as m_avg. The first target variable m1_temp corresponding to the first target sub-signal M1 and the second target variable m2_temp of the second target sub-signal M2 are determined according to the target mean, wherein m1_temp=m_avg / M1_end, that is, the first target variable m1_temp is the ratio of the target mean to the tail element of the first target sub-signal M1; m2_temp=m_avg / M2_start, that is, the second target variable m2_temp is the ratio of the target mean to the head element of the second target sub-signal M2. The first target weight vector corresponding to M1 is determined according to the first target variable, and similarly, the second target weight vector corresponding to M2 is determined according to the second target variable. Both target weight vectors m1_w and m2_w are arithmetic sequences. Specifically, the first target weight vector m1_w=[1, 2, …, m1_temp], and m2_w=[m2_temp, …, 2, 1]. M1 and M2 are weighted and spliced to obtain a target electroencephalogram signal according to m1_w and m2_w. In the weighted splicing processing, m1_w acts on the last K elements of M1, and m2_w acts on the last K elements of M2, and K is a positive integer not greater than M.
[0099] In this way, the same processing is performed on the original electroencephalogram signal in each channel to obtain N channel spliced results with a length of 2M.
[0100] In the embodiment, by performing sliding window processing on the original brain electrical signals in multiple channels, and performing baseline removal processing on the original brain electrical signals in the window, and splicing the brain electrical signals after baseline removal processing, the signal drift, zero bias, fault, etc. in the original brain electrical signals can be removed. By performing baseline removal processing on the original brain electrical signals in multiple channels in a sliding window manner, the display quality of the original brain electrical signals is improved. When the processed brain electrical signals are used for visual display in the fields of disease diagnosis, brain-computer interface, mental state monitoring, etc., the influence of baseline drift on brain electrical signal decoding analysis can be reduced, which helps to improve the accuracy of decoding analysis results.
[0101] Further, the independent component analysis method can also be used to remove artifacts from the original data of the brain electrical signals in multiple channels, realize one-to-one correspondence between input and output, and ensure the consistency of input and output of the brain electrical signals in the processing process.
[0102] Referring to Figure 2 Another flowchart of the brain electrical signal processing method is shown in FIG. 6. In one embodiment, the original data of the brain electrical signals in multiple channels collected by the brain electrical device collector is cached in a cache queue. Based on the original data of the brain electrical signals cached in the same cache queue, sliding window segmentation processing is performed, and in the sliding window processing, the original data in the window is subjected to baseline removal processing. The data after baseline removal processing in adjacent windows is spliced to obtain the single-frame calculation results of each channel after baseline removal processing. The following will be described in detail in combination with Figure 2 The brain electrical signal processing method provided by the application will be described in detail.
[0103] First, the original data of the brain electrical signals in multiple channels collected by the brain electrical device collector at a sampling rate of 1K is obtained. Since the filtering or baseline removal and other signal processing methods are performed on a group of time series signals rather than a single frame of signal, a certain amount of data needs to be cached before processing. When caching data, N FIFO (first in first out) cache queues corresponding to each channel are created (N is the number of brain electrical channels). The original data of the brain electrical signals in the same channel is cached in the same cache queue, and the original data of the brain electrical signals in different channels is cached in different cache queues.
[0104] When the amount of data cached in the queue reaches a set value L (in Figure 2In the method, the set value L is the same as the window width of the sliding window processing, and the original data of the electroencephalogram signal in the cache queue is processed based on the sliding window segmentation processing. The calculation result is also an N-dimensional array with a length of L. It should be noted that the original data of the electroencephalogram signal of each channel is synchronously collected, and thus, the original data of the electroencephalogram signal of each channel can be synchronously processed. For the calculation result of the first signal processing, the last M data are taken and saved in a temporary variable M1. At this time, M1 contains M filtered data of N channels, and the value of M is half of L.
[0105] Then, the original data of the newly collected electroencephalogram signal is transmitted to the end of the FIFO queue, and the first data of the FIFO queue is deleted until the FIFO queue is updated by M data. The original data of the electroencephalogram signal is calculated again to obtain the calculation result of the N-dimensional array with a length of L. Similarly, the last M data of the calculation result are taken and saved in a temporary variable M2. The first calculation result is denoted as M1, and the second calculation result is denoted as M2. In order to better splice the adjacent two calculation results together, the adjacent two calculation results M1 and M2 are processed as follows:
[0106] The last element M1_end in M1 and the first element M2_start in M2 are taken, the average of M1_end and M2_start is calculated, and the average is denoted as m_avg. According to the average, the intermediate variables m1_temp = m_avg / M1_end and m2_temp = m_avg / M2_start are calculated. The weight vectors m1_w and m2_w are set for M1 and M2, respectively, and the weight vectors act on the last k elements of M1 and the first k elements of M2, respectively (K is a positive integer less than M). The weight vectors are an arithmetic sequence, and m1_w = [1, 2,..., m1_temp] and m2_w = [m2_temp,..., 2, 1]. M1 and M2 are updated based on the weight vectors. Specifically, the last k elements in M1 are multiplied by m1_2, and the first k elements in M2 are multiplied by m2_w. Finally, M1 and M2 are spliced to obtain the spliced result of N channels with a length of 2M. The internal key parameters L, M, and k are generally as follows: L can be twice the sampling rate, M is half of L, and k can be set according to experience, for example, 100.
[0107] The electroencephalogram filtering result data of the multiple channels can also be removed by the independent component analysis method and cached. The above steps are repeated until there is no new original data to be calculated, so that one-to-one correspondence between the input and the output is realized.
[0108] Further, the raw data of the brain electrical signal in the window in the sliding window processing is processed, specifically, the raw data of the one-dimensional brain electrical signal with the length of L is processed by baseline drift removal, band pass filtering and band stop filtering, and the one-dimensional filtering result with the length of L is returned. For example, the band pass can be set to 0.5-70 Hz, and the band stop can be set to 45-55 Hz, so as to remove high and low frequency noise and power frequency and noise near the power frequency. The brain electrical signal processing method provided by the embodiment of the application provides a baseline removal processing method, which can effectively remove signal drift, zero offset and fault layer and the like in the low-cost brain electrical signal acquisition device.
[0109] Specifically, the brain electrical signal to be removed from the baseline is processed by sliding window segmentation, and the sliding window parameters are set, including the window width size window and the step size, i.e. the sliding length stepsize. When the length of the raw brain electrical signal cached in the cache queue reaches L, the raw brain electrical signal is processed by sliding window, the sliding length of the sliding window processing is M, and the sliding window processing is performed based on the raw brain electrical signal data with the length of L cached in the cache queue, and the sliding number of the window is (L-window) / stepsize. Figure 2 In the embodiment, the window width window is equal to L. A normalization vector norm is further set, and the length of the normalization vector norm is the length L of the raw brain electrical signal. The raw data of the brain electrical signal in the window is processed by baseline removal at each sliding window: that is, the mean value of the raw data of the brain electrical signal in the window is calculated and recorded as y1; the raw data of the brain electrical signal in the window is processed by weighting with the weight vector w1, each element of the raw data in the window is multiplied by the corresponding element of the weight vector, and then divided by the window width window, and recorded as y2; wherein the number of elements of the weight vector w1 is the same as the window width window, and the element value is (xi-window) / window, xi is an element in the sequence [1, 2, 3... window]. The intermediate variables a and b are calculated according to y1 and y2, wherein a=y1-y2; b=y2-(a*window+1) / 2; the local fitting curve is determined according to the weight vector w1 and the intermediate variables a and b, and the local fitting curve is yfit=wt*(w1*a+b). Wherein, wt is another weight vector with the same length as the window width window, and the element value is (1-|ki| 2 ) 2, ki is the element value in w1. After each window sliding, the original data of the electroencephalogram signal in the window is subjected to baseline removal processing, and norm is updated at the same time. The updating manner is to superimpose the element corresponding to the current window in the norm element and the element in the wt vector. Repeat the above steps until the window sliding is completed. For the locally fitted curve yfit, all elements greater than zero are divided by the corresponding elements in the updated norm vector to perform normalization processing. Finally, the original signal is subtracted from the yfit curve after normalization processing, that is, the baseline drift removal processing of the original data of the electroencephalogram signal is completed, and Figure 2 M1 and M2 in M1 and M2 are spliced in the above manner, and the target electroencephalogram signal after baseline processing of each channel can be obtained.
[0110] In the embodiment, the original data of the electroencephalogram signal collected by the multi-channel is subjected to baseline processing in a sliding window manner, which improves the display quality of the electroencephalogram signal for visual display. When applied to the fields of disease diagnosis, brain-computer interface and mental state monitoring, the accuracy of decoding and analysis of the electroencephalogram signal can be improved.
[0111] The electroencephalogram signal processing device provided by the application is described below. The electroencephalogram signal processing device described below can be referred to the electroencephalogram signal processing method described above.
[0112] Referring to Figure 3 , the electroencephalogram signal processing device provided by the embodiment of the application comprises:
[0113] The signal acquisition module 10 is configured to acquire original electroencephalogram signals of multiple channels.
[0114] The signal processing module 20 is configured to perform sliding window processing on the original electroencephalogram signal in the target channel, and perform baseline removal processing on the original electroencephalogram signal in the window obtained by the sliding window processing to obtain a first electroencephalogram signal. The target channel is any channel in the multiple channels.
[0115] The signal splicing module 30 is configured to perform splicing processing on the first electroencephalogram signal to obtain a target electroencephalogram signal.
[0116] In one embodiment, the signal processing module 20 is further configured to:
[0117] Calculate the mean value of the original electroencephalogram signal in the window obtained by the sliding window processing to obtain a first sub-signal.
[0118] Determine a first weight vector according to the window width of the sliding window processing. The number of elements of the first weight vector is the same as the window width of the sliding window processing.
[0119] weighting the raw electroencephalogram signals in the window based on the first weight vector to obtain a second sub-signal;
[0120] determining an intermediate variable according to the first sub-signal and the second sub-signal;
[0121] determining a local fitting curve according to the first weight vector and the intermediate variable, and performing baseline removal on the raw electroencephalogram signals in the window based on the local fitting curve to obtain a first electroencephalogram signal.
[0122] In one embodiment, the intermediate variable includes a first variable and a second variable; and the signal processing module 20 is further configured to:
[0123] determining a second weight vector according to the first weight vector; the second weight vector has the same number of elements as the first weight vector;
[0124] determining a local fitting curve according to the second weight vector, the first weight vector and the intermediate variable;
[0125] the local fitting curve yfit=wt*(w1*a+b);
[0126] wherein a=y2-y1, b=y2-(a*window+1) / 2;
[0127] yfit is a local fitting curve; wt is a second weight vector; w1 is a first weight vector; a is a first variable in the intermediate variable, and b is a second variable in the intermediate variable; window is a window width of the sliding window processing; y1 is a first sub-signal, and y2 is a second sub-signal.
[0128] In one embodiment, the signal processing module 20 is further configured to:
[0129] obtaining a normalization vector;
[0130] superimposing each element in the second weight vector with a corresponding element in the normalization vector to update the element in the normalization vector;
[0131] performing normalization processing on the local fitting curve based on the updated normalization vector to obtain a target fitting curve;
[0132] subtracting the target fitting curve from the raw electroencephalogram signals in the window to perform baseline removal on the raw electroencephalogram signals in the window to obtain a first electroencephalogram signal.
[0133] In one embodiment, the first brain electrical signal at least includes a first target signal and a second target signal; the first target signal and the second target signal are obtained by performing baseline removal on the original brain electrical signal in adjacent windows in the sliding window processing; the signal splicing module 30 is further configured to:
[0134] cutting a first preset number of elements from the rear part of the first target signal to generate a first target sub-signal;
[0135] cutting a second preset number of elements from the rear part of the second target signal to generate a second target sub-signal;
[0136] splicing the first target sub-signal and the second target sub-signal to obtain a target brain electrical signal; the target brain electrical signal, the first target signal and the second target signal have the same number of elements.
[0137] In one embodiment, the signal splicing module 30 is further configured to:
[0138] determining a tail element of the first target sub-signal and a head element of the second target sub-signal;
[0139] calculating a target mean value of the tail element and the head element, and determining a first target variable corresponding to the first target sub-signal and a second target variable corresponding to the second target sub-signal according to the target mean value;
[0140] determining a first target weight vector corresponding to the first target sub-signal and a second target weight vector corresponding to the second target sub-signal according to the first target variable;
[0141] performing weighted splicing processing on the first target sub-signal and the second target sub-signal according to the first target weight vector and the second target weight vector to obtain a target brain electrical signal.
[0142] In one embodiment, the signal processing module 20 is further configured to:
[0143] creating a cache queue corresponding to a target channel, and caching the original brain electrical signal in the target channel into the cache queue;
[0144] obtaining a preset sliding window parameter; the sliding window parameter includes a window width and a sliding length;
[0145] when the length of the original brain electrical signal cached in the cache queue reaches a preset length, performing sliding window processing on the original brain electrical signal cached in the cache queue according to the sliding window parameter; the window width is less than or equal to the preset length, and the sliding length is less than the window width.
[0146] Figure 4An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 4 As shown, the electronic device may include: a processor 410, a communications interface 420, a memory 430, and a communication bus 440, wherein the processor 410, the communications interface 420, and the memory 430 communicate with each other via the communication bus 440. The processor 410 can call logical instructions in the memory 430 to execute an EEG signal processing method, which includes:
[0147] Acquire raw EEG signals from multiple channels;
[0148] The raw EEG signal in the target channel is subjected to sliding window processing, and the raw EEG signal within the window obtained by sliding window processing is subjected to baseline removal processing to obtain the first EEG signal; the target channel is any one of the multiple channels;
[0149] The first EEG signal is spliced to obtain the target EEG signal.
[0150] Furthermore, the logical instructions in the aforementioned memory 430 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, essentially, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0151] On the other hand, the present invention also provides a computer program product, the computer program product comprising a computer program that can be stored on a non-transitory computer-readable storage medium, wherein when the computer program is executed by a processor, the computer is able to execute the electroencephalogram (EEG) signal processing method provided by the above methods, the method comprising:
[0152] Acquire raw EEG signals from multiple channels;
[0153] The original brain electrical signals in a target channel are subjected to sliding window processing, and the original brain electrical signals in the window obtained through the sliding window processing are subjected to baseline removal processing to obtain first brain electrical signals; the target channel is any channel in the plurality of channels;
[0154] The first brain electrical signals are subjected to splicing processing to obtain target brain electrical signals.
[0155] In another aspect, the present application also provides a non-transitory computer readable storage medium having a computer program stored thereon, the computer program being executed by a processor to implement the brain electrical signal processing method provided by the above method, the method comprising:
[0156] Obtaining original brain electrical signals of a plurality of channels;
[0157] The original brain electrical signals in a target channel are subjected to sliding window processing, and the original brain electrical signals in the window obtained through the sliding window processing are subjected to baseline removal processing to obtain first brain electrical signals; the target channel is any channel in the plurality of channels;
[0158] The first brain electrical signals are subjected to splicing processing to obtain target brain electrical signals.
[0159] The device embodiments described above are only schematic, wherein the units shown as separate components can or can not be physically separate, and the components shown as units can or can not be physical units, i.e., can be located in one place, or can be distributed on multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the present embodiment. Those skilled in the art can understand and implement without creative labor.
[0160] From the above description of the embodiments, those skilled in the art can clearly understand that the embodiments can be realized by means of software plus necessary universal hardware platforms, and of course can also be realized by hardware. Based on such understanding, the above technical solutions, essentially or in other words, the part that contributes to the prior art can be embodied in the form of a software product, which can be stored in a computer readable storage medium, such as a ROM / RAM, a magnetic disk, an optical disk, etc., and includes a number of instructions to make a computer device (which can be a personal computer, a server, or a network device, etc.) execute the methods described in each embodiment or some parts of the embodiments.
[0161] It should be pointed out finally that the above embodiments are only used to illustrate the technical solutions of the present application, but not to limit the same; and although the present application has been described in detail with reference to the foregoing embodiments, it should be appreciated by those skilled in the art that the technical solutions recorded in the foregoing embodiments can be modified, or some technical features thereof can be replaced equivalently; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A method for processing electroencephalogram (EEG) signals, characterized in that, The electroencephalogram (EEG) signal processing method includes the following steps: Acquire raw EEG signals from multiple channels; The raw EEG signal in the target channel is subjected to sliding window processing, and the raw EEG signal within the window obtained by sliding window processing is subjected to baseline removal processing to obtain the first EEG signal; the target channel is any one of the multiple channels; The first EEG signal is spliced to obtain the target EEG signal; The first EEG signal includes at least a first target signal and a second target signal; the first target signal and the second target signal are obtained by removing the baseline of the original EEG signals in adjacent windows during the sliding window process; the step of splicing the first EEG signal to obtain the target EEG signal includes: A first target sub-signal is generated by extracting a first preset number of elements from the latter part of the first target signal; A second preset number of elements are extracted from the latter part of the second target signal to generate a second target sub-signal; The first target sub-signal and the second target sub-signal are spliced together to obtain the target EEG signal; the target EEG signal, the first target signal, and the second target signal have the same number of elements.
2. The EEG signal processing method according to claim 1, characterized in that, The step of performing baseline removal processing on the original EEG signal within the window obtained by sliding window processing to obtain the first EEG signal includes: The mean of the original EEG signal within the window obtained by sliding window processing is calculated to obtain the first sub-signal; The first weight vector is determined based on the window width of the sliding window processing; the number of elements in the first weight vector is the same as the window width of the sliding window processing. The original EEG signal within the window is weighted based on the first weight vector to obtain the second sub-signal; Based on the first sub-signal and the second sub-signal, determine the intermediate variable; A local fitting curve is determined based on the first weight vector and the intermediate variable, and the original EEG signal within the window is subjected to baseline removal processing based on the local fitting curve to obtain the first EEG signal.
3. The EEG signal processing method according to claim 2, characterized in that, The intermediate variables include a first variable and a second variable; the step of determining the local fitting curve based on the first weight vector and the intermediate variables includes: A second weight vector is determined based on the first weight vector; the number of elements in the second weight vector is the same as that in the first weight vector. The local fitting curve is determined based on the second weight vector, the first weight vector, and the intermediate variable; The local fitting curve yfit = wt*(w1*a+b); Among them, a=y2-y1, b=y2-(a*window+1) / 2; yfit is the local fitting curve; wt is the second weight vector; w1 is the first weight vector; a is the first variable among the intermediate variables, b is the second variable among the intermediate variables; window is the window width of the sliding window processing; y1 is the first sub-signal, y2 is the second sub-signal.
4. The EEG signal processing method according to claim 3, characterized in that, The step of performing baseline removal processing on the original EEG signal within the window based on the local fitting curve to obtain the first EEG signal includes: Obtain the normalized vector; The elements in the second weight vector are superimposed with the corresponding elements in the normalized vector to update the elements in the normalized vector. Based on the updated normalized vector, the local fitting curve is normalized to obtain the target fitting curve. The target fitted curve is subtracted from the original EEG signal within the window to perform baseline removal processing on the original EEG signal within the window, thereby obtaining the first EEG signal.
5. The EEG signal processing method according to claim 1, characterized in that, The step of splicing the first target sub-signal and the second target sub-signal to obtain the target EEG signal includes: Determine the tail element of the first target sub-signal and the first element of the second target sub-signal; Calculate the target mean of the tail element and the first element, and determine the first target variable corresponding to the first target sub-signal and the second target variable corresponding to the second target sub-signal based on the target mean; Based on the first target variable, determine the first target weight vector corresponding to the first target sub-signal and the second target weight vector corresponding to the second target sub-signal; Based on the first target weight vector and the second target weight vector, the first target sub-signal and the second target sub-signal are weighted and spliced to obtain the target EEG signal.
6. The EEG signal processing method according to claim 1, characterized in that, The step of performing sliding window processing on the raw EEG signals in the target channel includes: Create a cache queue corresponding to the target channel, and cache the raw EEG signals in the target channel into the cache queue; Obtain preset sliding window parameters; the sliding window parameters include window width and sliding length; When the length of the raw EEG signal cached in the cache queue reaches a preset length, the raw EEG signal cached in the cache queue is subjected to sliding window processing according to the sliding window parameters; wherein, the window width is less than or equal to the preset length; and the sliding length is less than the window width.
7. A brainwave signal processing device, characterized in that, include: The signal acquisition module is used to acquire raw EEG signals from multiple channels; The signal processing module is used to perform sliding window processing on the raw EEG signal in the target channel, and to perform baseline removal processing on the raw EEG signal within the window obtained by the sliding window processing to obtain the first EEG signal; the target channel is any one of the multiple channels; The signal splicing module is used to splice the first EEG signal to obtain the target EEG signal; The first EEG signal includes at least a first target signal and a second target signal; the first target signal and the second target signal are obtained by removing the baseline from the original EEG signals in adjacent windows during the sliding window processing; the signal splicing module is further used for: A first target sub-signal is generated by extracting a first preset number of elements from the latter part of the first target signal; A second preset number of elements are extracted from the latter part of the second target signal to generate a second target sub-signal; The first target sub-signal and the second target sub-signal are spliced together to obtain the target EEG signal; The target EEG signal, the first target signal, and the second target signal have the same number of elements.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the EEG signal processing method as described in any one of claims 1 to 6.
9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the EEG signal processing method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
A method and a system for electroencephalogram signal preprocessing in sleep state analysis
CN106388778A
Electroencephalogram signal feature processing method and device
CN114692680A