CN113855037A - Atrial fibrillation identification method and device based on Transformer - Google Patents

Atrial fibrillation identification method and device based on Transformer Download PDF

Info

Publication number
CN113855037A
CN113855037A CN202111205554.1A CN202111205554A CN113855037A CN 113855037 A CN113855037 A CN 113855037A CN 202111205554 A CN202111205554 A CN 202111205554A CN 113855037 A CN113855037 A CN 113855037A
Authority
CN
China
Prior art keywords
atrial fibrillation
data
data set
transformer
training
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202111205554.1A
Other languages
Chinese (zh)
Other versions
CN113855037B (en
Inventor
谭慧欣
赖杰伟
阳维
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Southern Medical University
Original Assignee
Southern Medical University
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Southern Medical University filed Critical Southern Medical University
Priority to CN202111205554.1A priority Critical patent/CN113855037B/en
Publication of CN113855037A publication Critical patent/CN113855037A/en
Application granted granted Critical
Publication of CN113855037B publication Critical patent/CN113855037B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • AHUMAN NECESSITIES
    • A61MEDICAL OR VETERINARY SCIENCE; HYGIENE
    • A61BDIAGNOSIS; SURGERY; IDENTIFICATION
    • A61B5/00Measuring for diagnostic purposes; Identification of persons
    • A61B5/24Detecting, measuring or recording bioelectric or biomagnetic signals of the body or parts thereof
    • A61B5/316Modalities, i.e. specific diagnostic methods
    • A61B5/318Heart-related electrical modalities, e.g. electrocardiography [ECG]
    • AHUMAN NECESSITIES
    • A61MEDICAL OR VETERINARY SCIENCE; HYGIENE
    • A61BDIAGNOSIS; SURGERY; IDENTIFICATION
    • A61B5/00Measuring for diagnostic purposes; Identification of persons
    • A61B5/24Detecting, measuring or recording bioelectric or biomagnetic signals of the body or parts thereof
    • A61B5/316Modalities, i.e. specific diagnostic methods
    • A61B5/318Heart-related electrical modalities, e.g. electrocardiography [ECG]
    • A61B5/346Analysis of electrocardiograms
    • AHUMAN NECESSITIES
    • A61MEDICAL OR VETERINARY SCIENCE; HYGIENE
    • A61BDIAGNOSIS; SURGERY; IDENTIFICATION
    • A61B5/00Measuring for diagnostic purposes; Identification of persons
    • A61B5/24Detecting, measuring or recording bioelectric or biomagnetic signals of the body or parts thereof
    • A61B5/316Modalities, i.e. specific diagnostic methods
    • A61B5/318Heart-related electrical modalities, e.g. electrocardiography [ECG]
    • A61B5/346Analysis of electrocardiograms
    • A61B5/349Detecting specific parameters of the electrocardiograph cycle
    • A61B5/361Detecting fibrillation
    • AHUMAN NECESSITIES
    • A61MEDICAL OR VETERINARY SCIENCE; HYGIENE
    • A61BDIAGNOSIS; SURGERY; IDENTIFICATION
    • A61B5/00Measuring for diagnostic purposes; Identification of persons
    • A61B5/72Signal processing specially adapted for physiological signals or for diagnostic purposes
    • A61B5/7235Details of waveform analysis
    • AHUMAN NECESSITIES
    • A61MEDICAL OR VETERINARY SCIENCE; HYGIENE
    • A61BDIAGNOSIS; SURGERY; IDENTIFICATION
    • A61B5/00Measuring for diagnostic purposes; Identification of persons
    • A61B5/72Signal processing specially adapted for physiological signals or for diagnostic purposes
    • A61B5/7235Details of waveform analysis
    • A61B5/7253Details of waveform analysis characterised by using transforms
    • AHUMAN NECESSITIES
    • A61MEDICAL OR VETERINARY SCIENCE; HYGIENE
    • A61BDIAGNOSIS; SURGERY; IDENTIFICATION
    • A61B5/00Measuring for diagnostic purposes; Identification of persons
    • A61B5/72Signal processing specially adapted for physiological signals or for diagnostic purposes
    • A61B5/7235Details of waveform analysis
    • A61B5/7264Classification of physiological signals or data, e.g. using neural networks, statistical classifiers, expert systems or fuzzy systems
    • A61B5/7267Classification of physiological signals or data, e.g. using neural networks, statistical classifiers, expert systems or fuzzy systems involving training the classification device

Landscapes

  • Health & Medical Sciences (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Public Health (AREA)
  • Surgery (AREA)
  • Cardiology (AREA)
  • Veterinary Medicine (AREA)
  • General Health & Medical Sciences (AREA)
  • Biophysics (AREA)
  • Pathology (AREA)
  • Biomedical Technology (AREA)
  • Heart & Thoracic Surgery (AREA)
  • Medical Informatics (AREA)
  • Molecular Biology (AREA)
  • Animal Behavior & Ethology (AREA)
  • Artificial Intelligence (AREA)
  • Psychiatry (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Physiology (AREA)
  • Signal Processing (AREA)
  • Evolutionary Computation (AREA)
  • Fuzzy Systems (AREA)
  • Mathematical Physics (AREA)
  • Measurement And Recording Of Electrical Phenomena And Electrical Characteristics Of The Living Body (AREA)

Abstract

The invention discloses an atrial fibrillation identification method and device based on a Transformer, wherein the method comprises the following steps: acquiring original electrocardiogram data; carrying out classification marking on the original electrocardiogram data to obtain atrial fibrillation electrocardiogram data and non-atrial fibrillation electrocardiogram data; carrying out data segmentation on the atrial fibrillation electrocardiogram data and the non-atrial fibrillation electrocardiogram data to construct a training data set and a test data set for neural network training; inputting the training data set into a Transformer for network training to obtain a target model; and inputting the test data set into the target model for secondary classification to obtain classification results of atrial fibrillation electrocardiogram data and non-atrial fibrillation electrocardiogram data in the test data set. The invention has high accuracy and high precision, and can be widely applied to the technical field of data processing.

Description

Atrial fibrillation identification method and device based on Transformer
Technical Field
The invention relates to the technical field of data processing, in particular to a Transformer-based atrial fibrillation identification method and device.
Background
Atrial fibrillation has always been the focus of health concern because it is the most common arrhythmia, with its prevalence expected to double by 2050 years due to the proliferation of aging populations. Atrial fibrillation results in a significant increase in the risk of cardiovascular disease, including a 5-fold increase in stroke risk. A false diagnosis of atrial fibrillation may lead to over-medical treatment, improper use of medical resources, and failure to timely warn of cardiovascular risk. However, asymptomatic and paroxysmal atrial fibrillation accounts for a small percentage of atrial fibrillation events, which makes it difficult to detect atrial fibrillation in a timely manner during a hospital routine electrocardiographic examination.
With the advent of wearable electrocardiographs, long-term continuous electrocardiographic monitoring can significantly improve the detection rate of asymptomatic and paroxysmal atrial fibrillation, but the lack of cardiovascular experts to diagnose all long-term recordings remains a serious challenge. Therefore, the automatic diagnosis of atrial fibrillation by the wearable electrocardiogram is urgent.
The atrial fibrillation detection method based on feature extraction is not robust to noise and individual difference, so the current mainstream methods are based on a convolutional neural network or a cyclic neural network, but for a time sequence, the convolutional network cannot well model long-distance dependence, and the cyclic network has poor parallelism.
Disclosure of Invention
In view of this, embodiments of the present invention provide a method and an apparatus for identifying atrial fibrillation based on a transform with high accuracy and high precision.
One aspect of the present invention provides a Transformer-based atrial fibrillation identification method, including:
acquiring original electrocardiogram data;
carrying out classification marking on the original electrocardiogram data to obtain atrial fibrillation electrocardiogram data and non-atrial fibrillation electrocardiogram data;
carrying out data segmentation on the atrial fibrillation electrocardiogram data and the non-atrial fibrillation electrocardiogram data to construct a training data set and a test data set for neural network training;
inputting the training data set into a Transformer for network training to obtain a target model;
and inputting the test data set into the target model for secondary classification to obtain classification results of atrial fibrillation electrocardiogram data and non-atrial fibrillation electrocardiogram data in the test data set.
Optionally, the acquiring raw electrocardiographic data includes:
and acquiring original electrocardiogram data through wearable equipment.
Optionally, the data segmenting the atrial fibrillation electrocardiographic data and the non-atrial fibrillation electrocardiographic data, and constructing a training data set and a testing data set for neural network training includes:
setting the time slice of the monitoring data as 15 seconds, and setting the sampling rate as 500 Hz;
carrying out data segmentation on the acquired atrial fibrillation electrocardiograph data and non-atrial fibrillation electrocardiograph data;
calculating the mean value and standard deviation of all the electrocardio data after data segmentation;
carrying out normalization processing on all the electrocardiogram data according to the mean value and the standard deviation;
filtering noise in the electrocardiosignals through band-pass filtering to obtain a training data set and a test data set;
wherein the data set format of the training data set and the test data set is HDF5 format.
Optionally, the training data set is input into a Transformer for network training to obtain a target model, and the method includes a projection step, a position embedding step and a Transformer encoding step;
wherein the projecting step comprises:
dividing the training data set into a plurality of segments at equal intervals, wherein each segment is data to be projected;
performing linear transformation on the data to be projected to generate projection data;
adding a classification head with the length equal to that of the projection segment to the projection data, wherein the classification head is used for carrying out data classification;
the location embedding step includes:
adding learnable position information for each small segment according to the total number of the projected segments;
the Transformer encoding step comprises:
normalizing the output of each layer of the network;
enabling the target model to carry out information learning in different feature subspaces through a multi-head self-attention mechanism;
and after classification processing is carried out through the multilayer perceptron, the probability of classifying as atrial fibrillation is obtained through a sigmoid activation function.
Optionally, the expression of the normalization process is:
Figure BDA0003306697100000021
wherein LN (x) represents a normalization processing function; x is an input sample; μ and δ are the mean and standard deviation of the input sample, respectively; gamma is the learning rate; beta is a bias term;
the expression of the multi-head self-attention is as follows:
Figure BDA0003306697100000022
wherein, Attention (Q, K, V) represents a multi-head self-Attention expression; q, K, V are query, key, and value, respectively; soft max (·) is an activation function of the neural network; dkIs the dimension of key K;
the expression of the multilayer perceptron is as follows:
MLP(X)=GELU(XW1+b1)W2+b2
wherein MLP (X) represents an expression of a multi-layer perceptron; x is the input, GELU (-) is an activation function of the neural network, W1And W2Weights of two fully-connected layers in MLP, respectively, b1And b2Is the bias term.
Optionally, the projecting step further includes: the method for dividing the training data set into electrocardiosignals according to the heartbeat comprises the following steps:
acquiring the position of the wave crest of the R wave according to the electrocardiosignals;
if the number of R wave peaks is more than or equal to 20, taking 0.15 second to the left and 0.35 second to the right according to the R wave peak positions, and taking 0.5 second as a heartbeat;
if the number of R wave peaks is more than or equal to 3 and less than 20, taking 0.4 second to the left and 0.6 second to the right according to the positions of the R wave peaks, and taking 1 second as a heart beat;
splicing all the cut heartbeats into a section of signal, and if the spliced signal is less than 20 seconds, zero filling is carried out for 20 seconds; and if the time is more than 20 seconds, cutting the electrocardiosignals for 20 seconds to obtain the division result of the electrocardiosignals.
Optionally, the method further comprises:
and gradually increasing the number of leads of the electrocardiosignals, and inputting the electrocardiosignals with partial leads after being shielded into the target model to obtain the result that the electrocardiosignals are atrial fibrillation or non-atrial fibrillation.
In another aspect, an embodiment of the present invention further provides a Transformer-based atrial fibrillation recognition apparatus, including:
the first module is used for acquiring original electrocardiogram data;
the second module is used for carrying out classification marking on the original electrocardio data to obtain atrial fibrillation electrocardio data and non-atrial fibrillation electrocardio data;
the third module is used for carrying out data segmentation on the atrial fibrillation electrocardiogram data and the non-atrial fibrillation electrocardiogram data to construct a training data set and a test data set for neural network training;
the fourth module is used for inputting the training data set into a Transformer for network training to obtain a target model;
and the fifth module is used for inputting the test data set into the target model for secondary classification to obtain classification results of atrial fibrillation electrocardiographic data and non-atrial fibrillation electrocardiographic data in the test data set.
In another aspect, an embodiment of the present invention further provides an electronic device, including a processor and a memory;
the memory is used for storing programs;
the processor executes the program to implement the method as described above.
In another aspect, the present invention provides a computer-readable storage medium, which stores a program, where the program is executed by a processor to implement the method described above.
The embodiment of the invention also discloses a computer program product or a computer program, which comprises computer instructions, and the computer instructions are stored in a computer readable storage medium. The computer instructions may be read by a processor of a computer device from a computer-readable storage medium, and the computer instructions executed by the processor cause the computer device to perform the foregoing method.
The embodiment of the invention obtains original electrocardio data; carrying out classification marking on the original electrocardiogram data to obtain atrial fibrillation electrocardiogram data and non-atrial fibrillation electrocardiogram data; carrying out data segmentation on the atrial fibrillation electrocardiogram data and the non-atrial fibrillation electrocardiogram data to construct a training data set and a test data set for neural network training; inputting the training data set into a Transformer for network training to obtain a target model; and inputting the test data set into the target model for secondary classification to obtain classification results of atrial fibrillation electrocardiogram data and non-atrial fibrillation electrocardiogram data in the test data set. The invention has high accuracy and high precision.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
FIG. 1 is a graph showing an example of a comparison between a non-atrial fibrillation electrocardiographic signal and an atrial fibrillation electrocardiographic signal;
FIG. 2 is an exemplary diagram of an electrocardiographic signal;
FIG. 3 is an exemplary diagram of a method flow of the present invention;
FIG. 4 is an exemplary diagram of the transform encoder layer of the present invention;
FIG. 5 is a graph illustrating the performance of the method of the present invention in comparison to other methods of atrial fibrillation identification with a lead drop;
FIG. 6 is an exemplary diagram of an improved electrocardiographic segmentation method of the present invention;
FIG. 7 is a flowchart illustrating the overall steps of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
First, explanation will be given on related terms appearing in the embodiments of the present invention:
a Transformer: is a neural network based on a self-attention mechanism;
HierarchichalcalaDataFormat: is a file format designed to store and organize large amounts of data;
3, LN: layer normalization, which is a way to normalize the output of hidden layers of a neural network;
4, MSA: multi-headed self-attention, a mechanism of attention in feature space;
MLP: the multilayer perceptron is a feedforward artificial neural network;
sigmoid: an activation function of the neural network;
softmax: an activation function of the neural network;
GELU: an activation function for a neural network.
For solving the problems in the prior art, an embodiment of the present invention provides a method for identifying atrial fibrillation based on a Transformer, as shown in fig. 7, the method includes:
acquiring original electrocardiogram data;
carrying out classification marking on the original electrocardiogram data to obtain atrial fibrillation electrocardiogram data and non-atrial fibrillation electrocardiogram data;
carrying out data segmentation on the atrial fibrillation electrocardiogram data and the non-atrial fibrillation electrocardiogram data to construct a training data set and a test data set for neural network training;
inputting the training data set into a Transformer for network training to obtain a target model;
and inputting the test data set into the target model for secondary classification to obtain classification results of atrial fibrillation electrocardiogram data and non-atrial fibrillation electrocardiogram data in the test data set.
Optionally, the acquiring raw electrocardiographic data includes:
and acquiring original electrocardiogram data through wearable equipment.
Optionally, the data segmenting the atrial fibrillation electrocardiographic data and the non-atrial fibrillation electrocardiographic data, and constructing a training data set and a testing data set for neural network training includes:
setting the time slice of the monitoring data as 15 seconds, and setting the sampling rate as 500 Hz;
carrying out data segmentation on the acquired atrial fibrillation electrocardiograph data and non-atrial fibrillation electrocardiograph data;
calculating the mean value and standard deviation of all the electrocardio data after data segmentation;
carrying out normalization processing on all the electrocardiogram data according to the mean value and the standard deviation;
filtering noise in the electrocardiosignals through band-pass filtering to obtain a training data set and a test data set;
wherein the data set format of the training data set and the test data set is HDF5 format.
Optionally, the training data set is input into a Transformer for network training to obtain a target model, and the method includes a projection step, a position embedding step and a Transformer encoding step;
wherein the projecting step comprises:
dividing the training data set into a plurality of segments at equal intervals, wherein each segment is data to be projected;
performing linear transformation on the data to be projected to generate projection data;
adding a classification head with the length equal to that of the projection segment to the projection data, wherein the classification head is used for carrying out data classification;
the location embedding step includes:
adding learnable position information for each small segment according to the total number of the projected segments;
the Transformer encoding step comprises:
normalizing the output of each layer of the network;
enabling the target model to carry out information learning in different feature subspaces through a multi-head self-attention mechanism;
and after classification processing is carried out through the multilayer perceptron, the probability of classifying as atrial fibrillation is obtained through a sigmoid activation function.
Optionally, the expression of the normalization process is:
Figure BDA0003306697100000061
wherein LN (x) represents a normalization processing function; x is an input sample; μ and δ are the mean and standard deviation of the input sample, respectively; gamma is the learning rate; beta is a bias term;
the expression of the multi-head self-attention is as follows:
Figure BDA0003306697100000062
wherein, Attention (Q, K, V) represents a multi-head self-Attention expression; q, K, V are query, key, and value, respectively; softmax (·) is an activation function of neural networks; dkIs the dimension of key K;
the expression of the multilayer perceptron is as follows:
MLP(X)=GELU(XW1+b1)W2+b2
wherein MLP (X) represents an expression of a multi-layer perceptron; x is the input, GELU (-) is an activation function of the neural network, W1And W2Weights of two fully-connected layers in MLP, respectively, b1And b2Is the bias term.
Optionally, the projecting step further includes: the method for dividing the training data set into electrocardiosignals according to the heartbeat comprises the following steps:
acquiring the position of the wave crest of the R wave according to the electrocardiosignals;
if the number of R wave peaks is more than or equal to 20, taking 0.15 second to the left and 0.35 second to the right according to the R wave peak positions, and taking 0.5 second as a heartbeat;
if the number of R wave peaks is more than or equal to 3 and less than 20, taking 0.4 second to the left and 0.6 second to the right according to the positions of the R wave peaks, and taking 1 second as a heart beat;
splicing all the cut heartbeats into a section of signal, and if the spliced signal is less than 20 seconds, zero filling is carried out for 20 seconds; and if the time is more than 20 seconds, cutting the electrocardiosignals for 20 seconds to obtain the division result of the electrocardiosignals.
Optionally, the method further comprises:
and gradually increasing the number of leads of the electrocardiosignals, and inputting the electrocardiosignals with partial leads after being shielded into the target model to obtain the result that the electrocardiosignals are atrial fibrillation or non-atrial fibrillation.
In another aspect, an embodiment of the present invention further provides a Transformer-based atrial fibrillation recognition apparatus, including:
the first module is used for acquiring original electrocardiogram data;
the second module is used for carrying out classification marking on the original electrocardio data to obtain atrial fibrillation electrocardio data and non-atrial fibrillation electrocardio data;
the third module is used for carrying out data segmentation on the atrial fibrillation electrocardiogram data and the non-atrial fibrillation electrocardiogram data to construct a training data set and a test data set for neural network training;
the fourth module is used for inputting the training data set into a Transformer for network training to obtain a target model;
and the fifth module is used for inputting the test data set into the target model for secondary classification to obtain classification results of atrial fibrillation electrocardiographic data and non-atrial fibrillation electrocardiographic data in the test data set.
In another aspect, an embodiment of the present invention further provides an electronic device, including a processor and a memory;
the memory is used for storing programs;
the processor executes the program to implement the method as described above.
In another aspect, the present invention provides a computer-readable storage medium, which stores a program, where the program is executed by a processor to implement the method described above.
The embodiment of the invention also discloses a computer program product or a computer program, which comprises computer instructions, and the computer instructions are stored in a computer readable storage medium. The computer instructions may be read by a processor of a computer device from a computer-readable storage medium, and the computer instructions executed by the processor cause the computer device to perform the foregoing method.
The following detailed description of the specific implementation principles of the present invention is made with reference to the accompanying drawings:
the invention relates to a Transformer-based atrial fibrillation identification method, which comprises the following steps of:
s1, acquiring original dynamic electrocardiogram data of wearable equipment;
s2, marking atrial fibrillation on the electrocardiosignals by an expert, and classifying the atrial fibrillation into atrial fibrillation and non-atrial fibrillation;
s3, segmenting the electrocardio data, preprocessing the electrocardio data, and manufacturing the electrocardio data into a general data set of a neural network;
s4, inputting the training data set into a Transformer for network training to obtain a model with excellent performance of each index;
and S5, inputting the test data set into the model obtained in the S4 for secondary classification to obtain the result that the electrocardiosignal is atrial fibrillation or non-atrial fibrillation.
Preferably, in the electrocardiographic data in step S1, the atrial fibrillation signal includes a plurality of noises, such as power frequency interference, myoelectric interference, baseline wander, and the like.
Preferably, the segment length of the central electrical data in step S3 is 15 seconds, and the sampling frequency of the signal is 500 hz.
Specifically, S1, acquiring original dynamic electrocardiogram data of the wearable device; the original electrocardiosignals are acquired through wearable equipment, the time course is long, the electrocardio data under various daily behaviors can be included, the noise types in the data are richer and more diverse, the diversity of the data is increased, the network training is facilitated, and the actual situation of remote electrocardio event monitoring is better met. The atrial fibrillation signal and the non-atrial fibrillation signal are illustrated in the attached drawing 1, and the atrial fibrillation signal has the remarkable characteristics of RR interval inequality, irregular heart rate, P wave disappearance and the like. Atrial fibrillation signals under the condition of lead falling, atrial fibrillation signals under strong noise and atrial flutter signals are illustrated in the attached drawing 2, the lead falling and the strong noise easily cause misjudgment of a neural network, and the atrial flutter signals are difficult to distinguish from the atrial fibrillation signals.
S2, marking the electrocardiosignals, and classifying the electrocardiosignals into atrial fibrillation or non-atrial fibrillation; for example: the label of each electrocardiogram sample can be audited by experts, for example, the following standardization process: evaluation (1 person), examination (1 person), initial examination (2 persons) and final examination (1 person), and 5 experts are used for evaluation and examination.
S3, segmenting the electrocardio data, preprocessing the electrocardio data, and manufacturing the electrocardio data into a general data set of a neural network; in the actual long-term dynamic electrocardiographic monitoring, in order to obtain a monitoring result in real time, monitoring information should be output every other short time period, so that in this example, the length of the time segment is set to be a common value of 15 seconds, and the electrocardiographic signals in the short time period can also reduce the influence of baseline drift and filter motion artifacts. The sampling rate of the electrocardiosignals is set to be 500 Hz. 15 seconds of electrocardiographic data also have two types of tags: atrial fibrillation, and non-atrial fibrillation. Wherein, fig. 1 is an exemplary diagram of atrial fibrillation electrocardiograph signals, and fig. 2 is an exemplary diagram of non-atrial fibrillation electrocardiograph signals. After the signals are segmented, the mean value and the standard deviation of all the signals are calculated, the signals are normalized, power frequency interference, baseline drift and myoelectric noise which may be contained in the signals are filtered through band-pass filtering, the signals are made into a universal data set of a neural network, and the format of the data set is set to be Hierarchica DataFormat, namely the HDF5 format.
S4, dividing the training data set into a plurality of small segments at equal intervals, inputting the small segments into an 8-layer Transformer encoder for network training, and obtaining a model with excellent performance of each index;
the Transformer is an emerging direction of deep learning in the field of computer vision, and comprises projection, position embedding and Transformer encoder layers, the overall structure is shown in fig. 3, and the optimization strategy of the embodiment is set as a gradient descent method.
The projection step is as follows:
A1. the electrocardiosignal is divided into a plurality of segments at equal intervals, and each segment is data to be projected:
Figure BDA0003306697100000081
where ECG represents the ECG signal, the subscript S represents the segments and the superscript N represents the total number of segments.
A2. Carrying out linear transformation on data to be projected to generate projection data:
Figure BDA0003306697100000082
wherein the ECGprojRepresenting projection data, E is a linear transformation matrix.
A3. Adding a classification head equal to the length of the projection segment to the projection data for final classification:
Figure BDA0003306697100000083
wherein z isprojRepresenting projection data with added sort headers, ECGclassIs an added sort header.
The position embedding process comprises the following steps:
A1. adding learnable position information for each small segment according to the total number of segments of the projection:
Figure BDA0003306697100000091
wherein z is0For projection data to which learnable position information is added, EposIs location information that can be learned. The Transformer is information that introduces position information for each projection of the input by position embedding, thereby enabling the network to learn the time flow of the time series.
The transform encoder layers are shown in fig. 4, and include layer normalization, multi-head self-attention, and multi-layer perceptron:
A1. layer Normalization (LN):
Figure BDA0003306697100000092
wherein, x is an input sample, mu and delta are respectively the mean value and the standard deviation of the input sample, gamma is the learning rate, and beta is the bias term. The layer normalization is used for normalizing the output of each layer of the network, is independent of the batch size, does not influence the data volume participating in the layer normalization calculation no matter how many samples are in batch, and does not change the effect when the batch samples are small in volume.
A2. Multiple Self Attention (MSA):
Figure BDA0003306697100000093
wherein Q, K, V are query, key and value respectively, soft max (·) is an activation function of neural network, DkIs the dimension of key K. The self-attention mechanism can model the dependency information among time periods of a long time sequence, and the multi-head self-attention mechanism can allow the model to learn the related information in different feature subspaces.
A3. Multilayer perceptron (MLP):
MLP(X)=GELU(XW1+b1)W2+b2 (7)
wherein X is the input, GELU (-) is an activation function of the neural network, W1And W2Weights of two fully-connected layers in MLP, respectively, b1And b2Is the bias term.
Therefore, the transform encoder inputs the linear projection and the classification head of the electrocardiogram data segment added with the learnable position information, the linear projection and the classification head are input into the encoder, after layer normalization, multi-head self-attention, residual connection, layer normalization, multi-layer perceptron and residual connection of each layer, the linear projection and the classification head are input into the multi-layer perceptron for classification, and the classification output can be classified into atrial fibrillation after an s-igmoid activation function:
Figure BDA0003306697100000101
Figure BDA0003306697100000102
Figure BDA0003306697100000103
Figure BDA0003306697100000104
ProbAF=σ(MLP(y′)) (12)
wherein z isl-1And zlRespectively, output of L-1 and L-th layers (network-one common L layer), z'lIs output after layer normalization, multi-head self-attention and residual connection,
Figure BDA0003306697100000105
is the output of the last layer of the transform encoder, y' is the output of the transform encoder, σ is the Sigmoid function, ProbAFThe probability of atrial fibrillation is the last obtained classification.
The loss function of the network can be expressed as:
L=-∑ω(y log ProbAF)+(1-y)log(1-ProbAF) (13)
wherein
Figure BDA0003306697100000106
Is the cross entropy coefficient (N)nAnd NpThe number of negative samples and the number of positive samples, respectively), can prevent training instability caused by data imbalance, y is a label value, and L is a classification loss.
The weight parameter of the gradient descent update network can be expressed as:
Figure BDA0003306697100000107
wherein wiFor the updated network parameter, wi-1Gamma is the learning rate for the network parameter updated last time.
Due to the fact that data volumes of atrial fibrillation and non-atrial fibrillation are extremely unbalanced, in order to enable the training process to be more stable, data amplification means such as lead shielding, signal segment zeroing and clipping scaling are used for data amplification during training.
And S5, inputting the test data set into the model obtained in the S4 for secondary classification to obtain the result that the electrocardiosignal is atrial fibrillation or non-atrial fibrillation. In order to prove the superiority of the method, lead shedding robustness verification is also carried out. The implementation method comprises the steps of gradually increasing the number of leads of the electrocardiosignals, inputting the electrocardiosignals with partial leads after being shielded into a network to obtain the result that the electrocardiosignals are atrial fibrillation or non-atrial fibrillation. The comparison result is shown in fig. 5, the average identification precision of the atrial fibrillation identification method of the invention is better than that of other methods (DNN 1 and DNN2 in fig. 5 are two currently mainstream deep convolutional neural networks for analyzing cardiac signal arrhythmia).
Optionally, in the embodiment of the present invention, the step S4 may further improve a dividing method of the electrical signal in the center of the projection step. The original method for dividing the electrocardiosignals at equal intervals is improved into the method for dividing the electrocardiosignals according to the heart beat, and the process is shown as the attached figure 6:
A1. acquiring the position of the wave crest of the R wave according to the electrocardiosignals;
A2. if the number of R wave peaks is more than or equal to 20, taking 0.15 second to the left and 0.35 second to the right according to the positions of the R wave peaks, and taking 0.5 second as a heartbeat; and if the number of the R wave peaks is more than or equal to 3 and less than or equal to 20, taking 0.4 second to the left and 0.6 second to the right according to the positions of the R wave peaks, and taking 1 second in total as a heartbeat.
A3. Splicing all the cut heartbeats into a section of signal, and if the spliced signal is less than 20 seconds, zero filling is carried out for 20 seconds; if the time is more than 20 seconds, the cutting time is 20 seconds.
In summary, compared with the prior art, the method uses a Transformer as a model for atrial fibrillation identification; a new input method is provided for the transform to identify atrial fibrillation, namely, electrocardiosignals are divided according to heartbeats, each heart beat is taken as a projection segment and is input into an encoder, and the method has the following advantages:
1. one-dimensional electrocardiosignals are input into a Transformer encoder to identify atrial fibrillation, and compared with a convolutional neural network and a cyclic neural network, the long-distance dependence of a time sequence can be well modeled, and meanwhile, the method has high parallelism.
2. The results obtained with this experimental data set were excellent using the following evaluation indices: accuracy, AUC, F1 score, and AP.
3. Compared with the convolutional neural network for detecting arrhythmia of electrocardiosignals with the best performance, the model disclosed by the invention is more robust to atrial fibrillation identification under partial lead drop, can accurately distinguish atrial fibrillation from atrial flutter, and can more reliably and effectively identify atrial fibrillation events.
4. The method provides an efficient method for automatically identifying atrial fibrillation for long-term electrocardiosignals and provides technical support for the development of remote electrocardio event monitoring.
In alternative embodiments, the functions/acts noted in the block diagrams may occur out of the order noted in the operational illustrations. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality/acts involved. Furthermore, the embodiments presented and described in the flow charts of the present invention are provided by way of example in order to provide a more thorough understanding of the technology. The disclosed methods are not limited to the operations and logic flows presented herein. Alternative embodiments are contemplated in which the order of various operations is changed and in which sub-operations described as part of larger operations are performed independently.
Furthermore, although the present invention is described in the context of functional modules, it should be understood that, unless otherwise stated to the contrary, one or more of the described functions and/or features may be integrated in a single physical device and/or software module, or one or more functions and/or features may be implemented in a separate physical device or software module. It will also be appreciated that a detailed discussion of the actual implementation of each module is not necessary for an understanding of the present invention. Rather, the actual implementation of the various functional modules in the apparatus disclosed herein will be understood within the ordinary skill of an engineer, given the nature, function, and internal relationship of the modules. Accordingly, those skilled in the art can, using ordinary skill, practice the invention as set forth in the claims without undue experimentation. It is also to be understood that the specific concepts disclosed are merely illustrative of and not intended to limit the scope of the invention, which is defined by the appended claims and their full scope of equivalents.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
The logic and/or steps represented in the flowcharts or otherwise described herein, e.g., an ordered listing of executable instructions that can be considered to implement logical functions, can be embodied in any computer-readable medium for use by or in connection with an instruction execution system, apparatus, or device, such as a computer-based system, processor-containing system, or other system that can fetch the instructions from the instruction execution system, apparatus, or device and execute the instructions. For the purposes of this description, a "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transport the program for use by or in connection with the instruction execution system, apparatus, or device.
More specific examples (a non-exhaustive list) of the computer-readable medium would include the following: an electrical connection (electronic device) having one or more wires, a portable computer diskette (magnetic device), a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disc read-only memory (CDROM). Additionally, the computer-readable medium could even be paper or another suitable medium upon which the program is printed, as the program can be electronically captured, via for instance optical scanning of the paper or other medium, then compiled, interpreted or otherwise processed in a suitable manner if necessary, and then stored in a computer memory.
It should be understood that portions of the present invention may be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, the various steps or methods may be implemented in software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, any one or combination of the following techniques, which are known in the art, may be used: a discrete logic circuit having a logic gate circuit for implementing a logic function on a data signal, an application specific integrated circuit having an appropriate combinational logic gate circuit, a Programmable Gate Array (PGA), a Field Programmable Gate Array (FPGA), or the like.
In the description herein, references to the description of the term "one embodiment," "some embodiments," "an example," "a specific example," or "some examples," etc., mean that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the invention. In this specification, the schematic representations of the terms used above do not necessarily refer to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples.
While embodiments of the invention have been shown and described, it will be understood by those of ordinary skill in the art that: various changes, modifications, substitutions and alterations can be made to the embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the claims and their equivalents.
While the preferred embodiments of the present invention have been illustrated and described, it will be understood by those skilled in the art that various changes in form and details may be made therein without departing from the spirit and scope of the invention as defined by the appended claims.

Claims (10)

1. The method for identifying atrial fibrillation based on Transformer is characterized by comprising the following steps of:
acquiring original electrocardiogram data;
carrying out classification marking on the original electrocardiogram data to obtain atrial fibrillation electrocardiogram data and non-atrial fibrillation electrocardiogram data;
carrying out data segmentation on the atrial fibrillation electrocardiogram data and the non-atrial fibrillation electrocardiogram data to construct a training data set and a test data set for neural network training;
inputting the training data set into a Transformer for network training to obtain a target model;
and inputting the test data set into the target model for secondary classification to obtain classification results of atrial fibrillation electrocardiogram data and non-atrial fibrillation electrocardiogram data in the test data set.
2. The method for identifying atrial fibrillation based on a Transformer according to claim 1, wherein the step of acquiring original electrocardiographic data comprises the following steps:
and acquiring original electrocardiogram data through wearable equipment.
3. The method for identifying atrial fibrillation according to claim 1, wherein the step of performing data segmentation on the atrial fibrillation electrocardiographic data and the non-atrial fibrillation electrocardiographic data to construct a training data set and a testing data set for neural network training comprises the following steps of:
setting the time slice of the monitoring data as 15 seconds, and setting the sampling rate as 500 Hz;
carrying out data segmentation on the acquired atrial fibrillation electrocardiograph data and non-atrial fibrillation electrocardiograph data;
calculating the mean value and standard deviation of all the electrocardio data after data segmentation;
carrying out normalization processing on all the electrocardiogram data according to the mean value and the standard deviation;
filtering noise in the electrocardiosignals through band-pass filtering to obtain a training data set and a test data set;
wherein the data set format of the training data set and the test data set is HDF5 format.
4. The method for identifying atrial fibrillation according to claim 1, wherein the training data set is input into a Transformer for network training to obtain a target model, and the method comprises a projection step, a position embedding step and a Transformer coding step;
wherein the projecting step comprises:
dividing the training data set into a plurality of segments at equal intervals, wherein each segment is data to be projected;
performing linear transformation on the data to be projected to generate projection data;
adding a classification head with the length equal to that of the projection segment to the projection data, wherein the classification head is used for carrying out data classification;
the location embedding step includes:
adding learnable position information for each small segment according to the total number of the projected segments;
the Transformer encoding step comprises:
normalizing the output of each layer of the network;
enabling the target model to carry out information learning in different feature subspaces through a multi-head self-attention mechanism;
and after classification processing is carried out through the multilayer perceptron, the probability of classifying as atrial fibrillation is obtained through a sigmoid activation function.
5. The Transformer-based atrial fibrillation identification method of claim 4, wherein the step of identifying the atrial fibrillation in the Transformer-based atrial fibrillation,
the expression of the normalization process is:
Figure FDA0003306697090000021
wherein LN (x) represents a normalization processing function; x is an input sample; μ and δ are the mean and standard deviation of the input sample, respectively; gamma is the learning rate; beta is a bias term;
the expression of the multi-head self-attention is as follows:
Figure FDA0003306697090000022
wherein, Attention (Q, K, V) represents a multi-head self-Attention expression; q, K, V are query, key, and value, respectively; softmax (·) is an activation function of neural networks; dkIs the dimension of key K;
the expression of the multilayer perceptron is as follows:
MLP(X)=GELU(XW1+b1)W2+b2
wherein MLP (X) represents the sense of multilayeringAn expression of a learner; x is the input, GELU (-) is an activation function of the neural network, W1And W2Weights of two fully-connected layers in MLP, respectively, b1And b2Is the bias term.
6. The method for identifying atrial fibrillation based on Transformer according to claim 4, wherein the projecting step further comprises: the method for dividing the training data set into electrocardiosignals according to the heartbeat comprises the following steps:
acquiring the position of the wave crest of the R wave according to the electrocardiosignals;
if the number of R wave peaks is more than or equal to 20, taking 0.15 second to the left and 0.35 second to the right according to the R wave peak positions, and taking 0.5 second as a heartbeat;
if the number of R wave peaks is more than or equal to 3 and less than 20, taking 0.4 second to the left and 0.6 second to the right according to the positions of the R wave peaks, and taking 1 second as a heart beat;
splicing all the cut heartbeats into a section of signal, and if the spliced signal is less than 20 seconds, zero filling is carried out for 20 seconds; and if the time is more than 20 seconds, cutting the electrocardiosignals for 20 seconds to obtain the division result of the electrocardiosignals.
7. The Transformer-based atrial fibrillation recognition method of claim 1, wherein the method further comprises:
and gradually increasing the number of leads of the electrocardiosignals, and inputting the electrocardiosignals with partial leads after being shielded into the target model to obtain the result that the electrocardiosignals are atrial fibrillation or non-atrial fibrillation.
8. Atrial fibrillation recognition device based on Transformer, characterized by comprising:
the first module is used for acquiring original electrocardiogram data;
the second module is used for carrying out classification marking on the original electrocardio data to obtain atrial fibrillation electrocardio data and non-atrial fibrillation electrocardio data;
the third module is used for carrying out data segmentation on the atrial fibrillation electrocardiogram data and the non-atrial fibrillation electrocardiogram data to construct a training data set and a test data set for neural network training;
the fourth module is used for inputting the training data set into a Transformer for network training to obtain a target model;
and the fifth module is used for inputting the test data set into the target model for secondary classification to obtain classification results of atrial fibrillation electrocardiographic data and non-atrial fibrillation electrocardiographic data in the test data set.
9. An electronic device comprising a processor and a memory;
the memory is used for storing programs;
the processor executing the program realizes the method according to any one of claims 1-7.
10. A computer-readable storage medium, characterized in that the storage medium stores a program, which is executed by a processor to implement the method according to any one of claims 1-7.
CN202111205554.1A 2021-10-15 2021-10-15 Atrial fibrillation identification method and device based on Transformer Active CN113855037B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111205554.1A CN113855037B (en) 2021-10-15 2021-10-15 Atrial fibrillation identification method and device based on Transformer

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111205554.1A CN113855037B (en) 2021-10-15 2021-10-15 Atrial fibrillation identification method and device based on Transformer

Publications (2)

Publication Number Publication Date
CN113855037A true CN113855037A (en) 2021-12-31
CN113855037B CN113855037B (en) 2023-03-28

Family

ID=78999905

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111205554.1A Active CN113855037B (en) 2021-10-15 2021-10-15 Atrial fibrillation identification method and device based on Transformer

Country Status (1)

Country Link
CN (1) CN113855037B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114469124A (en) * 2022-01-30 2022-05-13 北京理工大学 Method for identifying abnormal electrocardiosignals in motion process
CN114504324A (en) * 2022-01-20 2022-05-17 武汉中旗生物医疗电子有限公司 Method and device for detecting dynamic atrial fibrillation starting and stopping points and electronic equipment

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130178755A1 (en) * 2011-07-06 2013-07-11 James Waters Analyzing electrocardiograms
CN110547792A (en) * 2019-07-31 2019-12-10 平安科技(深圳)有限公司 atrial fibrillation detection method and device, computer equipment and storage medium
CN111358460A (en) * 2020-03-03 2020-07-03 京东方科技集团股份有限公司 Arrhythmia identification method and device and electronic equipment
CN112932499A (en) * 2021-01-28 2021-06-11 晨思(广州)医疗科技有限公司 Network training and single-lead-connection electrocardiogram data processing method, computer device and medium
CN113143204A (en) * 2021-01-28 2021-07-23 晨思(广州)医疗科技有限公司 Electrocardiosignal quality evaluation method, computer device and storage medium
CN113408508A (en) * 2021-08-20 2021-09-17 中国科学院自动化研究所 Transformer-based non-contact heart rate measurement method

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130178755A1 (en) * 2011-07-06 2013-07-11 James Waters Analyzing electrocardiograms
CN110547792A (en) * 2019-07-31 2019-12-10 平安科技(深圳)有限公司 atrial fibrillation detection method and device, computer equipment and storage medium
CN111358460A (en) * 2020-03-03 2020-07-03 京东方科技集团股份有限公司 Arrhythmia identification method and device and electronic equipment
CN112932499A (en) * 2021-01-28 2021-06-11 晨思(广州)医疗科技有限公司 Network training and single-lead-connection electrocardiogram data processing method, computer device and medium
CN113143204A (en) * 2021-01-28 2021-07-23 晨思(广州)医疗科技有限公司 Electrocardiosignal quality evaluation method, computer device and storage medium
CN113408508A (en) * 2021-08-20 2021-09-17 中国科学院自动化研究所 Transformer-based non-contact heart rate measurement method

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114504324A (en) * 2022-01-20 2022-05-17 武汉中旗生物医疗电子有限公司 Method and device for detecting dynamic atrial fibrillation starting and stopping points and electronic equipment
CN114504324B (en) * 2022-01-20 2024-07-05 武汉中旗生物医疗电子有限公司 Method and device for detecting dynamic atrial fibrillation starting and stopping points and electronic equipment
CN114469124A (en) * 2022-01-30 2022-05-13 北京理工大学 Method for identifying abnormal electrocardiosignals in motion process
CN114469124B (en) * 2022-01-30 2024-04-09 北京理工大学 Method for identifying abnormal electrocardiosignals in movement process

Also Published As

Publication number Publication date
CN113855037B (en) 2023-03-28

Similar Documents

Publication Publication Date Title
Çınar et al. Classification of normal sinus rhythm, abnormal arrhythmia and congestive heart failure ECG signals using LSTM and hybrid CNN-SVM deep neural networks
He et al. Automatic detection of atrial fibrillation based on continuous wavelet transform and 2D convolutional neural networks
US10869610B2 (en) System and method for identifying cardiac arrhythmias with deep neural networks
CN111449645B (en) Intelligent classification and identification method for electrocardiogram and heartbeat
He et al. A framework for cardiac arrhythmia detection from IoT-based ECGs
CN106805965A (en) A kind of electrocardiosignal sorting technique and device
CN107837082A (en) Electrocardiogram automatic analysis method and device based on artificial intelligence self study
Wu et al. A novel method for classification of ECG arrhythmias using deep belief networks
CN113855037B (en) Atrial fibrillation identification method and device based on Transformer
Deperlioglu Heart sound classification with signal instant energy and stacked autoencoder network
KR102483693B1 (en) Method and apparatus of explainable multi electrocardiogram arrhythmia diagnosis
CN116602642B (en) Heart rate monitoring method, device and equipment
CN112704503B (en) Electrocardiosignal noise processing method
Roy et al. Photoplethysmogram signal quality evaluation by unsupervised learning approach
Rohmantri et al. Arrhythmia classification using 2D convolutional neural network
Banerjee et al. A hybrid CNN-LSTM architecture for detection of coronary artery disease from ECG
Borghi et al. Atrial fibrillation classification based on MLP networks by extracting Jitter and Shimmer parameters
CN115281688A (en) Cardiac hypertrophy multi-label detection system based on multi-mode deep learning
CN113995419A (en) Atrial fibrillation risk prediction system based on heartbeat rhythm signal and application thereof
Jia et al. Automatic detection and classification of 12-lead ECGs using a deep neural network
CN112842342B (en) Electrocardiogram and magnetic signal classification method combining Hilbert curve and integrated learning
Balcı A hybrid attention-based LSTM-XGBoost model for detection of ECG-based atrial fibrillation
Wen et al. ECG beat classification using GreyART network
Wang et al. A pooling convolution model for multi-classification of ECG and PCG signals
Benarabi et al. Energy and sparse coding coefficients as sufficient measures for VEBs classification

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant