Magnetoencephalography slice data classification method based on pre-trained fine-tuning model

Through the magnetoencephalography slice data classification method based on the pre-training fine-tuning model, the unsupervised data set is used to pre-train and fine-tune the deep learning model, which solves the problem of high cost of labeling magnetoencephalography data, improves the classification accuracy, and is suitable for many applications. kind of downstream tasks.

CN118447339BActive Publication Date: 2024-09-13ARTIFICIAL INTELLIGENCE RES INST OF HEFEI COMPREHENSIVE NAT SCI CENT (ANHUI ARTIFICIAL INTELLIGENCE LAB)
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410903673.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-08
Publication Date
2024-09-13
Estimated Expiration
2044-07-08

AI Technical Summary

Technical Problem

Due to the high cost of collecting and labeling magnetoencephalography data, the development of deep learning models in the field of magnetoencephalography signal modeling and analysis is limited, especially in scenarios such as epilepsy spike classification, sleep state classification, and visual and auditory task classification. Construction costs and classification accuracy are limited.

Method used

A magnetoencephalogram slice data classification method based on a pre-trained fine-tuning model is used to pre-train and fine-tune the deep learning model through unsupervised data sets, reducing dependence on annotated data and improving classification task accuracy. Specific steps include collecting unlabeled magnetoencephalogram data for preprocessing, constructing an unsupervised data set, performing data augmentation and model parameter adjustment, using the dimension compression module and attention network layer for feature extraction, and optimizing model parameters through backpropagation. , and finally connect the fine-tuning prediction layer to perform parameter fine-tuning after pre-training the model.

Benefits of technology

Through the learning of low-cost unsupervised data, the amount of annotated data required for downstream tasks is reduced, and the classification accuracy is improved. It is suitable for different downstream tasks, including epilepsy spike classification, sleep state classification, and visual and auditory task classification.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118447339B
    Figure CN118447339B
Patent Text Reader

Abstract

The present invention discloses a method for classifying magnetoencephalogram (MEG) slice data based on a pre-trained fine-tuning model, which relates to the field of artificial intelligence technology and comprises the following steps: inputting data to be predicted into a trained deep learning model to output a classification result of the MEG slice data; the training process of the deep learning model is as follows: S1, collecting unlabeled MEG data and pre-processing them, and constructing an unsupervised data set based on the pre-processed MEG data; S2, pre-training the deep learning model based on the unsupervised data set to adjust model parameters of the deep learning model; S3, connecting a fine-tuning prediction layer after the output node of the pre-trained deep learning model, and fine-tuning the parameters in the fine-tuning prediction layer based on the constructed fine-tuning data slice set to obtain a trained deep learning model; the MEG pre-training fine-tuning method reduces the demand for supervised labeled data and improves the accuracy of classification tasks.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a method for classifying magnetoencephalogram slice data based on a pre-trained fine-tuning model. Background Art

[0002] The detection of electrophysiological activity of the brain nerve tissue in the cerebral cortex is one of the basic methods for studying brain function. It is widely used in brain science research such as cognitive function and sensory system. It also assists in the diagnosis of various medical problems such as neurological diseases, mental illness, and psychological disorders.

[0003] Magnetoencephalography (MEG) is a new neuroimaging tool that records extremely weak brain magnetic waves around the brain to form images for analysis by doctors and researchers. Unlike electrical conductivity, the magnetic permeability of the media of various brain tissues is almost the same. Compared with scalp EEG, MEG has a technical advantage in source analysis. In addition, MEG usually has more sensor channels and has certain advantages in spatial resolution.

[0004] Deep learning is an artificial intelligence technology that has emerged in recent years. It originated from the research on artificial neural networks. Through multiple hidden layers, it gradually abstracts the initial data into high-level feature representations, and has achieved far greater improvements in computer vision, natural language processing, search recommendation technology and many other fields.

[0005] The feature representation of MEG data through deep learning models has good applicability and application value. On the one hand, MEG has high temporal and spatial resolution and large data volume, in which background physiological activities account for the vast majority, while the stimulus signals and pathological signals of concern usually account for a small proportion, so the efficiency of manual image judgment is very low, and the application value of model assistance is high; on the other hand, the relationship between MEG signals and human brain activities is very complex, and there are a large number of unknown mechanisms. Deep learning technology can take advantage of big data and large models to achieve image judgment functions that are similar to or even surpass those of humans in some tasks.

[0006] Although deep learning has advantages in generalization performance and expressiveness over traditional machine learning methods, it is also based on the support of data volume, which is also a major disadvantage in the current field of MEG signal modeling and analysis. Due to the high cost of collecting MEG data, especially the high cost of collecting and labeling, it is not easy to collect a large amount of high-quality labeled MEG data. This greatly limits the construction cost and classification accuracy of deep learning models in scenarios such as epileptic spike classification, sleep state classification, and visual and auditory task classification. Summary of the invention

[0007] Based on the technical problems existing in the background technology, the present invention proposes a magnetoencephalogram slice data classification method based on a pre-trained fine-tuning model, which reduces the demand for supervised labeled data and improves the accuracy of classification tasks.

[0008] The method for classifying magnetoencephalogram slice data based on a pre-trained fine-tuning model proposed in the present invention comprises the following steps:

[0009] Input the data to be predicted into the trained deep learning model to output the classification results of the magnetoencephalogram slice data;

[0010] The training process of the deep learning model is as follows:

[0011] S1, collect unlabeled MEG data and preprocess them, and build an unsupervised dataset based on the preprocessed MEG data;

[0012] S11, performing noise reduction and normalization processing on each group of MEG files in the unlabeled MEG data in turn to obtain noise-reduced MEG files;

[0013] S12, calculating the full channel energy of the denoised EEG file, traversing the data points in the denoised EEG file where the full channel energy is greater than the high energy time point, and obtaining high energy data points, wherein the high energy time points are calculated based on the mean and standard deviation of the energy of all channels;

[0014] S13, Each high-energy data point in the high-energy data points is taken as the center point, and the time neighborhood data of the center point is intercepted into the first group of slices. The data matrix dimension of the first group of slices is , randomly sampled from the denoised MEG files At a certain point in time, capture The time neighborhood data of each time point in the time points is formed into the second set of slices. The data matrix dimension of the second set of slices is , the first group of slices and the second group of slices are spliced ​​according to the data dimension to obtain the data matrix of the group of brain magnetic files , with the data matrix As a set of preprocessed brain magnetic files to construct an unsupervised dataset, Indicates the number of slices, corresponding to the data dimension, Indicates the number of channels, corresponding to the spatial dimension, Indicates the slice time length, corresponding to the time dimension;

[0015] S2. Pre-training the deep learning model based on the unsupervised data set to adjust the model parameters of the deep learning model;

[0016] S21, set the batch size to , the data matrix After random shuffling according to the data dimension, we get batches, and the size of each batch data matrix is , ;

[0017] S22. Data augmentation: Setting values ​​based on the input size of deep learning model training , for the batch data matrix Slice to get the third set of slices. The data matrix dimension of the third set of slices is , , construct a noise matrix with the same dimension as the data matrix of the third group of slices, and sum the noise matrix with the data matrix of the third group of slices to obtain the growth data;

[0018] S23, inputting the augmented data into the deep learning model and outputting the pre-trained feature vector;

[0019] S24. Calculate the pre-training loss of the deep learning model based on the pre-training feature vector, and optimize the model parameters of the deep learning model using back propagation and gradient descent;

[0020] S3. Connect a fine-tuning prediction layer after the output node of the pre-trained deep learning model, and fine-tune the parameters in the fine-tuning prediction layer based on the constructed fine-tuning data slice set to obtain a trained deep learning model.

[0021] Furthermore, in step S11, the process of generating the denoised brain magnetoencephalogram file is as follows:

[0022] The MEG files were subjected to noise reduction processing using spatiotemporal signal separation filtering, bandpass filtering, notch filtering, independent principal component analysis and ECG channels in sequence to obtain preprocessed MEG files.

[0023] The mean and standard deviation of each channel of the preprocessed EEG file were calculated, and the preprocessed EEG file was normalized to obtain the denoised EEG file.

[0024] Further, in step S23, the deep learning model includes a dimension compression module and an attention network layer, and the deep learning model specifically processes the input augmented data as follows:

[0025] Based on the dimension compression module, the time and space dimensions of the augmented data are compressed by rearranging pixels to obtain a compressed feature vector;

[0026] The compressed feature vector is input as the input vector to the attention network layer for pixel rearrangement. The attention network layer has N layers, and each layer is provided with a two-dimensional attention module 1, a spatiotemporal replacement module 1, a two-dimensional attention module 2, and a spatiotemporal replacement module 2 connected in sequence. The feature output by the spatiotemporal replacement module 2 of the current layer is used as the input of the two-dimensional attention module 1 of the next layer, until the spatiotemporal replacement module 2 of the Nth layer outputs the attention feature vector;

[0027] Add the input vector to the attention feature vector and output the pre-trained feature vector.

[0028] Furthermore, when the compressed feature vector is input as an input vector into the attention network layer for pixel rearrangement, the network structures of the two-dimensional attention module 1 and the two-dimensional attention module 2 are consistent. The processing process of the two-dimensional attention module 1 on the input vector is as follows:

[0029] Rearrange the pixels of the input vector to obtain a rearranged vector, and perform linear transformation on the rearranged vector to obtain query, key, and value vectors, where the query, key, and value vectors correspond to the multi-head attention feature vector Q, the multi-head attention feature vector K, and the multi-head attention feature vector V, respectively;

[0030] The multi-head attention feature vector Q and the multi-head attention feature vector K are multiplied by parallel matrix multiplication and The activation function obtains the attention feature map;

[0031] Perform parallel matrix multiplication on the multi-head attention feature vector V and the attention feature map to obtain an H-head feature vector, and then obtain a D1-head feature vector by linear transformation and nonlinear activation of the H-head feature vector in the C dimension;

[0032] The output vector is obtained by adding the D1 head feature vector to the input vector of the 2D attention module 1.

[0033] Further, in step S24, the pre-training loss of the deep learning model is calculated as follows:

[0034] (1) Calculate the pre-training loss in the time dimension for the pre-trained feature vector;

[0035] Use a linear layer to adjust the feature dimensions of the pre-trained feature vector Transform and then replace the dimension to get the time slice set ,in Defined as data dimension, Defined as the time dimension, Defined as feature dimension;

[0036] The time dimension of the data in the time slice set is taken , represents the central time point, Length of continuous data Defined as a set of consecutive time slices ;

[0037] Slice continuous time At the center point Linear transformation to get the center vector , with the center vector To predict the corresponding time vector , The time dimension is represented by The time vector is used to constrain the deep learning model to maintain the prediction continuity of the time dimension in the feature space. The pre-training loss formula is as follows:

[0038]

[0039] Current continuous time slice Pre-training loss in the temporal dimension The formula is as follows:

[0040]

[0041] in, Using mean square error to represent one-dimensional feature vector and the one-dimensional eigenvector The distance in feature space, Represents the dimension of the time vector; pre-training loss in the time dimension for the entire set of time slices is the average of the losses of all groups of consecutive time slices in this time slice set;

[0042] (2) Calculate the pre-training loss of the spatial dimension of the pre-trained feature vector;

[0043] Use a linear layer to adjust the feature dimensions of the pre-trained feature vector Transform to obtain the spatial feature vector;

[0044] For the channel vector in the same time dimension, randomly sample W groups of 3 feature vectors as a set of spatial slices , respectively , let the position vector of the channel corresponding to the three eigenvectors in the physical space be , used to constrain the deep learning model features to maintain similar consistency in the spatial dimension in the feature space, and the pre-training loss of the spatial dimension The calculation is as follows:

[0045]

[0046]

[0047]

[0048] in, represents the activation function, The mean square error is used to represent the distance between two one-dimensional feature vectors in the feature space, that is, Represents a one-dimensional feature vector and the one-dimensional eigenvector The distance in feature space, Represents a one-dimensional feature vector and the one-dimensional eigenvector The distance in feature space, Represents a one-dimensional feature vector and the one-dimensional eigenvector The distance in feature space, Represents a one-dimensional feature vector and the one-dimensional eigenvector The distance in feature space, Represents the position vector , position vector , position vector The distance between them; the spatial dimension pre-training loss of the entire feature vector is the average of the pre-training losses of all W groups of feature vector slices;

[0049] (3) Add the pre-training loss of the time dimension and the pre-training loss of the space dimension to obtain the pre-training loss of the deep learning model.

[0050] Furthermore, it is characterized in that, in step S3, it specifically includes:

[0051] The acquired labeled data of downstream tasks are denoised and normalized in turn to obtain denoised labeled data. The fine-tuning dataset and the corresponding label Label are separated from the denoised labeled data according to the labeled time point. The spatial dimension and time dimension of the fine-tuning dataset are consistent with those in the unsupervised dataset.

[0052] The fine-tuning dataset is randomly shuffled and divided into batches, and each batch of data is input into the pre-trained deep learning model to obtain the compressed feature vector, and the pixels are rearranged into the time vector to be classified. ,in is the data dimension, is the time dimension, is the characteristic dimension;

[0053] The time vector to be classified After global pooling in the time dimension, the data is input into the fine-tuning prediction layer, and the parameters in the fine-tuning prediction layer are fine-tuned based on the cross entropy loss.

[0054] The advantages of the magnetoencephalogram (MEG) slice data classification method based on a pre-trained fine-tuning model provided by the present invention are: through low-cost unsupervised data learning, baseline model parameters that can adapt to different downstream tasks are obtained, thereby reducing the amount of labeled data required for downstream tasks to achieve target accuracy, or improving the accuracy of downstream tasks with the same amount of data, wherein downstream tasks include application scenarios in which MEG slices are input and identification labels are output, such as epileptic spike classification, sleep state classification, and visual and auditory task classification. BRIEF DESCRIPTION OF THE DRAWINGS

[0055] Figure 1 Training flowchart for deep learning models;

[0056] Figure 2 It is a structural flowchart of the deep learning model;

[0057] Figure 3 It is the structural flow chart of the dimension compression module;

[0058] Figure 4 It is a schematic diagram of the structure of the two-dimensional attention module;

[0059] Figure 5 A schematic diagram of the pre-training loss process of the deep learning model in the time dimension;

[0060] Figure 6 Schematic diagram of the pre-training loss process of deep learning models in the spatial dimension. DETAILED DESCRIPTION

[0061] Below, the technical solution of the present invention is described in detail through specific embodiments. Many specific details are set forth in the following description to facilitate a full understanding of the present invention. However, the present invention can be implemented in many other ways different from those described herein, and those skilled in the art can make similar improvements without violating the connotation of the present invention. Therefore, the present invention is not limited to the specific implementation disclosed below.

[0062] Figures 1 to 6 As shown, the method for classifying magnetoencephalogram slice data based on a pre-trained fine-tuning model proposed in the present invention comprises the following steps:

[0063] Input the data to be predicted into the trained deep learning model to output the prediction results;

[0064] The training process of the deep learning model is as follows:

[0065] S1, collect unlabeled MEG data and preprocess them, and build an unsupervised dataset based on the preprocessed MEG data;

[0066] S11, performing noise reduction and normalization processing on each group of MEG files in the unlabeled MEG data in turn to obtain noise-reduced MEG files;

[0067] The MEG file is denoised using the spatiotemporal signal separation filter (maxwell filter), bandpass filter, notch filter, independent principal component analysis and ECG channel in turn to obtain the preprocessed MEG file; in this example, the bandpass filter parameter is [1Hz, 40Hz], and other feasible filter parameters are [1Hz, 60Hz], [1Hz, 80Hz], [1Hz, 100Hz]. Note that when the low-pass frequency of the selected bandpass filter is higher than the working current frequency of the MEG acquisition device, a notch filter needs to be used for denoising at the same time. Taking the Chinese current frequency of 50Hz as an example, if the bandpass filter parameter is [1Hz, 80Hz], 50Hz needs to be denoised again by notch filter. In addition, the number of features used in the independent principal component analysis in this example is consistent with the number of channels, and only the independent features that are most similar to the ECG channel features are removed.

[0068] The mean and standard deviation of each channel of the preprocessed EEG file were calculated, and the preprocessed EEG file was normalized to obtain the denoised EEG file.

[0069] S12, calculating the full channel energy of the denoised EEG file, traversing the data points in the denoised EEG file where the full channel energy is greater than the high energy time point, and obtaining high energy data points, where the high energy time point is based on the average energy of all channels and standard deviation It is calculated that the high energy time point corresponds to , is a threshold parameter.

[0070] S13, Each high-energy data point in the high-energy data points is taken as the center point, and the time neighborhood data of the center point is intercepted into the first group of slices. The data matrix dimension of the first group of slices is , randomly sampled from the denoised MEG files At a certain point in time, capture The time neighborhood data of each time point in the time points is formed into the second set of slices. The data matrix dimension of the second set of slices is , the first group of slices and the second group of slices are spliced ​​according to the data dimension to obtain the data matrix of the group of brain magnetic files , with the data matrix As a set of preprocessed brain magnetic files to construct an unsupervised dataset, Indicates the number of slices, corresponding to the data dimension, Indicates the number of channels, corresponding to the spatial dimension, Indicates the length of slice time, corresponding to the time dimension. It should be noted that data dimension, space dimension and time dimension are collectively referred to. For different data matrices, the corresponding letters may be different;

[0071] by Base sampling This is because the background activity fragments account for a large proportion of the magnetoencephalogram data. S12 selects the neural active part (that is, the data point greater than the high energy moment) for pre-training. In order to ensure that the background activity is also included in the observation, the slice data is randomly selected for training. In this example, , the training ratio of the neural active part and the random part is 1:1, which can be adjusted by and The ratio of the size to modify the focus of pre-training.

[0072] S2. Pre-training the deep learning model based on the unsupervised data set to adjust the model parameters of the deep learning model;

[0073] S21, set the batch size to , the data matrix After random shuffling according to the data dimension, we get batches, and the size of each batch data matrix is , ;

[0074] In this example Take 32, when Not divisible In each round of iteration, the last batch of data that cannot be grouped is skipped.

[0075] S22. Data augmentation: Setting values ​​based on the input size of deep learning model training , for the batch data matrix Slice to get the third set of slices. The data matrix dimension of the third set of slices is , , construct a noise matrix with the same dimension as the data matrix of the third group of slices, and sum the noise matrix with the data matrix of the third group of slices to obtain the augmented data ;

[0076] The third set of slices is generated as follows: Randomly select a bias value in the interval , intercept As a new data slice, and then the new data slice from Select channel, this The slice data of each channel is set to zero to obtain the third set of slices. In addition, each element in the noise matrix independently obeys a Gaussian distribution with a mean of 0 and a standard deviation of Std.

[0077] Understandably, is the length of the time dimension of the dataset slice, It is the length of the slice time dimension actually fed into the deep learning model. It is related to the sampling rate of training data, model design, and downstream task mode, and can be adapted to change. Only a part needs to be expanded accordingly. This example uses 250Hz data and selects 512ms as the time dimension of the deep learning model input. =128, when the corresponding data set is prepared, You can take 1.5 times ,at this time =192, or Take other greater than The numerical value of .

[0078] Number of zeroed channels for data augmentation The variance in the noise matrix determines the strength of data augmentation and can be set flexibly. In this example, Pick 0.05 times of =15, the noise standard deviation is =0.1.

[0079] In this embodiment, for the convenience of description, the augmented data is recorded as , it is understandable that the augmented data The data matrix dimensions with the third set of slices The sizes are the same, but they do not represent the same data.

[0080] S23. Augment the data Input into the deep learning model and output the pre-trained feature vector ,in is a hyperparameter of the deep learning model, represents the compressed spatial dimension, Represents the compressed time dimension, represents the feature dimension, here The dimension setting refers to the feature vector Dimensions in

[0081] This example will use As the actual size of the augmented data, when the actual task adopts other dimension sizes, the feature dimensions of all the structures described below can be replaced accordingly.

[0082] The deep learning model includes a dimension compression module and an attention network layer. The overall process is as follows: Figure 2 As shown in the figure, the specific processing process of the deep learning model on the input augmented data is as follows:

[0083] (a1) Based on the dimension compression module, the temporal and spatial dimensions of the augmented data are compressed by pixel rearrangement to obtain the compressed feature vector;

[0084] In such Figure 3 In the dimension compression module shown, the augmented data is used as the input vector (32,306,128), and the channel completion is performed to obtain the completed vector (32,312,128). Then, the completed vector (32,312,128) is pixel-rearranged to obtain the rearranged vector (32,(26,12),(8,16)). Finally, the compressed feature vector is output by pixel rearrangement. .

[0085] (a2) The compressed feature vector is input as the input vector to the attention network layer, and the pixels of the input vector are rearranged to obtain the attention feature vector.

[0086] The attention network layer consists of N layers, and each layer is provided with a two-dimensional attention module 1, a space-time replacement module 1, a two-dimensional attention module 2, and a space-time replacement module 2 which are connected in sequence. That is to say, each layer of the attention network layer is provided with two two-dimensional attention modules and two space-time replacement modules. The input of the two-dimensional attention module 1 of the first layer is a compressed feature vector, which then passes through the space-time replacement module 1, the two-dimensional attention module 2, and the space-time replacement module 2 of the first layer in sequence to output the features of the first layer. The features output by the first layer are used as the input of the two-dimensional attention module 1 of the second layer, which then passes through the space-time replacement module 1, the two-dimensional attention module 2, and the space-time replacement module 2 of the second layer in sequence to output the features of the second layer, until the Nth layer is reached, and the space-time replacement module 2 of the Nth layer outputs the attention feature vector.

[0087] In this example, N=6. This hyperparameter controls the model depth, amount of computation, and the number of parameters.

[0088] In such Figure 4 In the two-dimensional attention module shown in the figure, the input vector is pixel-rearranged to obtain a rearranged vector, and the rearranged vector is linearly transformed to obtain query, key, and value vectors, which correspond to multi-head attention feature vectors Q, K, and V. The multi-head attention feature vectors Q and K are multi-head attention feature vectors through parallel matrix multiplication and The activation function obtains the attention feature map, and then the multi-head attention feature vector V and the attention feature map are parallel matrix multiplied to obtain the H-head feature vector, and then the H-head feature vector The D1 head feature vector is obtained through C-dimensional linear transformation and nonlinear activation and added to the input vector of the two-dimensional attention module to obtain the output vector.

[0089] In the two-dimensional attention module, the dimensions of the input vector, D1 head feature vector, and output vector are , the dimensions of feature vector Q, feature vector K, feature vector V, attention feature map, and H head feature vector are .in Changes with the input of the deep learning model, is the internal hyperparameter of the 2D attention module;

[0090] In this example, the two-dimensional attention module , There are two input sizes, 2D attention module 1 , the 2D attention module 2 The function of the space-time replacement module is to replace the feature dimension and actual dimension of the vector. The space-time replacement module 1 changes the feature vector (32, 26, 8, 192) into (32, 8, 26, 192), and the space-time replacement module 2 changes the feature vector (32, 8, 26, 192) into (32, 26, 8, 192);

[0091] (a3) After the input vector passes through all the two-dimensional attention modules and the spatiotemporal permutation modules, the residual linear layer and the nonlinear activation function are used to transform the feature dimension to obtain a feature vector, and then the feature vector is normalized by the feature dimension to obtain the feature vector , the feature vector As the output of the deep learning model.

[0092] In this embodiment, in the deep learning model, for the input vector (32,306,128), the time and space dimensions of the input vector (32,306,128) are compressed by the dimension compression module to obtain a compressed feature vector (32,26,8,192), and the compressed feature vector (32,26,8,192) is input into the attention network layer. After a series of processing by the two-dimensional attention module and the spatiotemporal substitution module in the attention network layer, a feature vector (32,26,8,64) is obtained, and then after normalization of the characteristic dimension, a feature vector (32,26,8,64) is output. The feature vector (32,26,8,64) is the same as correspond.

[0093] S24, based on pre-trained feature vector Calculate the pre-training loss of deep learning models and optimize the model parameters of deep learning models using back-propagation and gradient descent;

[0094] (b1) Pre-trained feature vector Calculate the pre-training loss in the time dimension;

[0095] Use a linear layer to pre-train feature vectors The characteristic dimension Transform and then replace the dimension to get the time slice set ,in Defined as data dimension, Defined as the time dimension, Defined as the feature dimension, where The dimension setting refers to the time slice set The dimension in the time slice set is ; The time dimension of the data in the time slice set is taken , represents the central time point, Length of continuous data Defined as a set of consecutive time slices , The time dimension is represented by The time vector (D) of At the center moment Linear transformation to get the center vector , with the center vector To predict the corresponding time vector , which is used to constrain the deep learning model to maintain the prediction continuity of the time dimension in the feature space, and the time dimension pre-training loss of the entire time slice set The formula is as follows:

[0096]

[0097] Current continuous time slice Pre-training loss in the temporal dimension The formula is as follows:

[0098]

[0099] in, Using mean square error to represent one-dimensional feature vector and the one-dimensional eigenvector The distance in feature space, Represents the dimension of the time vector; pre-training loss in the time dimension for the entire set of time slices is the loss of consecutive time slices for all groups in this time slice set The average value of

[0100] In this embodiment, if Figure 5 As shown, the pre-trained feature vector As the input feature vector, the input feature vector (32, 26, 8, 64) is linearly transformed and dimensionally permuted to obtain the time vector set , each data is (8,64), when T=5 and t=3, each data can generate 4 consecutive data (5,64), so the time slice set can generate a total of A group of continuous time slices. The third time slice of each group of continuous time slices G(5,64) is obtained by linear transformation To predict the actual time slice , calculate the mean square error to get the pre-training loss of the continuous time slice G ,Will Group of consecutive time slices Average the feature vector (32, 26, 8, 64) to calculate the pre-training loss in the time dimension .

[0101] (b2) Pre-trained feature vector Calculate the pre-training loss of the spatial dimension;

[0102] Use a linear layer to pre-train feature vectors The characteristic dimension Transform to obtain the spatial feature vector; randomly sample W groups of 3 spatial feature vectors in the same time dimension as a set of spatial slices , respectively , let the position vector of the channel corresponding to the three spatial feature vectors in the physical space be , used to constrain the deep learning model features to maintain similar consistency in the spatial dimension in the feature space, and the pre-training loss of the spatial dimension The calculation is as follows:

[0103]

[0104]

[0105]

[0106] in, represents the activation function, The mean square error is used to represent the distance between two one-dimensional feature vectors in the feature space, that is, Represents a one-dimensional feature vector and the one-dimensional eigenvector The distance in feature space, Represents a one-dimensional feature vector and the one-dimensional eigenvector The distance in feature space, Represents a one-dimensional feature vector and the one-dimensional eigenvector The distance in feature space, Represents a one-dimensional feature vector and the one-dimensional eigenvector The distance in feature space, Represents the position vector , position vector , position vector The distance between them; the spatial dimension pre-training loss of the entire feature vector is the pre-training loss for all W groups of feature vector slices average;

[0107] In this embodiment, if Figure 6 As shown, the pre-trained feature vector As the input feature vector, the input feature vector (32, 26, 8, 64) is linearly transformed into a spatial feature vector, and then the pixels are rearranged to obtain the rearranged feature vector , randomly sampling triplets in the spatial dimension to obtain channels Vector (64) Channel Vector (64) Channel Vector (64) Then the triplet loss is calculated, with a total of The average loss is calculated for the pre-trained feature vector Compute the pre-training loss on the feature dimension.

[0108] (b3) Add the pre-training loss of the time dimension and the pre-training loss of the space dimension to get the pre-training loss of the deep learning model :

[0109]

[0110] The back propagation method is used to calculate the propagation gradient of each training parameter of the deep learning model, and the model parameters of the deep learning model are optimized using gradient descent. The pre-trained deep learning model is a model that maintains good description consistency in both time and space dimensions.

[0111] S3, connecting a fine-tuning prediction layer after the output node of the pre-trained deep learning model, and fine-tuning the parameters in the fine-tuning prediction layer based on the constructed fine-tuning data slice set to obtain a trained deep learning model;

[0112] The fine-tuning training process is as follows:

[0113] (c1) De-noise and normalize the annotated data of the downstream tasks to obtain the denoised annotated data, and separate the fine-tuning data set from the denoised annotated data according to the annotated time point. And the corresponding label Label , the fine-tuning dataset is consistent with the spatial and temporal dimensions in the unsupervised dataset, that is, With unsupervised dataset Consistent, is the dimension of the downstream task. In the classification task, is the number of categories.

[0114] The specific process of denoising and normalizing the acquired labeled data of the downstream task refers to step S11, wherein the downstream task may be epileptic spike classification, sleep state classification, visual and auditory task classification, etc. In these classification tasks, the task classification of the magnetoencephalogram can be set using this embodiment.

[0115] (c2) The fine-tuning dataset is randomly shuffled and divided into batches, and the size of each batch is , input each batch of data into the pre-trained deep learning model to obtain the compressed feature vector , pixels are rearranged into time vectors to be classified ,in is the data dimension, is the time dimension, is the feature dimension, The dimension setting is Dimension settings in;

[0116] (c3) The time vector to be classified After global pooling in the time dimension, the data is input to the fine-tuning prediction layer, and the parameters in the fine-tuning prediction layer are fine-tuned based on the cross entropy loss.

[0117] Specifically, after the training of the deep learning model based on the unsupervised dataset is completed, it can be used as the basic model for downstream task training. During the downstream task training process, if the amount of data in the fine-tuning dataset is small, the fine-tuning parameter update is only performed in the fine-tuning prediction layer. If the amount of data in the fine-tuning dataset is large, the parameters of the entire deep learning model can be fine-tuned. However, the learning rate setting of the pre-training parameters should be significantly lower than that of the fine-tuning prediction layer, and the general reduction is 1 / 5 or 1 / 10.

[0118] After the deep learning model is trained, when it is used for downstream task prediction, the data to be predicted also needs to be denoised and normalized as described in step (c1), but without setting labels. The data to be predicted is then input into the final deep learning model to obtain the prediction result.

[0119] Through steps S1 to S3, by learning low-cost unsupervised data, the baseline model parameters that can adapt to different downstream tasks are obtained, thereby reducing the amount of labeled data required for downstream tasks to achieve target accuracy, or improving the accuracy of downstream tasks with the same amount of data.

[0120] In the downstream task comparison experiment based on spike classification in this example, the classification accuracy of the pre-trained fine-tuned model was improved from 90% to 93% compared with the randomly initialized model. It should be noted that the scope of downstream task adaptation is all application scenarios where the input magnetoencephalogram slice outputs the identification label, including epileptic spike classification, sleep state classification, visual and auditory task classification, etc.

[0121] The above description is only a preferred specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can make equivalent replacements or changes according to the technical scheme and inventive concept of the present invention within the technical scope disclosed by the present invention, which should be covered by the protection scope of the present invention.

Claims

1. Classification method of MEG slice data based on pre-trained fine-tuning model, It is characterized in that Input the data to be predicted into the trained deep learning model to output the classification results of the magnetoencephalogram slice data; The training process of the deep learning model is as follows: S1, collect unlabeled MEG data and preprocess them, and build an unsupervised dataset based on the preprocessed MEG data; S11, performing noise reduction and normalization processing on each group of MEG files in the unlabeled MEG data in turn to obtain noise-reduced MEG files; S12, calculating the full channel energy of the denoised EEG file, traversing the data points in the denoised EEG file where the full channel energy is greater than the high energy time point, and obtaining high energy data points, wherein the high energy time points are calculated based on the mean and standard deviation of the energy of all channels; S13, Each high-energy data point in the high-energy data points is taken as the center point, and the time neighborhood data of the center point is intercepted into the first group of slices. The data matrix dimension of the first group of slices is , randomly sampled from the denoised MEG files At a certain point in time, capture The time neighborhood data of each time point in the time points is formed into the second set of slices. The data matrix dimension of the second set of slices is , the first group of slices and the second group of slices are spliced ​​according to the data dimension to obtain the data matrix of the group of brain magnetic files , with the data matrix As a set of preprocessed brain magnetic files to construct an unsupervised dataset, Indicates the number of slices, corresponding to the data dimension, Indicates the number of channels, corresponding to the spatial dimension, Indicates the slice time length, corresponding to the time dimension; S2. Pre-training the deep learning model based on the unsupervised data set to adjust the model parameters of the deep learning model; S21, set the batch size to , the data matrix After random shuffling according to the data dimension, we get batches, and the size of each batch data matrix is , ; S22. Data augmentation: Setting values ​​based on the input size of deep learning model training , for the batch data matrix Slice to get the third set of slices. The data matrix dimension of the third set of slices is , , construct a noise matrix with the same dimension as the data matrix of the third group of slices, and sum the noise matrix with the data matrix of the third group of slices to obtain the growth data; S23, inputting the augmented data into the deep learning model and outputting the pre-trained feature vector; S24. Calculate the pre-training loss of the deep learning model based on the pre-training feature vector, and optimize the model parameters of the deep learning model using back propagation and gradient descent; S3. Connect a fine-tuning prediction layer after the output node of the pre-trained deep learning model, and fine-tune the parameters in the fine-tuning prediction layer based on the constructed fine-tuning data slice set to obtain a trained deep learning model.

2. The method for classifying magnetoencephalogram slice data based on a pre-trained fine-tuning model according to claim 1, It is characterized in that In step S11, the process of generating the denoised brain magnetoencephalogram file is as follows: The MEG files were subjected to noise reduction processing using spatiotemporal signal separation filtering, bandpass filtering, notch filtering, independent principal component analysis and ECG channels in sequence to obtain preprocessed MEG files. The mean and standard deviation of each channel of the preprocessed EEG file were calculated, and the preprocessed EEG file was normalized to obtain the denoised EEG file.

3. The method for classifying magnetoencephalogram slice data based on a pre-trained fine-tuning model according to claim 1, It is characterized in that In step S23, the deep learning model includes a dimension compression module and an attention network layer. The specific processing process of the deep learning model on the input augmented data is as follows: Based on the dimension compression module, the time and space dimensions of the augmented data are compressed by rearranging pixels to obtain a compressed feature vector; The compressed feature vector is input as the input vector to the attention network layer for pixel rearrangement. The attention network layer has N layers, and each layer is provided with a two-dimensional attention module 1, a spatiotemporal replacement module 1, a two-dimensional attention module 2, and a spatiotemporal replacement module 2 connected in sequence. The feature output by the spatiotemporal replacement module 2 of the current layer is used as the input of the two-dimensional attention module 1 of the next layer, until the spatiotemporal replacement module 2 of the Nth layer outputs the attention feature vector; Add the input vector to the attention feature vector and output the pre-trained feature vector.

4. The method for classifying magnetoencephalogram slice data based on a pre-trained fine-tuning model according to claim 3, It is characterized in that When the compressed feature vector is input as the input vector into the attention network layer for pixel rearrangement, the network structures of the two-dimensional attention module 1 and the two-dimensional attention module 2 are the same. The processing process of the input vector by the two-dimensional attention module 1 is as follows: Rearrange the pixels of the input vector to obtain a rearranged vector, and perform linear transformation on the rearranged vector to obtain query, key, and value vectors, where the query, key, and value vectors correspond to the multi-head attention feature vector Q, the multi-head attention feature vector K, and the multi-head attention feature vector V, respectively; The multi-head attention feature vector Q and the multi-head attention feature vector K are multiplied by parallel matrix multiplication and The activation function obtains the attention feature map; Perform parallel matrix multiplication on the multi-head attention feature vector V and the attention feature map to obtain an H-head feature vector, and then obtain a D1-head feature vector by linear transformation and nonlinear activation of the H-head feature vector in the C dimension; The output vector is obtained by adding the D1 head feature vector to the input vector of the 2D attention module 1.

5. The method for classifying magnetoencephalogram slice data based on a pre-trained fine-tuning model according to claim 3, It is characterized in that In step S24, the pre-training loss of the deep learning model is calculated as follows: (1) Calculate the pre-training loss in the time dimension for the pre-trained feature vector; Use a linear layer to adjust the feature dimensions of the pre-trained feature vector Transform and then replace the dimension to get the time slice set ,in Defined as data dimension, Defined as the time dimension, Defined as feature dimension; The time dimension of the data in the time slice set is taken , represents the central time point, Length of continuous data Defined as a set of consecutive time slices ; Slice continuous time At the center point Linear transformation to get the center vector , with the center vector To predict the corresponding time vector , The time dimension is represented by The time vector is used to constrain the deep learning model to maintain the prediction continuity of the time dimension in the feature space. The pre-training loss formula is as follows: Current continuous time slice Pre-training loss in the temporal dimension The formula is as follows: in, Using mean square error to represent one-dimensional feature vector and the one-dimensional eigenvector The distance in feature space, Represents the dimension of the time vector; pre-training loss in the time dimension for the entire set of time slices is the average of the losses of all groups of consecutive time slices in this time slice set; (2) Calculate the pre-training loss of the spatial dimension of the pre-trained feature vector; Use a linear layer to adjust the feature dimensions of the pre-trained feature vector Transform to obtain the spatial feature vector; For the spatial channel vector in the same time dimension, randomly sample W groups of 3 spatial feature vectors as a set of spatial slices , respectively , let the position vector of the channel corresponding to the three spatial feature vectors in the physical space be , used to constrain the deep learning model features to maintain similar consistency in the spatial dimension in the feature space, and the pre-training loss of the spatial dimension The calculation is as follows: in, represents the activation function, The mean square error is used to represent the distance between two one-dimensional feature vectors in the feature space, that is, Represents a one-dimensional feature vector and the one-dimensional eigenvector The distance in feature space, Represents a one-dimensional feature vector and the one-dimensional eigenvector The distance in feature space, Represents a one-dimensional feature vector and the one-dimensional eigenvector The distance in feature space, Represents a one-dimensional feature vector and the one-dimensional eigenvector The distance in feature space, Represents the position vector , position vector , position vector The distance between them; the spatial dimension pre-training loss of the entire feature vector is the average of the pre-training losses of all W groups of feature vector slices; (3) Add the pre-training loss of the time dimension and the pre-training loss of the space dimension to obtain the pre-training loss of the deep learning model.

6. The method for classifying magnetoencephalogram slice data based on a pre-trained fine-tuning model according to claim 1, It is characterized in that In step S3, it specifically includes: The acquired labeled data of downstream tasks are denoised and normalized in turn to obtain denoised labeled data. The fine-tuning dataset and the corresponding label Label are separated from the denoised labeled data according to the labeled time point. The spatial dimension and time dimension of the fine-tuning dataset are consistent with those in the unsupervised dataset. The fine-tuning dataset is randomly shuffled and divided into batches, and each batch of data is input into the pre-trained deep learning model to obtain the compressed feature vector, and the pixels are rearranged into the time vector to be classified. ,in is the data dimension, is the time dimension, is the characteristic dimension; The time vector to be classified After global pooling in the time dimension, the data is input into the fine-tuning prediction layer, and the parameters in the fine-tuning prediction layer are fine-tuned based on the cross entropy loss.