Model training methods and atrial fibrillation heartbeat detection methods
By combining feature extraction networks and location encoding, the bounding boxes and classification predictions are updated layer by layer, which solves the shortcomings of existing ECG atrial fibrillation detection center beat level recognition and location prediction, and improves the accuracy and generalization ability of beat level atrial fibrillation detection.
Patent Information
- Application Number
- CN202411482688.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-23
- Publication Date
- 2025-11-14
- Estimated Expiration
- 2044-10-23
AI Technical Summary
Existing ECG atrial fibrillation detection methods cannot identify atrial fibrillation in individual heartbeats with fine granularity and ignore the location information of irregular heartbeats, resulting in insufficient model generalization performance. Furthermore, traditional QRS detection algorithms are inadequate in various arrhythmia scenarios.
A model training method is adopted, which combines a feature extraction network, an encoder and a decoder, and uses a location encoding function to construct a location code. The bounding box and classification prediction are updated layer by layer, and the model parameters are optimized by combining loss calculation to improve the accuracy of location prediction.
It achieves heartbeat-level atrial fibrillation heartbeat detection, effectively avoiding feature ambiguity and improving the model's accuracy and generalization ability in atrial fibrillation detection.
Smart Images

Figure CN119302669B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of physiological signal processing technology, and in particular to a model training method and a method for detecting atrial fibrillation heartbeats. Background Technology
[0002] Electrocardiograms (ECGs) can be used to assist in the clinical diagnosis of atrial fibrillation (AF). Therefore, timely and accurate detection of AF in ECG heartbeat signals is crucial for the early detection of AF. However, most existing ECG-based AF detection methods often only focus on segment-level AF classification tasks, failing to identify AF in individual heartbeats with fine granularity and neglecting the effective extraction of location information for irregular heartbeats, thus limiting the model's generalization performance in practical applications. Existing heartbeat-level AF detection methods typically use a single heartbeat signal as input, still requiring additional QRS detection algorithms for heartbeat localization. However, traditional threshold-based QRS detection algorithms still have insufficient performance in various arrhythmia scenarios, and erroneous localization results may further limit the model's detection capabilities.
[0003] Therefore, how to accurately predict the location of atrial fibrillation heartbeats while focusing on their classification is a technical problem that needs to be solved in the current technology. Summary of the Invention
[0004] In view of the above problems, this disclosure provides a model training method and an atrial fibrillation heartbeat detection method.
[0005] According to a first aspect of this disclosure, a model training method is provided, comprising:
[0006] Each ECG record sample in the sample set is preprocessed to obtain a target ECG image segment, wherein the target ECG image segment includes M heart beats, where M is an integer greater than or equal to 1. Each heart beat is labeled with a category label and a two-dimensional truth bounding box label. The category label is used to characterize whether the heart beat is an atrial fibrillation heart beat.
[0007] The target ECG image segment is input into the feature extraction network, and the output is the ECG feature corresponding to the target ECG image segment.
[0008] Using a positional encoding function, a first positional code corresponding to the above-mentioned electrocardiogram features is constructed;
[0009] The above-mentioned electrocardiogram features and the above-mentioned first position code are input into the encoder, and the electrocardiogram code features are output.
[0010] Repeat the following steps until the number of layers in the first loop matches the number of layers in the decoder, to obtain the atrial fibrillation heartbeat detection model:
[0011] If it is determined that the first cycle number mentioned above is inconsistent with the number of layers in the decoder,
[0012] The above-mentioned electrocardiogram encoding features, the above-mentioned first position encoding, the decoder embedded corresponding to the y-th decoding layer, and the second position encoding are input into the above-mentioned y-th decoding layer to obtain the output of the above-mentioned y-th decoding layer. The above-mentioned decoder includes Y decoding layers, where y is an integer greater than or equal to 1 and less than or equal to Y. The decoder embedded corresponding to the above-mentioned y-th decoding layer is the output of the (y-1)-th decoding layer. The second position encoding corresponding to the above-mentioned y-th decoding layer is constructed based on P bounding boxes updated through the output of the (y-1)-th decoding layer.
[0013] The output of the y-th decoding layer is input into the bounding box prediction header of the y-th decoding layer, and the offset corresponding to each of the P bounding boxes is output.
[0014] Using the offsets corresponding to the P bounding boxes, update the P bounding boxes to obtain the P predicted bounding boxes updated by the output of the y-th decoding layer.
[0015] The output of the y-th decoding layer is input into the classification prediction head of the y-th decoding layer, and the classification prediction results of each of the P reference heartbeats corresponding to the above decoder are output. The prediction bounding boxes are one-to-one with the above reference heartbeats, and the prediction bounding boxes are used to characterize the position of the reference chip in the target electrocardiogram segment.
[0016] The category labels and two-dimensional ground truth bounding box labels of the M heartbeats in the target ECG image segment are respectively compared with the classification prediction results and prediction bounding boxes of the P reference heartbeats to calculate the loss value and the bounding box loss value.
[0017] Based on the classification loss value and the bounding box loss value mentioned above, the model parameters of the model to be trained are adjusted to obtain the adjusted model, which includes a feature extraction network, an encoder, and a decoder.
[0018] The second aspect of this disclosure provides a method for detecting atrial fibrillation heartbeats, including:
[0019] The ECG record to be tested is sampled to the target sampling frequency, and the ECG record to be tested at the target sampling frequency is divided into multiple ECG segments to be tested according to the target time period.
[0020] For each of the above-mentioned ECG image segments to be detected, the ECG image segment to be detected is input into the atrial fibrillation heartbeat detection model, and the model outputs the classification prediction results and prediction bounding boxes corresponding to each heartbeat in the ECG image segment to be detected. The classification prediction results are used to determine the atrial fibrillation heartbeats in the ECG image segment to be detected.
[0021] A third aspect of the present invention provides an electronic device comprising: one or more processors; and a memory for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors perform the method described above.
[0022] A fourth aspect of the present invention also provides a computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, cause the processor to perform the methods described above.
[0023] A fifth aspect of the invention also provides a computer program product, including a computer program that, when executed by a processor, implements the above-described method.
[0024] According to the model training method and atrial fibrillation heartbeat detection method provided in this disclosure, the electrocardiogram (ECG) recording samples in the sample set are first preprocessed to improve the quality of the samples and enhance the accuracy of model training. The target ECG segment is input into the feature extraction network to extract the corresponding ECG features. A first position code corresponding to the ECG features is constructed by using a position encoding function. The first position code and the ECG features are input into the encoder, which helps to capture position dependencies and supplement the model's position representation capability. Then, the ECG encoded features, the first position code, and the decoder output by the encoder are embedded into the second position code and input into the decoder. The position query, i.e., the second position code, is updated by updating the bounding box representing the heartbeat position layer by layer to effectively locate the atrial fibrillation heartbeat. Since the target ECG segment includes multiple heartbeats, the trained model can provide heartbeat-level predictions, effectively avoiding the feature ambiguity problem caused by the ECG segment containing both atrial fibrillation and non-atrial fibrillation heartbeats. Furthermore, since a loss calculation is performed based on the output of each decoding layer, the model training speed is improved. Attached Figure Description
[0025] The foregoing contents, as well as other objects, features, and advantages of this disclosure, will become clearer from the following description of embodiments with reference to the accompanying drawings, in which:
[0026] Figure 1 This illustration schematically shows an application scenario of the model training method and the atrial fibrillation heartbeat detection method according to embodiments of the present disclosure;
[0027] Figure 2 A flowchart illustrating a model training method according to an embodiment of the present disclosure is shown schematically.
[0028] Figure 3 A schematic diagram illustrating the structure of a model to be trained according to an embodiment of the present disclosure is shown.
[0029] Figure 4 A schematic diagram illustrating the backbone structure of a feature extraction network according to an embodiment of the present disclosure is shown.
[0030] Figure 5 A schematic diagram illustrating the structure of a decoder and encoder according to embodiments of the present disclosure is shown.
[0031] Figure 6 A flowchart illustrating the use of encoder output electrocardiogram encoding features according to an embodiment of the present disclosure is shown.
[0032] Figure 7 A flowchart illustrating the process of obtaining the output of the y-th decoding layer according to an embodiment of the present disclosure is shown schematically.
[0033] Figure 8 A flowchart illustrating an atrial fibrillation heart rate detection method according to an embodiment of the present disclosure is shown schematically.
[0034] Figure 9 A schematic block diagram of a model training apparatus according to an embodiment of the present disclosure is shown.
[0035] Figure 10 A schematic diagram illustrating the structure of an atrial fibrillation heart rate detection device according to an embodiment of the present disclosure is shown; and
[0036] Figure 11 A block diagram schematically illustrates an electronic device suitable for implementing a model training method and an atrial fibrillation heartbeat detection method according to embodiments of the present disclosure. Detailed Implementation
[0037] The embodiments of the present disclosure will now be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the disclosure. In the following detailed description, numerous specific details are set forth to provide a thorough understanding of the embodiments of the present disclosure for ease of explanation. However, it will be apparent that one or more embodiments may be practiced without these specific details. Furthermore, descriptions of well-known structures and techniques are omitted in the following description to avoid unnecessarily obscuring the concepts of the present disclosure.
[0038] The terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit this disclosure. The terms “comprising,” “including,” etc., as used herein indicate the presence of the stated features, steps, operations, and / or components, but do not exclude the presence or addition of one or more other features, steps, operations, or components.
[0039] All terms used herein (including technical and scientific terms) have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein are to be interpreted in a manner consistent with the context of this specification, and not in an idealized or overly rigid way.
[0040] When using expressions such as "at least one of A, B and C", they should generally be interpreted in accordance with the meaning that is commonly understood by those skilled in the art (e.g., "a system having at least one of A, B and C" should include, but is not limited to, a system having A alone, a system having B alone, a system having C alone, a system having A and B, a system having A and C, a system having B and C, and / or a system having A, B and C, etc.).
[0041] In the technical solution disclosed herein, the user information (including but not limited to user personal information, user image information, user device information, such as location information) and data (including but not limited to data used for analysis, stored data, and displayed data) involved are all information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, storage, use, processing, transmission, provision, disclosure, and application of related data all comply with relevant laws, regulations, and standards, necessary confidentiality measures have been taken, and they do not violate public order and good morals. Corresponding operation entry points are provided for users to choose to authorize or refuse.
[0042] In scenarios involving automated decision-making using personal information, the methods, devices, and systems provided in this disclosure all offer users corresponding entry points for choosing to agree to or reject the automated decision-making results. If the user chooses to reject, the process proceeds to the expert decision-making stage. Here, "automated decision-making" refers to the activity of automatically analyzing and evaluating an individual's behavioral habits, interests, or economic, health, and credit status through computer programs, and then making a decision. Here, "expert decision-making" refers to the activity of making decisions by personnel who specialize in a particular field, possess specialized experience, knowledge, and skills, and have reached a certain level of professional expertise.
[0043] In implementing this disclosure, it was discovered that atrial fibrillation (AF) is characterized on electrocardiograms by irregular RR intervals and the disappearance of P waves replaced by f waves. Currently, interpretation of ECG data still relies on medical experts, and manual visual examination of ECGs is a very time-consuming and error-prone task, significantly reducing the chances of timely detection of AF. Therefore, it is essential to develop reliable automated methods for analyzing and interpreting long-term ECG recordings.
[0044] In recent years, deep learning (DL) technology has shown excellent performance in feature extraction and classification due to its unique adaptive capabilities. It can identify abstract and subtle information features that are difficult for humans to observe, making it very suitable for accurate analysis of large amounts of clinical atrial fibrillation ECG data.
[0045] Existing deep learning methods for atrial fibrillation detection can typically provide diagnostic predictions based on input ECG segments or RR interval sequences (RRIs) extracted from ECGs. However, some overlooked issues in existing deep learning methods require further investigation.
[0046] First, most existing AF detection methods treat fixed-length segments of ECG recordings as a whole to generate a single predictive label, which makes it impossible to provide heartbeat-level predictive labels. Furthermore, an ECG segment may contain both AF (atrial fibrillation) segments and Non-AF (non-atrial fibrillation) segments, which will lead to ambiguity in the feature space and mislead the model into embedding both into an overlapping feature space.
[0047] Secondly, existing AF detection models expect isolated single heartbeat signals as input to achieve beat-level detection, but this cannot provide sufficient rhythm location information for atrial fibrillation detection.
[0048] Furthermore, existing deep learning methods often focus only on atrial fibrillation (AF) classification tasks, neglecting the extraction of rhythm location information from ECGs, which limits the model's generalization performance in real-world applications. In addition, AF detection methods using a single heartbeat signal or RRI sequence as input still require explicit localization of the heartbeat signal. While model training can typically rely on heartbeat annotations in the dataset, inference in practical applications still necessitates the use of QRS detection algorithms. Traditional threshold-based QRS detection algorithms still have insufficient performance in various arrhythmia scenarios, and erroneous localization results may further limit the model's detection capabilities.
[0049] Therefore, accurately predicting the location of atrial fibrillation beats while focusing on their classification is a technical problem that needs to be solved in the existing technology. Based on this, this disclosure provides a model training method and an atrial fibrillation beat detection method to solve the above-mentioned problem. In addition, this disclosure also provides a model training device and an atrial fibrillation beat detection device to implement the above-mentioned model training method and atrial fibrillation beat detection method.
[0050] Figure 1 The illustration shows an application scenario of the model training method and the atrial fibrillation heartbeat detection method according to embodiments of the present disclosure.
[0051] like Figure 1As shown, application scenario 100 according to this embodiment may include a first terminal device 101, a second terminal device 102, a third terminal device 103, a network 104, and a server 105. The network 104 serves as a medium for providing a communication link between the first terminal device 101, the second terminal device 102, the third terminal device 103, and the server 105. The network 104 may include various connection types, such as wired or wireless communication links, or fiber optic cables, etc.
[0052] Users can use the first terminal device 101, the second terminal device 102, and the third terminal device 103 to interact with the server 105 via the network 104 to receive or send messages, etc. Various communication client applications can be installed on the first terminal device 101, the second terminal device 102, and the third terminal device 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social media platform software, etc. (for example only).
[0053] The first terminal device 101, the second terminal device 102, and the third terminal device 103 can be various electronic devices with displays and support web browsing, including but not limited to smartphones, tablets, laptops, and desktop computers.
[0054] Server 105 can be a server that provides various services, such as a backend management server that supports websites browsed by users using the first terminal device 101, the second terminal device 102, and the third terminal device 103 (this is just an example). The backend management server can analyze and process data such as received user requests, and feed back the processing results (such as web pages, information, or data obtained or generated according to user requests) to the terminal devices.
[0055] For example, server 105 can preprocess each ECG record sample in the sample set to obtain a target ECG image segment. This target ECG image segment is then input into a feature extraction network, which outputs ECG features corresponding to the target ECG image segment. A positional encoding function is then used to construct a first positional encoding corresponding to the ECG features. The ECG features and the first positional encoding are then input into the encoder, outputting ECG encoded features. This process is repeated until the first loop iteration matches the number of layers in the decoder, resulting in an atrial fibrillation beat detection model. If the first loop iteration does not match the number of layers in the decoder, the ECG encoded features, the first positional encoding, the decoder corresponding to the y-th decoding layer, and the second positional encoding are embedded into the y-th decoding layer, resulting in the output of the y-th decoding layer. The output of the y-th decoding layer is input into the bounding box prediction head of the y-th decoding layer, and the output is the offset corresponding to each of the P bounding boxes. Using the offsets corresponding to each of the P bounding boxes, the P bounding boxes are updated to obtain the P predicted bounding boxes updated by the output of the y-th decoding layer. The output of the y-th decoding layer is input into the classification prediction head of the y-th decoding layer, and the classification prediction results corresponding to each of the P reference heartbeats embedded by the decoder are output. The class labels and two-dimensional ground truth bounding box labels of each of the M heartbeats in the target ECG image segment are respectively compared with the classification prediction results and predicted bounding boxes of each of the P reference heartbeats to calculate the loss, obtaining the classification loss value and the bounding box loss value. Based on the classification loss value and the bounding box loss value, the model parameters of the model to be trained are adjusted to obtain the adjusted model.
[0056] It should be noted that the model training method and atrial fibrillation heartbeat detection method provided in this embodiment can generally be executed by server 105. Correspondingly, the model training device and atrial fibrillation heartbeat detection device provided in this embodiment can generally be located in server 105. The model training method and atrial fibrillation heartbeat detection method provided in this embodiment can also be executed by a server or server cluster that is different from server 105 and capable of communicating with the first terminal device 101, the second terminal device 102, the third terminal device 103, and / or server 105. Correspondingly, the model training device and atrial fibrillation heartbeat detection device provided in this embodiment can also be located in a server or server cluster that is different from server 105 and capable of communicating with the first terminal device 101, the second terminal device 102, the third terminal device 103, and / or server 105.
[0057] It should be understood that Figure 1 The number of terminal devices, networks, and servers shown is merely illustrative. Depending on implementation needs, any number of terminal devices, networks, and servers can be included.
[0058] The following will be based on Figure 1 The described scene, through Figures 2-8The model training method and atrial fibrillation heartbeat detection method of the embodiments of this disclosure are described in detail.
[0059] Figure 2 A flowchart illustrating a model training method according to an embodiment of the present disclosure is shown schematically.
[0060] like Figure 2 As shown, the method 200 includes operations S210 to S221.
[0061] In operation S210, each electrocardiogram record sample in the sample set is preprocessed to obtain the target electrocardiogram segment.
[0062] The target electrocardiogram segment may include M heartbeats, where M is an integer greater than or equal to 1, and each heartbeat is labeled with a category label and a two-dimensional ground truth bounding box label.
[0063] According to embodiments of this disclosure, multiple electrocardiogram (ECG) recording samples in a sample set are preprocessed to improve sample quality and facilitate model training accuracy. Based on the category label and two-dimensional ground truth bounding box label for each heartbeat, loss calculation is performed using the predicted classification result and bounding box to adjust the model parameters. The category label may include an atrial fibrillation (AF) label and a non-AF label to characterize whether the heartbeat is an atrial fibrillation heartbeat; the two-dimensional ground truth bounding box label indicates the position of the heartbeat within the target ECG segment.
[0064] Figure 3 A schematic diagram of the structure of a model to be trained according to an embodiment of the present disclosure is shown.
[0065] like Figure 3 As shown, the model to be trained 300 includes a feature extraction network (CNN Backbone) 310, an encoder (Transformer Encoder) 320, and a decoder (Transformer Decoder) 330.
[0066] In operation S211, the target ECG image segment is input into the feature extraction network, and the output is the ECG feature corresponding to the target ECG image segment.
[0067] According to embodiments of this disclosure, a target electrocardiogram (ECG signal) segment can be input into a feature extraction network 310 to extract features from the target ECG signal segment, thereby obtaining ECG features corresponding to the target ECG signal segment.
[0068] In operation S212, the position encoding function is used to construct the first position code corresponding to the electrocardiogram features.
[0069] According to embodiments of this disclosure, since the Transformer architecture has permutation invariance, fixed positional encoding is added to the input of each attention module in the encoder 320 to capture positional dependencies, which helps to supplement the model's positional representation capabilities.
[0070] According to embodiments of this disclosure, a sine function is used to construct a position encoding vector at the same scale, thereby encoding the position... Position encoding function mapped to D-dimensional sinusoidal embedding It can be expressed as formulas (1) and (2) below.
[0071] (1)
[0072] (2)
[0073] in, In the encoder, it refers to the position of the encoding vector in the time dimension. The encoding vector refers to the feature length D corresponding to each time point in the time dimension of the electrocardiogram feature. The length of the feature dimension of the electrocardiogram feature is D. The subscripts 2i and 2i+1 represent the index in the encoding vector. When i is odd, formula (2) is used, and when i is even, formula (1) is used. i refers to D and takes a value of 0 to D / 2. T is a hyperparameter. The typical value used in the encoder is T=10000.
[0074] According to the embodiments of this disclosure, by using the formulas (1) and (2) corresponding to the above position encoding functions, a first position encoding corresponding to the electrocardiogram features can be constructed based on the electrocardiogram features.
[0075] In operation S213, the electrocardiogram features and the first position code are input into the encoder, and the electrocardiogram coded features are output.
[0076] According to embodiments of this disclosure, encoder 320 consists of multiple encoding layers with the same structure, all of which are capable of encoding and generating encoded features with the same resolution as the input electrocardiogram features. That is, by inputting the electrocardiogram features into the encoder, the encoder can extract the electrocardiogram encoded features from the electrocardiogram features. Furthermore, by inputting the first position encoding into the encoder, the encoder can capture positional dependencies, which helps to supplement the positional representation capability of the model.
[0077] According to embodiments of this disclosure, based on the above formulas (1) and (2), the position code is independent of the specific value of the feature, but related to the length and position of the feature, that is, related to the shape of the feature. Therefore, as long as the shape of the feature is fixed, the corresponding position code is fixed. Thus, the position code input to each coding layer in the encoder 320 is the same, which is the first position code. The electrocardiogram feature is only used as the input of the first coding layer, and the input of the next coding layer is the first position code and the output of the previous coding layer.
[0078] In operation S214, the electrocardiogram encoding features, the first position encoding, the decoder corresponding to the y-th decoding layer are embedded into the second position encoding input to the y-th decoding layer to obtain the output of the y-th decoding layer.
[0079] The decoder 330 may include Y decoding layers, where y is an integer greater than or equal to 1 and less than or equal to Y; the decoder embedding corresponding to the y-th decoding layer is the output of the (y-1)-th decoding layer, and the second position encoding corresponding to the y-th decoding layer is constructed based on P bounding boxes updated by the output of the (y-1)-th decoding layer, where P is an integer greater than M.
[0080] According to embodiments of this disclosure, decoder 330 may include Y identical decoding layers for decoding P targets, that is, the number of predicted heartbeats output by decoder 330 is P.
[0081] According to embodiments of this disclosure, the number of predicted heartbeats output by the trained model is fixedly limited. That is, in the inference stage of actual application, the number of predicted heartbeats is P=N. However, the number of heartbeats in the ECG segments input into the trained model is variable. In order for the trained model to more accurately detect ECG segments containing different numbers of heartbeats, it is necessary to set the number of predicted heartbeats output by the model to be significantly greater than the possible number of heartbeats in the ECG segment during training. That is, N is much greater than the possible M. The model only needs to predict NM heartbeats as non-target heartbeats. These non-target heartbeats are invalid predictions. For example, for an ECG segment of t seconds, the maximum number of heartbeats that may appear is 60, so the model output can be set to 100.
[0082] According to an embodiment of this disclosure, when y is 1, for the first decoding layer in the decoder 330, the decoder embedding corresponding to the first decoding layer is generated based on P reference frames, and the second position code corresponding to the first decoding layer is constructed based on the reference bounding boxes of each of the P random reference frames using the position coding function, i.e., the above formulas (1) and (2); when y is greater than 1, the decoder embedding corresponding to the y-th decoding layer is the output of the (y-1)-th decoding layer, and the second position code corresponding to the y-th decoding layer is constructed based on the P bounding boxes updated by the output of the (y-1)-th decoding layer.
[0083] In operation S215, the output of the y-th decoding layer is input into the bounding box prediction header of the y-th decoding layer, and the offsets corresponding to the P bounding boxes are output.
[0084] According to embodiments of the present disclosure, each decoding layer in the decoder 330 includes a bounding box prediction head and a classification prediction head, so as to predict a predicted bounding box based on the bounding box prediction head and predict a predicted classification result based on the classification prediction head.
[0085] According to embodiments of this disclosure, by inputting the output of the y-th decoding layer into the bounding box prediction head of that decoding layer, the offsets corresponding to each of the P bounding boxes can be output. This provides updated bounding boxes for the (y+1)th decoding layer; iterative updates help further reduce the optimization difficulty. The bounding box prediction head is... The bounding box prediction head consists of three fully connected layers. This is the offset of the bounding box center point. This is the offset of the bounding box width.
[0086] In operation S216, the P bounding boxes are updated using the offsets corresponding to each of the P bounding boxes, resulting in the P predicted bounding boxes updated by the output of the y-th decoding layer.
[0087] According to embodiments of this disclosure, the offsets corresponding to each of the P bounding boxes are used. Update the P bounding boxes to obtain P predicted bounding boxes corresponding to the output of the y-th decoding layer.
[0088] According to embodiments of this disclosure, given a normalized bounding box predicted by the (y-1)th decoding layer... Then the y-th decoding layer can update the bounding box with the corresponding predicted bounding box. It can be represented by the following formula (3).
[0089] (3)
[0090] in, For the q-th predicted bounding box among the P predicted bounding boxes corresponding to the (y-1)-th decoding layer, For the q-th predicted bounding box among the P predicted bounding boxes corresponding to the y-th decoding layer, Let be the relative offset of the q-th bounding box predicted by the y-th decoding layer with respect to the center point. Let be the relative offset of the q-th bounding box predicted by the y-th decoding layer with respect to the box width. and These represent the sigmoid function and the inverse sigmoid function, respectively.
[0091] In operation S217, the output of the y-th decoding layer is input into the classification prediction head of the y-th decoding layer, and the classification prediction results of each of the P reference frames corresponding to the decoder embedding are output.
[0092] The predicted bounding box corresponds one-to-one with the reference heartbeat, and the predicted bounding box is used to represent the position of the reference heartbeat in the target electrocardiogram segment.
[0093] According to embodiments of this disclosure, the output of the y-th decoding layer is normalized using layer normalization and input into the classification prediction head of that decoding layer. This allows the output of classification prediction results corresponding to each of the P reference heartbeats. The classification prediction results can indicate whether a reference heartbeat is an atrial fibrillation heartbeat, a non-atrial fibrillation heartbeat, or a non-target heartbeat. In other words, the classification prediction results can be used to determine the atrial fibrillation heartbeat among the P reference heartbeats. The classification prediction head is... The classification prediction head contains two fully connected layers.
[0094] In operation S218, the category labels and two-dimensional ground truth bounding box labels of each of the M heartbeats in the target electrocardiogram segment are compared with the classification prediction results and predicted bounding boxes of each of the P reference heartbeats to calculate the loss, and the classification loss value and the bounding box loss value are obtained.
[0095] According to embodiments of this disclosure, loss calculations are performed on the predicted bounding boxes and classification prediction results obtained from the output of each decoding layer, based on the category labels of M heartbeats in the target electrocardiogram segment and the two-dimensional ground truth bounding box labels, to calculate classification loss values and bounding box loss values, thereby accelerating model training.
[0096] In operation S219, the model parameters of the model to be trained are adjusted based on the classification loss value and the bounding box loss value to obtain the adjusted model, which includes a feature extraction network, an encoder, and a decoder.
[0097] In this case, the bounding box prediction head and the classification prediction head do not share parameters.
[0098] In operation S220, it is determined whether the first loop round is consistent with the number of layers in the decoder.
[0099] According to an embodiment of this disclosure, if the first cycle number is inconsistent with the number of layers in the decoder, operations S214 to S219 are performed; if the first cycle number is consistent with the number of layers in the decoder, operation S221 is performed.
[0100] In operation S221, the adjusted model is determined as the atrial fibrillation heartbeat detection model.
[0101] According to embodiments of this disclosure, the model trained using a target electrocardiogram (ECG) segment is identified as an atrial fibrillation heartbeat detection model. The target ECG segment is at least one.
[0102] According to embodiments of this disclosure, the electrocardiogram (ECG) recording samples in the sample set are first preprocessed to improve sample quality and enhance the accuracy of model training. The target ECG segment is then input into a feature extraction network to extract the corresponding ECG features. A first positional encoding corresponding to the ECG features is constructed using a positional encoding function, and the first positional encoding and ECG features are input into the encoder. This helps capture positional dependencies and supplements the model's positional representation capability. The ECG encoded features, the first positional encoding, and the decoder output by the encoder are then embedded into the second positional encoding and input into the decoder. The position query, i.e., the second positional encoding, is updated by updating the bounding box representing the heartbeat position layer by layer to effectively locate atrial fibrillation heartbeats. Since the target ECG segment includes multiple heartbeats, the trained model can provide heartbeat-level predictions, effectively avoiding the feature ambiguity problem caused by the ECG segment simultaneously containing atrial fibrillation heartbeats and non-atrial fibrillation heartbeats. Furthermore, since a loss calculation is performed based on the output of each decoding layer, the model training speed is improved.
[0103] According to embodiments of this disclosure, preprocessing each electrocardiogram (ECG) recording sample in the sample set to obtain a target ECG image segment includes: sampling each ECG recording sample in the sample set to a target sampling frequency; filtering each ECG recording sample at the target sampling frequency to obtain a filtered ECG recording sample; segmenting each filtered ECG recording sample into multiple ECG image segments according to a target time period; normalizing the multiple ECG image segments to obtain a normalized ECG image segment; and labeling the normalized ECG image segments with category labels and two-dimensional truth bounding box labels to obtain the target ECG image segment.
[0104] According to embodiments of this disclosure, the sampling frequency of each electrocardiogram recording sample in the sample set can be sampled to the target sampling frequency. This is to facilitate accurate training of the model.
[0105] According to embodiments of this disclosure, due to equipment aging, changes in environmental conditions, etc., there may be noise in the electrocardiogram (ECG) recording samples, which will affect the training of the model. Therefore, it is necessary to filter the ECG recording samples at the target sampling frequency to filter out the noise in the ECG recording samples, thereby obtaining filtered ECG recording samples.
[0106] For example, a bandpass Butterworth filter with an order of 5 and a pass frequency range of 0.5 to 40 Hz can be used to remove baseline drift and high-frequency noise from electrocardiogram (ECG) recordings. The filter order and type can be set and selected as needed. Baseline drift generally refers to noise below 0.5 Hz, and high-frequency noise generally refers to noise above 40 Hz.
[0107] According to embodiments of this disclosure, the presence of baseline drift and high-frequency noise can interfere with the features of electrocardiogram (ECG) recording samples during model training, which may affect the accuracy and stability of the measurement results. Therefore, filtering the ECG recording samples at the target sampling frequency can eliminate the influence of baseline drift and high-frequency noise on the ECG, improve the quality of the samples, and avoid interference with subsequent model training.
[0108] According to embodiments of this disclosure, since the length of the input image segments processed by the model is limited, the filtered electrocardiogram (ECG) recording samples need to be segmented into multiple ECG image segments according to the target time period to avoid interference from multiple sample segments of different lengths to the model training. For example, the filtered ECG recording samples can be segmented into non-overlapping segments. A 1-second ECG image segment.
[0109] According to embodiments of this disclosure, to facilitate data processing during model training, electrocardiogram (ECG) image segments are normalized to obtain normalized ECG image segments. Each heartbeat in the normalized ECG image segment is then labeled with a category label and a two-dimensional ground truth bounding box label to obtain the target ECG image segment. For example, z-score normalization can be performed on the ECG image segments.
[0110] According to embodiments of this disclosure, the length of the target electrocardiogram segment is... However, the number of heartbeats contained in different target ECG segments varies. This target ECG segment can be defined as... The target ground truth set corresponding to the target electrocardiogram segment can be represented as: Where M can represent the number of images captured at the center of the target electrocardiogram segment. This can be represented as the element corresponding to the i-th heartbeat in the target electrocardiogram segment, where the element... It can be represented as ,in, It can be represented as a category label (AF or Non-AF). For example, it can be labeled with 0 and 1, where 1 represents atrial fibrillation and 0 represents non-atrial fibrillation. It can be represented as a two-dimensional truth bounding box label. The coordinates of the center point are normalized. The width is relative to the sample length.
[0111] The two-dimensional ground truth bounding box of each heartbeat in the target electrocardiogram segment can be obtained from the normalized electrocardiogram segment.
[0112] For example, the two-dimensional truth bounding box of a heartbeat includes position and width. The R-peak position can be used as the center position of the bounding box, i.e., the center point coordinates. The empirical value of 400ms can be sampled as the width of the bounding box. The position of each heartbeat relative to the starting point of the sliding window is normalized to [0, 1].
[0113] According to embodiments of this disclosure, to improve the accuracy of subsequent model training, each electrocardiogram (ECG) record sample in the sample set is sampled at the target sampling frequency and filtered to eliminate the effects of baseline drift and high-frequency noise. The segmented ECG image segments are then normalized to facilitate data processing during model training. Furthermore, the normalized ECG image segments are labeled with category labels and two-dimensional ground truth bounding box labels for subsequent loss calculation based on the labeled labels and prediction results. Thus, preprocessing each ECG record sample in the sample set improves sample quality and enhances the accuracy of model training.
[0114] According to embodiments of this disclosure, inputting a target electrocardiogram (ECG) image segment into a feature extraction network and outputting ECG features corresponding to the target ECG image segment includes: sequentially inputting the target ECG image segment into a first convolutional layer and a pooling layer to output a first feature vector; inputting the first feature vector into a residual block to obtain a second feature vector; and using a second convolutional layer to adjust the feature dimension length of the second feature vector to obtain ECG features.
[0115] The feature extraction network 310 may include a first convolutional layer, a second convolutional layer, a pooling layer, and a residual block. The temporal dimension of the electrocardiogram features is determined by the kernel size of the convolutional layer, and the feature dimension of the electrocardiogram features is determined by the stride of the pooling layer.
[0116] According to an embodiment of this disclosure, the target electrocardiogram (ECG) image segment is first input into the first convolutional layer of the feature extraction network 310 to extract features of the target ECG image segment, and then passes through a pooling layer to reduce the time dimension length of the extracted features to obtain a first feature vector.
[0117] According to embodiments of this disclosure, the first feature vector is input into the residual block to alleviate the gradient vanishing problem, resulting in a second feature vector. A second convolutional layer is then used to adjust the feature dimension length of the second feature vector to achieve the target feature dimension length D, thus obtaining the electrocardiogram features. The convolutional layer, pooling layer, and residual block in the feature extraction network 310 are one-dimensional.
[0118] Figure 4 A schematic diagram of the backbone structure of a feature extraction network according to an embodiment of the present disclosure is shown.
[0119] like Figure 4 As shown, this embodiment 400 is a backbone structure of a feature extraction network 310. The feature extraction network 310 may include a first convolutional layer (Conv1D) 410, a pooling layer (Max Pooling) 420, a residual block 430, and a second convolutional layer 440, wherein the residual block 430 includes a convolutional layer 431 and a convolutional layer 432.
[0120] According to embodiments of this disclosure, the number of residual blocks 430 can be set as needed. By introducing skip connections, the input of the residual block 430 is directly added to the output of the second convolutional layer 432 in the residual block, so that the gradient can be directly transferred from the output layer to the input layer, thereby alleviating the gradient vanishing problem.
[0121] According to embodiments of this disclosure, target electrocardiogram segments can be input as follows: Figure 4 The feature extraction network shown outputs electrocardiogram features.
[0122] According to embodiments of this disclosure, generally, the residual block 430 includes only convolutional layer 431 and convolutional layer 432, wherein convolutional layer 431 and convolutional layer 432 constitute residual connections. Figure 4 The residual block 430 shown also includes a pooling layer 433 as a whole, to indicate that a pooling layer follows every two convolutional layers in the residual connection structure. This is one embodiment. Alternatively, the residual connection structure consisting of two convolutional layers can be treated as a whole, i.e., a residual block, and a pooling layer can be connected after the residual block, i.e., one pooling layer follows one residual block. However, only some residual blocks may be followed by pooling layers.
[0123] According to embodiments of this disclosure, the target electrocardiogram segment can be defined as... ,in, The value represents the length of the time dimension, and 1 represents the length of the feature dimension. The length of the feature dimension can be increased based on the kernel size of the convolutional layer, while the length of the time dimension can be reduced based on the stride of the pooling layer.
[0124] According to embodiments of this disclosure, when the desired electrocardiogram features are reduced by a factor of 48 in the time dimension and increased by 128 in the feature dimension, ... Figure 4 Taking the backbone structure 400 of the feature extraction network 310 as an example, the kernel size of the first convolutional layer 410 is 3, the stride of the pooling layer 420 is 3, and the kernel size is 3. The kernel sizes of the convolutional layers 431 and 432 in the four residual blocks 430 are 3, the stride of the pooling layer 433 is 2, and the kernel size is 2. The kernel size of the second convolutional layer 440 is 1. Therefore, the following can be obtained in the time dimension: The ECG features have a feature dimension of 128. The second convolutional layer 440 is used to adjust the number of channels in the feature vector to the required number, that is, to adjust the feature dimension of the feature vector to the required length, such as D=128.
[0125] The number of residual blocks, step size, kernel size, and number of channels in the feature extraction network 310 can all be set as needed.
[0126] According to embodiments of this disclosure, each convolutional layer in the feature extraction network 310 is followed by a batch normalization layer and a ReLU activation layer; each residual block contains two convolutional layers and the number of channels is doubled in the first convolutional layer.
[0127] The main function of the batch normalization layer is to reduce internal covariate bias. By normalizing the output of each layer, it ensures that the inputs of each layer maintain a similar distribution, thereby accelerating the training process and improving the stability of the model. The ReLU activation layer is a non-linear activation function that enhances the expressive power of the model by introducing a non-linear mapping and can alleviate the gradient vanishing problem, allowing information in deep networks to propagate effectively backward.
[0128] According to embodiments of this disclosure, the length of the feature dimension is increased based on the kernel size of the convolutional layers in the feature extraction network to improve the accuracy of model training. The length of the time dimension is reduced based on the stride of the pooling layers in the feature extraction network to effectively reduce the size of the features while retaining important features, which helps to reduce the amount of computation and increase the robustness and translation invariance of the features. Based on the residual structure of the residual blocks in the feature extraction network, the integrity of the gradient is better maintained during training, and the network can learn more complex feature representations, thereby improving the accuracy and generalization ability of the model.
[0129] Figure 5 A schematic diagram of the structure of a decoder and encoder according to an embodiment of the present disclosure is shown.
[0130] like Figure 5 As shown, this embodiment 500 is a backbone structure of encoder 320 and decoder 330.
[0131] According to embodiments of the present disclosure, the backbone structure 510 of each coding layer in the encoder 320 includes a multi-head self-attention module 511, an add & normalize module 512, a feedforward network (FFN) 513, an add & normalize module 514, and a position coding function.
[0132] Among them, the multi-head self-attention module 511 and the summation and layer normalization module 512 form a residual connection, and the feedforward network 513 and the summation and layer normalization module 514 also form a residual connection.
[0133] The feedforward network 513 consists of two fully connected layers connected by a ReLU activation layer.
[0134] According to embodiments of this disclosure, the backbone structure 520 of each decoding layer in the decoder 330 includes a multi-head self-attention module 521, an add & normalize module 522, an MLP (multilayer perceptron) 523, a multi-heat cross-attention module 524, an add & normalize module 525, a feedforward network (FFN) 526, an add & normalize module 527, a classification prediction head (MLP) 528, a bounding box prediction head (MLP) 529, and a position encoding function.
[0135] For example, the number of heads in the multi-head self-attention module 511, multi-head self-attention module 521, and multi-head cross-attention module can be set to H=8.
[0136] Figure 6 A flowchart illustrating the use of encoder output electrocardiogram encoding features according to an embodiment of the present disclosure is shown.
[0137] like Figure 6 As shown, the method 600 includes operations S610 to S660.
[0138] In operation S610, the feature vector corresponding to the x-th coding layer and the first position code are used as the query vector and key vector, and the feature vector corresponding to the x-th coding layer is used as the value vector and input into the multi-head self-attention module of the x-th coding layer to obtain the output of the multi-head self-attention module of the x-th coding layer.
[0139] The encoder 320 may include X coding layers, where x is an integer greater than or equal to 1 and less than or equal to X. When x is greater than 1, the feature vector corresponding to the x-th coding layer is the output of the (x-1)-th coding layer. When x is 1, the feature vector corresponding to the 1st coding layer is an electrocardiogram feature.
[0140] According to embodiments of this disclosure, in each coding layer, the feature vector is combined with the first positional encoding to generate a query Q, a key K, and a value V, which are then used as inputs to the multi-head self-attention module 511. For the x-th coding layer in the encoder 320, the feature vector and the first positional encoding corresponding to the x-th coding layer are used as the query vector and the key vector, and the feature vector corresponding to the x-th coding layer is used as the value vector. That is, the sum of the feature vector and the first positional encoding corresponding to the x-th coding layer is used as the query vector Q, the sum of the feature vector and the first positional encoding corresponding to the x-th coding layer is used as the key vector K, and the feature vector corresponding to the x-th coding layer is used as the value vector V.
[0141] Among them, query vector Key vector Value vector , .
[0142] According to embodiments of this disclosure, for each decoding layer in the encoder 320, the query vector is processed in the multi-head self-attention module 511. Key vector Sum value vector Linear projection This time, by using multi-head attention, we can obtain... group , and Where H represents the number of heads in the multi-head self-attention module 511. A typical setup is This is equivalent to dividing the feature length of the feature vector, and each head in the multi-head self-attention module 511 can process D / H dimensional features; weight matrix , and These are all learnable parameters of the linear projection layer.
[0143] According to an embodiment of this disclosure, the scaled dot product attention function used by each head in the multi-head self-attention module 511 can be expressed as the following formula (4).
[0144] (4)
[0145] Where T represents the transpose operation. The first in the multi-head self-attention module 511 Output of individual heads.
[0146] According to embodiments of this disclosure, the outputs of all heads in the multi-head self-attention module 511 are concatenated along the feature dimension and fed into a weight parameter of... The linear layer produces the final output, i.e., the output of the multi-head self-attention module 511 can be expressed as the following formula (5).
[0147] (5)
[0148] in, For the multi-head self-attention module 511, the first The output of the header, with the symbol Cat indicating the concatenation function.
[0149] In operation S620, the output and feature vector of the multi-head self-attention module are added and normalized to obtain the input of the feedforward network of the x-th coding layer.
[0150] According to an embodiment of this disclosure, the multi-head self-attention module 511 and the addition and layer normalization module 512 form a residual connection. The output of the multi-head self-attention module 511 is added to the feature vector input to the multi-head self-attention module 511, and the added vector is normalized to obtain the input of the feedforward network 513 of the x-th coding layer.
[0151] In operation S630, the input of the feedforward network is input into the feedforward network, and the output of the feedforward network is obtained.
[0152] According to an embodiment of this disclosure, the input of the feedforward network 513 is fed into the feedforward network 513 to obtain the output of the feedforward network.
[0153] In operation S640, the input and output of the feedforward network are added and normalized to obtain the output of the x-th coding layer.
[0154] According to an embodiment of this disclosure, the feedforward network 513 and the addition and layer normalization module 514 form a residual connection, add the output of the feedforward network to the input of the feedforward network, and normalize the added vector to obtain the output of the x-th coding layer.
[0155] When operating S650, determine whether the second cycle number matches the number of layers in the encoder.
[0156] According to embodiments of this disclosure, if the second cycle number is inconsistent with the number of layers of the encoder, operations S610 to S640 are performed; if the second cycle number is consistent with the number of layers of the encoder, operation S660 is performed.
[0157] In operation S660, the output of the coding layer obtained in the second cycle, when the number of layers of the encoder is consistent, is determined as the electrocardiogram coding feature.
[0158] According to an embodiment of this disclosure, when the second cycle is X, the output of the coding layer obtained after this cycle is determined as the electrocardiogram coding feature.
[0159] According to embodiments of this disclosure, by inputting electrocardiogram features and a first position code into an encoder 320, the multi-head self-attention module 511 in each coding layer of the encoder 320 focuses on different positions in the input features to capture positional dependencies and improve the expressive power of the model. Furthermore, based on the residual connection formed by the multi-head self-attention module 511 and the summation layer normalization module 512 in each coding layer, and the residual connection formed by the feedforward network 513 and the summation layer normalization module 514, the gradient vanishing problem is alleviated. Thus, the electrocardiogram features are input into the encoder 320 to extract the electrocardiogram encoded features.
[0160] Figure 7 The flowchart illustrating the process of obtaining the output of the y-th decoding layer according to an embodiment of the present disclosure is shown schematically.
[0161] like Figure 7 As shown, the method 700 includes operations S710 to S760.
[0162] In operation S710, the decoder embedding and second position encoding corresponding to the y-th decoding layer are used as key vector and query vector, and the decoder embedding corresponding to the y-th decoding layer is used as value vector input into the multi-head self-attention module of the y-th decoding layer to obtain the output of the multi-head self-attention module of the y-th decoding layer.
[0163] According to embodiments of this disclosure, considering that the key K in the multi-head cross-attention module 524 of each decoding layer in the decoder 330 contains two parts of information: a content part (ECG encoded features) and a position part (first position encoding), a dual-query mode consisting of content queries and position queries is introduced in the multi-head self-attention module 521. The decoder embedding corresponding to the y-th decoding layer is the content query, and the second position encoding corresponding to the y-th decoding layer is the position query.
[0164] According to embodiments of this disclosure, in order to make the positional similarity of query vector Q and key vector K in the multi-head cross-attention module 524 of each decoding layer more consistent, the bounding box is directly learned, and the second positional code can be derived from the bounding box through the positional encoding functions of the above formulas (1) and (2).
[0165] According to embodiments of this disclosure, [the following is a record / description] For the P bounding boxes, the first A box, Given a bounding box Derived location query It can be expressed as the following formula (6).
[0166] (6)
[0167] Here, PE can represent the positional encoding function that maps floating-point numbers to D-dimensional sine embeddings. That is, the above formulas (1) and (2), where the hyperparameter T = 20 is used in the position encoding function; the symbol Cat represents the connection function; MLP represents a multilayer perceptron, that is, the MLP model 523 in each decoding layer. The 2D vector is projected to D dimensions to obtain the second positional encoding. The MLP model 523 includes two fully connected layers and the parameters are shared among all decoding layers. and Let D be the content query and position query corresponding to the y-th decoding layer, and D be the dimension of the decoder embedding and the second position encoding.
[0168] According to embodiments of this disclosure, the multi-head self-attention module 521 in each decoding layer of the decoder 330 can be used for query updating of the multi-head cross-attention model 524. For the y-th decoding layer, the input of the query vector of the multi-head self-attention module 521 in the y-th decoding layer can be expressed as the following formula (7).
[0169] (7)
[0170] According to an embodiment of this disclosure, the input of the key vector of the multi-head self-attention module 521 in the y-th decoding layer can be expressed as the following formula (8).
[0171] (8)
[0172] According to an embodiment of this disclosure, the input of the value vector of the multi-head self-attention module 521 in the y-th decoding layer can be expressed as the following formula (9).
[0173] (9)
[0174] According to an embodiment of this disclosure, the decoder corresponding to the y-th decoding layer is embedded as a key vector and the second position encoding is used as a query vector. The decoder corresponding to the y-th decoding layer is embedded as a value vector and input into the multi-head self-attention module 521 of the y-th decoding layer to obtain the output of the multi-head self-attention module 521 of the y-th decoding layer.
[0175] When operating the S720, the output of the multi-head self-attention module and the decoder embedding are added and normalized to obtain a normalized vector.
[0176] According to an embodiment of this disclosure, the multi-head self-attention module 521 and the addition and layer normalization module 522 form a residual connection. The output of the multi-head self-attention module 521 is added to the decoder embedding corresponding to the y-th decoding layer, and the vector after addition is normalized to obtain the normalized vector.
[0177] In operation S730, the normalized vector and the second position code are used as the query vector, the first position code and the ECG encoding features are used as the key vector, and the ECG encoding features are used as the value vector and input into the multi-head cross-attention module of the y-th decoding layer to obtain the output of the multi-head cross-attention module of the y-th decoding layer.
[0178] According to an embodiment of this disclosure, in the multi-head cross-attention module 524, the normalized vector and the second position vector are combined as an object query to extract target information from the electrocardiogram encoding features output by the encoder 320, thereby obtaining the output of the multi-head cross-attention module 524.
[0179] According to an embodiment of this disclosure, the input of the query vector of the multi-head cross-attention module 524 in the y-th decoding layer can be expressed as the following formula (10).
[0180] (10)
[0181] in, This is the output of the multi-head self-attention module 521 in the y-th decoding layer. The layer normalization function is represented. To query the content corresponding to the y-th decoding layer, Query the position corresponding to the y-th decoding layer.
[0182] According to an embodiment of this disclosure, the input of the key vector of the multi-head cross-attention module 524 in the y-th decoding layer can be expressed as the following formula (11).
[0183] (11)
[0184] in, Position of the ECG encoded features output by encoder 320 The feature vector at that location, This is the position code for the corresponding position x. It is the vector in the key vector corresponding to position x.
[0185] According to an embodiment of this disclosure, the input of the value vector of the multi-head cross-attention module 524 in the y-th decoding layer can be expressed as the following formula (12).
[0186] (12)
[0187] in, It is the vector in the value vector corresponding to position x.
[0188] In the S740 operation, the output of the multi-head cross-attention module and the normalized vector are added and normalized to obtain the input of the feedforward network of the y-th decoding layer.
[0189] According to an embodiment of this disclosure, the multi-head cross-attention module 524 and the addition and layer normalization module 525 form a residual connection. The output of the multi-head cross-attention module 524 is added to the normalized vector, and then the added vector is normalized to obtain the input of the feedforward network 526.
[0190] When operating the S750, the input to the feedforward network is input into the feedforward network, and the output of the feedforward network is obtained.
[0191] According to an embodiment of this disclosure, the input of the feedforward network is fed into the feedforward network 527 to obtain the output of the feedforward network.
[0192] In operation S760, the output and input of the feedforward network are added and normalized to obtain the output of the y-th decoding layer.
[0193] According to an embodiment of this disclosure, the feedforward network 526 and the addition and layer normalization module 527 form a residual connection, add the input of the feedforward network 526 and the output of the feedforward network 526, and normalize the added vector to obtain the output of the y-th decoding layer.
[0194] According to embodiments of this disclosure, for each decoding layer in decoder 330, a multi-head self-attention module 521 is used to update the query vector of the multi-head cross-attention module 524, and the multi-head cross-attention module 524 is used to detect the type and location of the heartbeat based on the similarity between the query vector and the key vector, so as to continuously approach the ground truth heartbeat by updating the query vector of the multi-head cross-attention module 524 layer by layer, thereby achieving accurate prediction of the bounding box of the heartbeat type and location.
[0195] According to embodiments of this disclosure, the decoder embedding corresponding to the first decoding layer is obtained through the following operations: randomly generating N reference heartbeats and determining the learnable embedding vectors corresponding to each of the N reference heartbeats as the decoder embeddings corresponding to the N reference heartbeats, where N is an integer greater than M; randomly selecting Q heartbeats from the M heartbeats of the target electrocardiogram segment, where Q=PN; flipping the category labels of the Q heartbeats to obtain Q reference heartbeats, where the Q reference heartbeats are labeled with noise labels after label flipping; generating label embedding vectors corresponding to each of the Q reference heartbeats based on the noise labels of the Q reference heartbeats, and determining the decoder embeddings corresponding to the Q parameter frames based on the label embedding vectors; combining the decoder embeddings corresponding to the N reference heartbeats and the decoder embeddings corresponding to the Q reference heartbeats to generate the decoder embedding corresponding to the first decoding layer.
[0196] According to embodiments of this disclosure, the initial query of the first decoding layer of the decoder 330 requires the preparation of initial decoder embeddings and initial bounding boxes, respectively. Here, the initial bounding boxes adopt a fixed box width and uniformly distributed center points. For example, the width of the initial bounding box can be 400ms.
[0197] According to embodiments of this disclosure, N reference heartbeats can be randomly generated first. To ensure that the number of predicted heartbeats output by the model is significantly greater than the possible number of heartbeats in the electrocardiogram segment, N needs to be much larger than the possible number of M.
[0198] According to embodiments of this disclosure, before performing loss calculation based on the predicted results from the output of each decoding layer of the decoder 330 to update and adjust the model parameters, it is necessary to match the predicted heartbeats with the ground truth heartbeats. Therefore, in order to avoid instability caused by matching, denoising training (DN) is introduced during the model training process. That is, for the initial query of the first decoding layer of the decoder 330, a portion of the noise query based on the ground truth heartbeat is introduced.
[0199] According to embodiments of this disclosure, the noise query also consists of a content query and a location query. The noise tag can generate a portion of the initial content query for the first decoding layer by the decoder 330, and the noise bounding box can generate a portion of the initial location query for the first decoding layer by the decoder 330.
[0200] According to embodiments of this disclosure, Q heart beats can be randomly selected from M heart beats in a target electrocardiogram segment, and the category labels of the Q heart beats can be flipped using label flipping to randomly flip the category labels of the Q heart beats onto other labels to obtain Q reference heart beats. These Q reference heart beats are marked with noise labels, which are obtained by flipping the corresponding category labels.
[0201] Hyperparameters can also be used. This controls the proportion of label flipping in Q heartbeats; during the actual application inference phase of the model, Q=0, meaning that noisy queries are introduced during actual application.
[0202] According to embodiments of this disclosure, since the decoder embedding corresponding to the first decoding layer includes vectors corresponding to Q reference heartbeats for representing noise queries, and the ground heartbeats corresponding to the Q reference heartbeats can be directly determined, the loss can be calculated directly on the prediction results corresponding to the Q reference heartbeats and the category labels of the ground heartbeats corresponding to the Q reference heartbeats, thereby mitigating the instability problem caused by matching.
[0203] According to an embodiment of this disclosure, the second position code corresponding to the first decoding layer is obtained through the following operations: randomly generating bounding boxes of N reference heartbeats; adding random noise to the two-dimensional ground truth bounding boxes of Q heartbeats to obtain bounding boxes of Q reference heartbeats; using a position coding function, generating an initial position code based on the bounding boxes of the N reference heartbeats and the bounding boxes of the Q reference heartbeats; inputting the initial position code into a multilayer perceptron, and outputting the second position code corresponding to the first decoding layer.
[0204] According to embodiments of this disclosure, bounding boxes corresponding to N reference heartbeats can be randomly generated. Random noise can be added to the two-dimensional ground truth bounding boxes of Q heartbeats to obtain noisy bounding boxes, i.e., the bounding boxes of the Q reference heartbeats. An initial position code can be generated first using a position coding function, and then a second position code corresponding to the first decoding layer can be obtained using an MLP (Multilayer Perceptron) 523.
[0205] According to embodiments of this disclosure, a noisy bounding box can be generated based on a two-dimensional truth bounding box using a center-moving method. The random generation of the noisy bounding box can be controlled by setting a noise scale λ as needed, and random noise is added to the center of the two-dimensional truth bounding box. To achieve central movement and ensure This ensures that the center of the moved box remains within the original bounding box, where w refers to the width of the corresponding two-dimensional ground truth bounding box. Further consideration is given to Contrastive Denoising Training (CDN) to help the model avoid repeated outputs of the same prediction target.
[0206] According to embodiments of this disclosure, in the comparison denoising training, by setting... and Two different noise scales are used to generate positive and negative queries, with the positive query having a noise level less than 1. The noise scale, and expects to reconstruct its corresponding truth box, negative queries have a noise scale greater than and less than The noise scale is expected to be predicted as "Non-obj" (non-target), where the smaller This approach is often adopted because hard samples that are closer to the 2D ground truth bounding boxes are more conducive to improving performance.
[0207] For example, for noise reduction training, it can be done by setting... , and To be used to control noise levels.
[0208] According to embodiments of this disclosure, since the initial content query generated based on the noise label and the initial position query generated based on the noise bounding box can reconstruct the corresponding prediction result from the noise label and the noise bounding box, the prediction result corresponding to the noise query can bypass matching and directly calculate its loss with the corresponding ground truth beat, thus alleviating the instability problem caused by matching.
[0209] According to embodiments of this disclosure, loss calculations are performed on the category labels and two-dimensional ground truth bounding box labels of M heartbeats in the target ECG image segment, respectively, and the classification prediction results and predicted bounding boxes of P reference heartbeats, to obtain classification loss values and bounding box loss values. This includes: filling the ground truth results of NM non-target heartbeats into an initial ground truth arrangement to obtain a target ground truth arrangement; sorting the prediction results of the N reference heartbeats to obtain multiple prediction arrangements; for each prediction arrangement, calculating the classification prediction probability value, intersection-over-union ratio (IoU), and L1 norm based on the target ground truth arrangement and the prediction arrangement; calculating the matching cost corresponding to the prediction arrangement based on the classification prediction probability value, IoU, and L1 norm; and determining the arrangement with the smallest corresponding matching cost among the multiple prediction arrangements as the target prediction arrangement.
[0210] The initial truth set includes the truth results of each of the M heart beats. The truth results of each of the M heart beats in the target ECG segment can be obtained from the target truth set. The target ground truth arrangement is obtained from the data. It includes the ground truth results of each of the N heartbeats. The ground truth results include the class label and the two-dimensional ground truth bounding box label corresponding to the heartbeat. The arrangement of the ground truth results of each of the N heartbeats in the target ground truth arrangement is fixed. The prediction result includes the classification prediction result (Class) and the prediction bounding box (Box or New Boxes). The classification prediction probability value represents the probability that the corresponding class label in the prediction arrangement and the target ground truth arrangement is consistent with the classification prediction result.
[0211] According to the embodiments of this disclosure, both the content query and the location query of the decoder 330 are for P reference heartbeats. The classification prediction results and prediction bounding boxes obtained by the output prediction of each decoding layer in the decoder 330 are also for P reference heartbeats. The P reference heartbeats include Q reference heartbeats generated from the target ECG image segment. Since the target ECG image segment includes M heartbeats, P is much larger than M. And the prediction results corresponding to the Q reference heartbeats can directly determine the heartbeats corresponding to the target ECG image segment. That is, the prediction results corresponding to the Q reference heartbeats do not need to be matched. Therefore, the prediction results corresponding to N=PQ reference heartbeats need to be matched first. In order to ensure that each prediction result can correspond one-to-one with the true value result during the matching process, the true value results of NM non-target heartbeats (Non-obj) need to be filled into the initial true value arrangement to obtain the target true value arrangement.
[0212] According to embodiments of this disclosure, such as Figure 3 In the Matching 340 shown, the left side is the Predictions and the right side is the Ground Truth.
[0213] According to embodiments of this disclosure, since the prediction results corresponding to these N reference heartbeats are not directly paired with the ground truth results, during training, the loss needs to be calculated based on the optimal bipartite matching between the target ground truth arrangement and multiple prediction arrangements.
[0214] According to embodiments of this disclosure, the Hungarian algorithm can be used to efficiently compute the optimal bipartite matching between two sets from the cost matrix of objects, that is, to find the N elements with the minimum matching cost. The predicted arrangement can be expressed as the following formula (13).
[0215] (13)
[0216] in, It is the truth result in the target truth value permutation Predicted results in the predicted arrangement The cost of pairwise matching between them It can be represented as a predictive permutation.
[0217] According to the embodiments of this disclosure, the prediction results corresponding to N reference heartbeats are arranged to obtain multiple prediction arrangements. The matching cost is calculated for each prediction arrangement and the target true value arrangement. Thus, the prediction arrangement with the minimum matching cost can be determined by the above formula (13) for loss calculation with the true value results in the target true value arrangement.
[0218] According to embodiments of this disclosure, the matching cost includes positional cost and classification cost. For a given prediction permutation, the prediction result... Define the predicted bounding box as ,definition The classification prediction probability value of the class is Among them, they will be classified as The negative probability of a class is used as the classification cost, while the location cost is determined using the negative one-dimensional generalized intersection over union (GIoU) and L1 norm of the bounding box.
[0219] According to embodiments of this disclosure, for a predicted arrangement and a target true value arrangement, the crossover ratio corresponding to the predicted arrangement can be calculated by the following formula (14).
[0220] (14)
[0221] According to embodiments of this disclosure, for a predicted permutation and a target true permutation, the L1 norm corresponding to the predicted permutation can be calculated using the following formula (15).
[0222] (15)
[0223] in, Indicates the length of the box. This represents the length of the smallest interval that can cover two bounding boxes.
[0224] According to embodiments of this disclosure, the matching cost corresponding to a certain predicted permutation can be calculated based on the classification prediction probability value, intersection-union ratio, and L1 norm. The formula for calculating the matching cost can be expressed as the following formula (16).
[0225] (16)
[0226] in, , , For hyperparameters, This indicates the case where the corresponding truth value is not a non-target heartbeat. The value is 1 in all cases and 0 in all other cases.
[0227] According to an embodiment of this disclosure, the matching cost of multiple predicted permutations is calculated using the above formula (16) so as to determine the permutation with the minimum matching cost as the target predicted permutation.
[0228] According to embodiments of this disclosure, for the prediction results corresponding to N reference heartbeats, matching is required before loss calculation to avoid large errors in the calculated loss value under mismatch conditions. The matching cost is calculated for each prediction arrangement and the target true value arrangement. Since the smaller the matching cost, the higher the probability of matching between the prediction arrangement and the target true value arrangement, the prediction arrangement with the smallest matching cost is determined as the target prediction arrangement. In order to perform loss calculation between the target prediction arrangement and the target true value arrangement, large errors in loss calculation due to matching problems are avoided.
[0229] According to embodiments of this disclosure, the above-mentioned model training method further includes: calculating a first classification loss value based on the predicted probability value corresponding to the target predicted arrangement using a classification loss function; calculating a first bounding box loss value based on the intersection-union ratio (IU) and L1 norm corresponding to the target predicted arrangement using a bounding box loss function; calculating a classification prediction probability value corresponding to the Q reference heartbeats based on the classification prediction results of each of the Q reference heartbeats and the category labels of each of the Q heartbeats corresponding to the Q reference heartbeats; calculating a second classification loss value based on the classification prediction probability value corresponding to the Q reference heartbeats using a classification loss function; calculating the intersection-union ratio (IU) and L1 norm corresponding to the Q reference heartbeats based on the predicted bounding boxes of each of the Q reference heartbeats and the two-dimensional ground truth bounding box labels of each of the Q reference heartbeats; and calculating a second bounding box loss value based on the intersection-union ratio (IU) and L1 norm corresponding to the Q reference heartbeats using a bounding box loss function.
[0230] The classification loss value includes a first classification loss value and a second classification loss value, and the bounding box loss value includes a first bounding box loss value and a second bounding box loss value.
[0231] According to embodiments of this disclosure, since the prediction results corresponding to P reference heartbeats include prediction results corresponding to N randomly generated reference heartbeats and prediction results corresponding to Q reference heartbeats generated based on target ECG segments, the loss value corresponding to N reference heartbeats can be calculated based on the target prediction permutation, and the loss value corresponding to Q reference heartbeats can be calculated based on the prediction results of Q reference heartbeats and their corresponding true values.
[0232] According to embodiments of this disclosure, once the target prediction order is determined, a first classification loss value can be calculated using a classification loss function based on the prediction probability value corresponding to the target prediction order. This classification loss function can be expressed as the following formula (17).
[0233] (17)
[0234] Among them, In this case, the weights adopted In other cases, .
[0235] According to embodiments of this disclosure, the first bounding box loss value can be calculated using the bounding box loss function based on the intersection-union ratio and L1 norm corresponding to the target prediction arrangement. The bounding box loss function can be expressed as the following formula (18).
[0236] (18)
[0237] in, and It is a hyperparameter that adjusts the loss weights. The bounding box loss function is a linear combination of the L1 norm loss and the one-dimensional GIoU loss.
[0238] According to the embodiments of this disclosure, based on the classification prediction results of each of the Q reference heartbeats and the category labels in the true value results of each of the Q reference heartbeats, the classification prediction probability value corresponding to the Q reference heartbeats can be calculated. Using the classification loss function, that is, through the above formula (17), the second classification loss value can be calculated based on the classification prediction probability value corresponding to the Q reference heartbeats.
[0239] According to embodiments of this disclosure, based on the predicted bounding boxes of the Q reference frames and the two-dimensional ground truth bounding box labels of the Q frames corresponding to the Q reference frames, the intersection-union ratio (IU) and L1 norm corresponding to the Q reference frames can be calculated using the above formulas (14) and (15). Using the bounding box loss function, i.e., through the above formula (18), the second bounding box loss value can be calculated based on the IU and L1 norm corresponding to the Q reference frames.
[0240] According to embodiments of this disclosure, considering a linear combination of classification loss and bounding box loss, the total loss can be calculated using the following formula (19).
[0241] (19)
[0242] in, This is the classification loss coefficient.
[0243] According to the embodiments of this disclosure, since the Q reference heartbeats can directly determine the category label and the two-dimensional ground truth bounding box label in the corresponding true result, there is no need to perform matching first. The second classification loss value and the second bounding box loss value can be calculated directly using the above formulas (17) and (18) based on the Q reference heartbeats and the corresponding Q heartbeats. This allows the parameters of the model to be adjusted using the second classification loss value and the second bounding box loss value, thereby alleviating the problem of unstable matching to a certain extent.
[0244] According to embodiments of this disclosure, during the training of the atrial fibrillation heartbeat detection model, an adaptive moment estimation algorithm (Adam optimizer) can be used to optimize the model. Similarly, grid search and cross-validation can be used to determine the hyperparameters involved in the model for fine-tuning. The cost coefficient of the bipartite matching in the above formula (16) is... The loss function coefficients in the above formula (19) .
[0245] According to embodiments of this disclosure, the initial learning rate of the model It can be set to 0.0001, and the batch size can be set to 64. The change in learning rate with the number of training cycles can be expressed by the following formula (20).
[0246] (20)
[0247] in, This is the number of training cycles completed so far. This refers to the total number of training rounds. In this disclosure, It can be set to 30.
[0248] Figure 8 A flowchart illustrating an atrial fibrillation heart rate detection method according to an embodiment of the present disclosure is shown schematically.
[0249] like Figure 8 As shown, the method 800 includes operations S810 and S820.
[0250] In operation S810, the ECG record to be tested is sampled to the target sampling frequency, and the ECG record to be tested at the target sampling frequency is divided into multiple ECG segments to be tested according to the target time period.
[0251] According to the embodiments of this disclosure, since the obtained ECG image segments to be detected need to be input into the atrial fibrillation heartbeat detection model, in order to improve the accuracy of the output, the ECG records to be detected need to be sampled to the target sampling frequency and segmented according to the target time period. The sampling frequency and time length of the samples used in the training process of the atrial fibrillation heartbeat detection model are the target sampling frequency and the target time period.
[0252] When operating the S820, for each ECG image segment to be detected, the ECG image segment to be detected is input into the atrial fibrillation heartbeat detection model, and the classification prediction results and prediction bounding boxes corresponding to each heartbeat in the ECG image segment to be detected are output.
[0253] According to embodiments of this disclosure, the atrial fibrillation heartbeat detection model is obtained by performing the above-described operations S210 to S221. The classification prediction result can indicate whether the heartbeat is an atrial fibrillation heartbeat, a non-atrial fibrillation heartbeat, or a non-target heartbeat; that is, the classification prediction result can be used to determine the atrial fibrillation heartbeat in the ECG segment to be detected. The predicted bounding box can be used to determine the location of the heartbeat in the ECG segment to be detected.
[0254] According to embodiments of this disclosure, the use of the atrial fibrillation heartbeat detection model can provide heartbeat-level prediction, effectively avoiding the feature ambiguity problem caused by the simultaneous inclusion of atrial fibrillation and non-atrial fibrillation segments in electrocardiogram segments, thereby achieving accurate and rapid detection of atrial fibrillation heartbeats in electrocardiogram segments and effectively locating atrial fibrillation heartbeats.
[0255] According to embodiments of this disclosure, during the training of the atrial fibrillation heartbeat detection model, a localization task is introduced on top of the classification task to fully extract the central beat rhythm location information of the electrocardiogram segment. This helps the model to make more accurate atrial fibrillation heartbeat detection based on global rhythm location information, ensuring the model's generalization ability in real-world application scenarios and achieving robust atrial fibrillation heartbeat detection. Furthermore, during the training of the atrial fibrillation heartbeat detection model, the location query of the decoder is constructed using the coordinates of the two-dimensional ground truth bounding box representing the heartbeat location. The bounding box is updated iteratively layer by layer by the decoder, thereby effectively locating the atrial fibrillation heartbeat. During the training of the atrial fibrillation heartbeat detection model, denoising training is also introduced to stabilize bipartite matching. A contrastive denoising mechanism is used, adding positive and negative noise samples with the same ground truth value at two different noise scales to help the model avoid repeated detection of the same heartbeat. At the same time, this disclosure adopts an end-to-end implementation approach, implicitly performing the heartbeat localization task during atrial fibrillation heartbeat detection, avoiding the multi-step processing of locating and segmenting heartbeats first and then performing atrial fibrillation detection in the prior art.
[0256] Based on the above model training method, this disclosure also provides a model training apparatus. The following will combine... Figure 9 The device is described in detail.
[0257] Figure 9 A schematic block diagram of a model training apparatus according to an embodiment of the present disclosure is shown.
[0258] like Figure 9As shown, the model training device 900 of this embodiment includes a preprocessing module 910, a first input module 911, a construction module 912, a second input module 913, a third input module 914, a fourth input module 915, an update module 916, a fifth input module 917, a first acquisition module 918, an adjustment module 919, and a second acquisition module 920.
[0259] The preprocessing module 910 is used to preprocess each electrocardiogram (ECG) record sample in the sample set to obtain a target ECG image segment. The target ECG image segment includes M heartbeats, where M is an integer greater than or equal to 1. Each heartbeat is labeled with a category label and a two-dimensional truth bounding box label. The category label is used to characterize whether the heartbeat is an atrial fibrillation heartbeat. In one embodiment, the preprocessing module 910 can be used to perform the operation S210 described above, which will not be repeated here.
[0260] The first input module 911 is used to input the target electrocardiogram (ECG) image segment into the feature extraction network and output the ECG features corresponding to the target ECG image segment. In one embodiment, the first input module 911 can be used to perform the operation S211 described above, which will not be repeated here.
[0261] The construction module 912 is used to construct a first position code corresponding to the electrocardiogram features using a position encoding function. In one embodiment, the construction module 912 can be used to perform the operation S212 described above, which will not be repeated here.
[0262] The second input module 913 is used to input the electrocardiogram features and the first position code into the encoder and output the electrocardiogram encoded features. In one embodiment, the second input module 913 can be used to perform the operation S213 described above, which will not be repeated here.
[0263] The third input module 914 is used to input the electrocardiogram encoding features, the first position encoding, the decoder embedding corresponding to the y-th decoding layer, and the second position encoding into the y-th decoding layer when it is determined that the first loop round and the number of layers of the decoder are inconsistent, to obtain the output of the y-th decoding layer. The decoder includes Y decoding layers, where y is an integer greater than or equal to 1 and less than or equal to Y. The decoder embedding corresponding to the y-th decoding layer is the output of the (y-1)-th decoding layer, and the second position encoding corresponding to the y-th decoding layer is constructed based on P bounding boxes updated through the output of the (y-1)-th decoding layer. In one embodiment, the third input module 914 can be used to perform the operation S214 described above, which will not be repeated here.
[0264] The fourth input module 915 is used to input the output of the y-th decoding layer into the bounding box prediction header of the y-th decoding layer, and output the offset corresponding to each of the P bounding boxes. In one embodiment, the fourth input module 915 can be used to perform the operation S215 described above, which will not be repeated here.
[0265] The update module 916 is used to update the P bounding boxes using the offsets corresponding to each of the P bounding boxes, to obtain the P predicted bounding boxes updated by the output of the y-th decoding layer. In one embodiment, the update module 916 can be used to perform the operation S216 described above, which will not be repeated here.
[0266] The fifth input module 917 is used to input the output of the y-th decoding layer into the classification prediction head of the y-th decoding layer, and output the classification prediction results of each of the P reference heartbeats corresponding to the decoder embedding. The prediction bounding boxes correspond one-to-one with the reference heartbeats, and the prediction bounding boxes are used to characterize the position of the reference heartbeats in the target electrocardiogram segment. In one embodiment, the fifth input module 917 can be used to perform the operation S217 described above, which will not be repeated here.
[0267] The first acquisition module 918 is used to perform loss calculations on the category labels and two-dimensional ground truth bounding box labels of each of the M heartbeats in the target electrocardiogram segment, respectively, and the classification prediction results and predicted bounding boxes of each of the P reference heartbeats, to obtain classification loss values and bounding box loss values. In one embodiment, the first acquisition module 918 can be used to perform the operation S218 described above, which will not be repeated here.
[0268] The adjustment module 919 is used to adjust the model parameters of the model to be trained based on the classification loss value and the bounding box loss value, to obtain the adjusted model, wherein the adjusted model includes a feature extraction network, an encoder, and a decoder. In one embodiment, the adjustment module 919 can be used to perform the operation S219 described above, which will not be repeated here.
[0269] The second acquisition module 920 is used to obtain an atrial fibrillation heartbeat detection model when the number of cycles in the first loop matches the number of layers in the decoder. In one embodiment, the second acquisition module 920 can be used to perform the operation S221 described above, which will not be repeated here.
[0270] According to embodiments of this disclosure, the preprocessing module 910 includes a sampling unit, a filtering unit, a segmentation unit, a first acquisition unit, and a labeling unit.
[0271] The sampling unit is used to sample each electrocardiogram record in the sample set to the target sampling frequency.
[0272] The filtering unit is used to filter each electrocardiogram recording sample at the target sampling frequency to obtain the filtered electrocardiogram recording sample.
[0273] The segmentation unit is used to divide each filtered electrocardiogram record sample into multiple electrocardiogram segments according to the target time period.
[0274] The first acquisition unit is used to normalize multiple electrocardiogram (ECG) image segments to obtain normalized ECG image segments.
[0275] The annotation unit is used to annotate the normalized electrocardiogram (ECG) image segments with category labels and two-dimensional truth bounding box labels to obtain the target ECG image segment.
[0276] According to embodiments of this disclosure, the feature extraction network includes a first convolutional layer, a second convolutional layer, a pooling layer, and a residual block, and the first input module 911 includes a first input unit, a second input unit, and an adjustment unit.
[0277] The first input unit is used to sequentially input the target electrocardiogram image segment into the first convolutional layer and the pooling layer, and output the first feature vector.
[0278] The second input unit is used to input the first feature vector into the residual block to obtain the second feature vector.
[0279] The adjustment unit is used to adjust the feature dimension length of the second feature vector using the second convolutional layer to obtain the electrocardiogram (ECG) features. The time dimension length of the ECG features is determined by the kernel size of the convolutional layer, and the feature dimension length of the ECG features is determined by the stride of the pooling layer.
[0280] According to embodiments of this disclosure, the second input module 913 includes a third input unit, a second obtaining unit, a fourth input unit, a third obtaining unit, and a first determining unit.
[0281] The third input unit is used to, when the second loop cycle is inconsistent with the number of layers in the encoder, take the feature vector corresponding to the x-th coding layer and the first position code as the query vector and the key vector, and input the feature vector corresponding to the x-th coding layer as the value vector into the multi-head self-attention module of the x-th coding layer to obtain the output of the multi-head self-attention module of the x-th coding layer. Here, the encoder includes X coding layers, and x is an integer greater than or equal to 1 and less than or equal to X; when x is greater than 1, the feature vector corresponding to the x-th coding layer is the output of the (x-1)-th coding layer; when x is 1, the feature vector corresponding to the 1st coding layer is the electrocardiogram feature.
[0282] The second acquisition unit is used to add and normalize the output of the multi-head attention module and the feature vector to obtain the input of the feedforward network of the x-th coding layer.
[0283] The fourth input unit is used to input the input of the feedforward network into the feedforward network to obtain the output of the feedforward network.
[0284] The third acquisition unit is used to add and normalize the input and output of the feedforward network to obtain the output of the x-th coding layer.
[0285] The first determining unit determines the output of the coding layer obtained in the second cycle, when the number of layers of the encoder is consistent, as the electrocardiogram coding feature.
[0286] According to embodiments of this disclosure, the third input module 914 includes a fifth input unit, a fourth obtaining unit, a sixth input unit, a fifth obtaining unit, a seventh input unit, and a sixth obtaining unit.
[0287] The fifth input unit is used to embed the decoder corresponding to the y-th decoding layer and the second position encoding as the key vector and query vector, and to input the decoder embedding corresponding to the y-th decoding layer as the value vector into the multi-head self-attention module of the y-th decoding layer to obtain the output of the multi-head self-attention module of the y-th decoding layer.
[0288] The fourth acquisition unit is used to add and normalize the output of the multi-head self-attention module and the decoder embedding to obtain a normalized vector.
[0289] The sixth input unit is used to input the normalized vector and the second position code as the query vector, the first position code and the ECG encoding feature as the key vector, and the ECG encoding feature as the value vector into the multi-head cross-attention module of the y-th decoding layer to obtain the output of the multi-head cross-attention module of the y-th decoding layer.
[0290] The fifth acquisition unit is used to add and normalize the output of the multi-head cross-attention module and the normalized vector to obtain the input of the feedforward network of the y-th decoding layer.
[0291] The seventh input unit is used to input the input of the feedforward network into the feedforward network to obtain the output of the feedforward network.
[0292] The sixth obtaining unit is used to add and normalize the output and input of the feedforward network to obtain the output of the y-th decoding layer.
[0293] According to embodiments of this disclosure, the first obtaining module 918 includes a filling unit, a sorting unit, a first calculation unit, a second calculation unit, and a second determining unit.
[0294] The filling unit is used to fill the initial truth value arrangement with the truth values of NM non-target heartbeats to obtain the target truth value arrangement. The initial truth value arrangement includes the truth values of each of the M heartbeats, and the target truth value arrangement includes the truth values of each of the N heartbeats. The truth values include the category label and the two-dimensional truth bounding box label corresponding to the heartbeat. The arrangement of the truth values of each of the N heartbeats in the target truth value arrangement is fixed.
[0295] The sorting unit is used to sort the prediction results of N reference frames to obtain multiple prediction arrangements, wherein the prediction results include classification prediction results and prediction bounding boxes.
[0296] The first calculation unit is used to calculate the classification prediction probability value, intersection-union ratio, and L1 norm for each prediction permutation based on the target true value permutation and the prediction permutation. The classification prediction probability value represents the probability that the corresponding category label in the prediction permutation and the target true value permutation is consistent with the classification prediction result.
[0297] The second calculation unit is used to calculate the matching cost corresponding to the predicted arrangement based on the classification prediction probability value, intersection-union ratio and L1 norm corresponding to the predicted arrangement.
[0298] The second determining unit is used to determine the arrangement with the minimum matching cost among multiple predicted arrangements as the target predicted arrangement.
[0299] According to embodiments of this disclosure, the first obtaining module 918 further includes a third calculation unit, a fourth calculation unit, a fifth calculation unit, a sixth calculation unit, a seventh calculation unit, and an eighth calculation unit.
[0300] The third calculation unit is used to calculate the first classification loss value based on the predicted probability value corresponding to the target prediction ranking using the classification loss function.
[0301] The fourth calculation unit is used to calculate the first bounding box loss value using the bounding box loss function, based on the intersection-union ratio and L1 norm corresponding to the target prediction arrangement.
[0302] The fifth calculation unit is used to calculate the classification prediction probability value corresponding to the Q reference heartbeats based on the classification prediction results of each of the Q reference heartbeats and the category labels of each of the Q heartbeats corresponding to the Q reference heartbeats.
[0303] The sixth calculation unit is used to calculate the second classification loss value based on the classification prediction probability values corresponding to the Q reference heartbeats using the classification loss function.
[0304] The seventh calculation unit is used to calculate the intersection-union ratio and L1 norm corresponding to the Q reference center frames based on the predicted bounding boxes of the Q reference center frames and the two-dimensional ground truth bounding box labels of the Q center frames corresponding to the Q reference center frames.
[0305] The eighth calculation unit is used to calculate the second bounding box loss value using the bounding box loss function, based on the intersection-union ratio and L1 norm corresponding to the Q reference core beats.
[0306] According to embodiments of this disclosure, any and more of the modules among the preprocessing module 910, the first input module 911, the construction module 912, the second input module 913, the third input module 914, the fourth input module 915, the update module 916, the fifth input module 917, the first obtaining module 918, the adjustment module 919, and the second obtaining module 920 can be combined into one module, or any one of these modules can be split into multiple modules. Alternatively, at least some of the functions of one or more of these modules can be combined with at least some of the functions of other modules and implemented in one module. According to embodiments of this disclosure, at least one of the preprocessing module 910, the first input module 911, the construction module 912, the second input module 913, the third input module 914, the fourth input module 915, the update module 916, the fifth input module 917, the first obtaining module 918, the adjustment module 919, and the second obtaining module 920 can be at least partially implemented as hardware circuitry, such as a field-programmable gate array (FPGA), a programmable logic array (PLA), a system-on-a-chip, a system-on-a-substrate, a system-on-package, an application-specific integrated circuit (ASIC), or any other reasonable means of integrating or packaging the circuitry, or implemented in software, hardware, or firmware, or in any suitable combination of any of these three implementation methods. Alternatively, at least one of the preprocessing module 910, the first input module 911, the construction module 912, the second input module 913, the third input module 914, the fourth input module 915, the update module 916, the fifth input module 917, the first obtaining module 918, the adjustment module 919, and the second obtaining module 920 can be at least partially implemented as a computer program module, which can perform corresponding functions when the computer program module is run.
[0307] Based on the above-described method for detecting atrial fibrillation heartbeats, this disclosure also provides an atrial fibrillation heartbeat detection device. The following will be combined with... Figure 10 The device is described in detail.
[0308] Figure 10 A schematic block diagram of an atrial fibrillation heart rate detection device according to an embodiment of the present disclosure is shown.
[0309] like Figure 10 As shown, the atrial fibrillation heart rate detection device 1000 of this embodiment includes a sampling segmentation module 1010 and a sixth input module 1020.
[0310] The sampling segmentation module 1010 is used to sample the ECG record to be detected to the target sampling frequency, and to segment the ECG record to be detected at the target sampling frequency into multiple ECG segments to be detected according to the target time period. In one embodiment, the sampling segmentation module 1010 can be used to perform the operation S810 described above, which will not be repeated here.
[0311] The sixth input module 1020 is used to input each of the ECG segments to be detected into the atrial fibrillation beat detection model, and output the classification prediction results and prediction bounding boxes corresponding to each beat in the ECG segment to be detected. The classification prediction results are used to determine the atrial fibrillation beats in the ECG segment to be detected. In one embodiment, the input module 1020 can be used to perform the operation S820 described above, which will not be repeated here.
[0312] According to embodiments of this disclosure, any plurality of modules in the sampling segmentation module 1010 and the sixth input module 1020 can be combined into one module, or any one of these modules can be split into multiple modules. Alternatively, at least a portion of the functionality of one or more of these modules can be combined with at least a portion of the functionality of other modules and implemented in one module. According to embodiments of this disclosure, at least one of the sampling segmentation module 1010 and the sixth input module 1020 can be at least partially implemented as hardware circuitry, such as a field-programmable gate array (FPGA), a programmable logic array (PLA), a system-on-a-chip, a system-on-a-substrate, a system-on-package, an application-specific integrated circuit (ASIC), or implemented in hardware or firmware by any other reasonable means of integrating or packaging the circuitry, or implemented in any one of software, hardware, and firmware methods, or in a suitable combination of any of these. Alternatively, at least one of the sampling segmentation module 1010 and the sixth input module 1020 can be at least partially implemented as a computer program module, which can perform corresponding functions when the computer program module is run.
[0313] Figure 11 A block diagram schematically illustrates an electronic device suitable for implementing a model training method and an atrial fibrillation heartbeat detection method according to embodiments of the present disclosure.
[0314] like Figure 11As shown, an electronic device 1100 according to an embodiment of the present disclosure includes a processor 1101, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1102 or a program loaded from a storage portion 1108 into a random access memory (RAM) 1103. The processor 1101 may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or an associated chipset and / or a special-purpose microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 1101 may also include onboard memory for caching purposes. The processor 1101 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present disclosure.
[0315] RAM 1103 stores various programs and data required for the operation of electronic device 1100. Processor 1101, ROM 1102, and RAM 1103 are interconnected via bus 1104. Processor 1101 performs various operations of the method flow according to embodiments of the present disclosure by executing programs in ROM 1102 and / or RAM 1103. It should be noted that the programs may also be stored in one or more memories other than ROM 1102 and RAM 1103. Processor 1101 may also perform various operations of the method flow according to embodiments of the present disclosure by executing programs stored in said one or more memories.
[0316] According to embodiments of this disclosure, the electronic device 1100 may further include an input / output (I / O) interface 1105, which is also connected to a bus 1104. The electronic device 1100 may also include one or more of the following components connected to the input / output (I / O) interface 1105: an input section 1106 including a keyboard, mouse, etc.; an output section 1107 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 1108 including a hard disk, etc.; and a communication section 1109 including a network interface card such as a LAN card, modem, etc. The communication section 1109 performs communication processing via a network such as the Internet. A drive 1110 is also connected to the input / output (I / O) interface 1105 as needed. A removable medium 1111, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on the drive 1110 as needed so that computer programs read from it can be installed into the storage section 1108 as needed.
[0317] This disclosure also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or it may exist independently and not assembled into the device / apparatus / system. The computer-readable storage medium carries one or more programs that, when executed, implement the method according to the embodiments of this disclosure.
[0318] According to embodiments of this disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium, such as including, but not limited to: portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this disclosure, the computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. For example, according to embodiments of this disclosure, the computer-readable storage medium may include ROM 1102 and / or RAM 1103 and / or one or more memories other than ROM 1102 and RAM 1103 described above.
[0319] Embodiments of this disclosure also include a computer program product comprising a computer program containing program code for performing the methods shown in the flowchart. When the computer program product is run on a computer system, the program code enables the computer system to implement the model training method and atrial fibrillation heartbeat detection method provided in the embodiments of this disclosure.
[0320] When the computer program is executed by the processor 1101, it performs the functions defined in the system / apparatus of this disclosure embodiments. According to embodiments of this disclosure, the systems, apparatuses, modules, units, etc., described above can be implemented by computer program modules.
[0321] In one embodiment, the computer program may rely on a tangible storage medium such as an optical storage device or a magnetic storage device. In another embodiment, the computer program may also be transmitted and distributed in the form of signals over a network medium, and may be downloaded and installed via the communication section 1109, and / or installed from the removable medium 1111. The program code contained in the computer program can be transmitted using any suitable network medium, including but not limited to: wireless, wired, etc., or any suitable combination thereof.
[0322] In such an embodiment, the computer program can be downloaded and installed from a network via communication section 1109, and / or installed from removable medium 1111. When the computer program is executed by processor 1101, it performs the functions defined in the system of this disclosure embodiment. According to embodiments of this disclosure, the systems, devices, apparatuses, modules, units, etc., described above can be implemented by computer program modules.
[0323] According to embodiments of this disclosure, program code for executing the computer programs provided in embodiments of this disclosure can be written in any combination of one or more programming languages. Specifically, these computational programs can be implemented using high-level procedural and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages include, but are not limited to, languages such as Java, C++, Python, "C", or similar programming languages. The program code can execute entirely on a user's computing device, partially on a user's device, partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).
[0324] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0325] Those skilled in the art will understand that the features described in the various embodiments of this disclosure can be combined and / or combined in various ways, even if such combinations or combinations are not explicitly described in this disclosure. In particular, the features described in the various embodiments of this disclosure can be combined and / or combined in various ways without departing from the spirit and teachings of this disclosure. All such combinations and / or combinations fall within the scope of this disclosure.
[0326] The embodiments of this disclosure have been described above. However, these embodiments are for illustrative purposes only and are not intended to limit the scope of this disclosure. Although various embodiments have been described above, this does not mean that the measures in the various embodiments cannot be used advantageously in combination. Various substitutions and modifications can be made by those skilled in the art without departing from the scope of this disclosure, and all such substitutions and modifications should fall within the scope of this disclosure.
Claims
1. A model training method, comprising: Each electrocardiogram (ECG) record sample in the sample set is preprocessed to obtain a target ECG image segment, wherein the target ECG image segment includes M heart beats, where M is an integer greater than or equal to 1, and each heart beat is labeled with a category label and a two-dimensional truth bounding box label. The category label is used to characterize whether the heart beat is an atrial fibrillation heart beat. The target electrocardiogram (ECG) image segment is input into the feature extraction network, and the ECG features corresponding to the target ECG image segment are output. Using a positional encoding function, a first positional code corresponding to the electrocardiogram features is constructed; The electrocardiogram features and the first position code are input into the encoder, and the electrocardiogram encoded features are output. Repeat the following steps until the number of layers in the first loop matches the number of layers in the decoder, to obtain the atrial fibrillation heartbeat detection model: If it is determined that the first loop iteration is inconsistent with the number of layers in the decoder, The electrocardiogram encoding features, the first position encoding, the decoder embedded corresponding to the y-th decoding layer, and the second position encoding are input into the y-th decoding layer to obtain the output of the y-th decoding layer. The decoder includes Y decoding layers, where y is an integer greater than or equal to 1 and less than or equal to Y. The decoder embedded corresponding to the y-th decoding layer is the output of the (y-1)-th decoding layer. The second position encoding corresponding to the y-th decoding layer is constructed based on P bounding boxes updated through the output of the (y-1)-th decoding layer, where P is an integer greater than M. The output of the y-th decoding layer is input into the bounding box prediction header of the y-th decoding layer, and the offset corresponding to each of the P bounding boxes is output. Using the offsets corresponding to each of the P bounding boxes, update the P bounding boxes to obtain the P predicted bounding boxes updated by the output of the y-th decoding layer; The output of the y-th decoding layer is input into the classification prediction head of the y-th decoding layer, and the classification prediction results of each of the P reference heartbeats corresponding to the decoder embedding are output. The prediction bounding box corresponds one-to-one with the reference heartbeat, and the prediction bounding box is used to characterize the position of the reference heartbeat in the target electrocardiogram segment. The category labels and two-dimensional ground truth bounding box labels of each of the M heartbeats in the target electrocardiogram segment are respectively compared with the classification prediction results and prediction bounding boxes of each of the P reference heartbeats to calculate the loss value and the bounding box loss value. Based on the classification loss value and the bounding box loss value, the model parameters of the model to be trained are adjusted to obtain the adjusted model, wherein the adjusted model includes a feature extraction network, an encoder, and a decoder.
2. The method according to claim 1, wherein, The preprocessing of each electrocardiogram (ECG) record sample in the sample set to obtain the target ECG segment includes: Each electrocardiogram record in the sample set is sampled at the target sampling frequency; Each electrocardiogram (ECG) recording sample at the target sampling frequency is filtered to obtain the filtered ECG recording sample. Each filtered electrocardiogram (ECG) record sample is divided into multiple ECG segments according to the target time period; The multiple electrocardiogram (ECG) image segments are normalized to obtain normalized ECG image segments; and The normalized electrocardiogram (ECG) image segments are labeled with category labels and two-dimensional truth bounding box labels to obtain the target ECG image segments.
3. The method according to claim 1, wherein, The feature extraction network includes a first convolutional layer, a second convolutional layer, a pooling layer, and residual blocks. The step of inputting the target ECG image segment into the feature extraction network and outputting the ECG features corresponding to the target ECG image segment includes: The target electrocardiogram segment is sequentially input into the first convolutional layer and the pooling layer, and the first feature vector is output. The first feature vector is input into the residual block to obtain the second feature vector; Using the second convolutional layer, the feature dimension length of the second feature vector is adjusted to obtain the electrocardiogram (ECG) feature. The time dimension length of the ECG feature is determined by the kernel size of the convolutional layer, and the feature dimension length of the ECG feature is determined by the stride of the pooling layer.
4. The method according to claim 1, wherein, The step of inputting the electrocardiogram features and the first position code into the encoder and outputting the electrocardiogram encoded features includes repeating the following operations until the second cycle number matches the layer number of the encoder: If it is determined that the second cycle number is inconsistent with the number of layers of the encoder, The feature vector corresponding to the x-th coding layer and the first position code are used as the query vector and key vector, respectively. The feature vector corresponding to the x-th coding layer is used as the value vector and input into the multi-head self-attention module of the x-th coding layer to obtain the output of the multi-head self-attention module of the x-th coding layer. The encoder includes X coding layers, where x is an integer greater than or equal to 1 and less than or equal to X. When x is greater than 1, the feature vector corresponding to the x-th coding layer is the output of the (x-1)-th coding layer. When x is 1, the feature vector corresponding to the 1st coding layer is the electrocardiogram feature. The output of the multi-head self-attention module and the feature vector are added together and normalized to obtain the input of the feedforward network of the x-th coding layer; The input of the feedforward network is input into the feedforward network to obtain the output of the feedforward network; The input and output of the feedforward network are added together and normalized to obtain the output of the x-th coding layer; The output of the coding layer obtained when the second cycle is consistent with the number of layers of the encoder is determined as the electrocardiogram coding feature.
5. The method according to claim 1, wherein, The step of embedding the electrocardiogram encoding features, the first position encoding, the decoder corresponding to the y-th decoding layer, and the second position encoding into the y-th decoding layer to obtain the output of the y-th decoding layer includes: The decoder embedding and second position encoding corresponding to the y-th decoding layer are used as key vector and query vector, and the decoder embedding corresponding to the y-th decoding layer is used as value vector and input into the multi-head self-attention module of the y-th decoding layer to obtain the output of the multi-head self-attention module of the y-th decoding layer. The output of the multi-head self-attention module and the decoder embedding are added and normalized to obtain a normalized vector; The normalized vector and the second position code are used as the query vector, the first position code and the ECG encoding feature are used as the key vector, and the ECG encoding feature is used as the value vector. The input is then used to the multi-head cross-attention module of the y-th decoding layer to obtain the output of the multi-head cross-attention module of the y-th decoding layer. The output of the multi-head cross-attention module and the normalized vector are added and normalized to obtain the input of the feedforward network of the y-th decoding layer; The input to the feedforward network is fed into the feedforward network to obtain the output of the feedforward network; and The output of the feedforward network and the input of the feedforward network are added together and normalized to obtain the output of the y-th decoding layer.
6. The method according to claim 1, wherein, The decoder embedding corresponding to the first decoding layer is obtained through the following operations: N reference heartbeats are randomly generated, and the learnable embedding vectors corresponding to each of the N reference heartbeats are determined as the decoder embeddings corresponding to the N reference heartbeats, where N is an integer greater than M; Q heart beats are randomly selected from M heart beats in the target electrocardiogram segment, where Q is an integer greater than 1 and Q = PN; The category labels of the Q heartbeats are flipped to obtain Q reference heartbeats, wherein the Q reference heartbeats are marked with noise labels after the labels are flipped; Based on the noise labels of the Q reference heartbeats, generate a label embedding vector corresponding to each of the Q reference heartbeats, and determine the label embedding vector as the decoder embedding corresponding to the Q reference heartbeats; Based on the decoder embeddings corresponding to the N reference heartbeats and the decoder embeddings corresponding to the Q reference heartbeats, a decoder embedding corresponding to the first decoding layer is generated.
7. The method according to claim 6, wherein, The second position encoding corresponding to the first decoding layer is obtained through the following operations: Randomly generate the bounding boxes of the N reference heartbeats; Random noise is added to the two-dimensional ground truth bounding boxes of the Q heartbeats to obtain the bounding boxes of the Q reference heartbeats; Using the position encoding function, an initial position code is generated based on the bounding boxes of the N reference frames and the bounding boxes of the Q reference frames; The initial position code is input into the multilayer perceptron, and the second position code corresponding to the first decoding layer is output.
8. The method according to claim 7, wherein, The step of calculating the loss by comparing the category labels and two-dimensional ground truth bounding box labels of each of the M heartbeats in the target electrocardiogram segment with the classification prediction results and predicted bounding boxes of each of the P reference heartbeats, and obtaining classification loss values and bounding box loss values, includes: The ground truth results of NM non-target heartbeats are filled into the initial ground truth arrangement to obtain the target ground truth arrangement. The initial ground truth arrangement includes the ground truth results of each of the M heartbeats, and the target ground truth arrangement includes the ground truth results of each of the N heartbeats. The ground truth results include the category label and the two-dimensional ground truth bounding box label corresponding to the heartbeat. The arrangement of the ground truth results of each of the N heartbeats in the target ground truth arrangement is fixed. The prediction results of the N reference heartbeats are sorted to obtain multiple prediction arrangements, wherein the prediction results include classification prediction results and prediction bounding boxes; For each of the predicted permutations, the classification prediction probability value, intersection-union ratio, and L1 norm are calculated based on the target true value permutation and the predicted permutation, wherein the classification prediction probability value represents the probability that the corresponding category label in the predicted permutation and the target true value permutation is consistent with the classification prediction result; Based on the classification prediction probability value, intersection-union ratio, and L1 norm corresponding to the predicted arrangement, the matching cost corresponding to the predicted arrangement is calculated; and The arrangement with the lowest matching cost among the multiple prediction arrangements is determined as the target prediction arrangement.
9. The method according to claim 8, wherein, The classification loss value includes a first classification loss value and a second classification loss value, and the bounding box loss value includes a first bounding box loss value and a second bounding box loss value. The method further includes: The first classification loss value is calculated using the classification loss function based on the predicted probability value corresponding to the target prediction arrangement. The first bounding box loss value is calculated using the bounding box loss function based on the intersection-union ratio and L1 norm corresponding to the predicted permutation of the target; Based on the classification prediction results of the Q reference heartbeats and the category labels of the Q heartbeats corresponding to the Q reference heartbeats, the classification prediction probability value corresponding to the Q reference heartbeats is calculated. Using the classification loss function, the second classification loss value is calculated based on the classification prediction probability values corresponding to the Q reference heartbeats; Based on the predicted bounding boxes of the Q reference heartbeats and the two-dimensional ground truth bounding box labels of the Q heartbeats corresponding to the Q reference heartbeats, the intersection-union ratio and L1 norm corresponding to the Q reference heartbeats are calculated. Using the bounding box loss function, the second bounding box loss value is calculated based on the intersection-union ratio and L1 norm corresponding to the Q reference frames.
10. A method for detecting atrial fibrillation heartbeats, comprising: The ECG record to be tested is sampled to the target sampling frequency, and the ECG record to be tested at the target sampling frequency is divided into multiple ECG segments according to the target time period. For each of the ECG segments to be detected, the ECG segment to be detected is input into the atrial fibrillation beat detection model, and the classification prediction results and prediction bounding boxes corresponding to each beat in the ECG segment to be detected are output. The atrial fibrillation beat detection model is trained by the method according to any one of claims 1 to 9, and the classification prediction results are used to determine the atrial fibrillation beats in the ECG segment to be detected.
Citation Information
Patent Citations
Atrial fibrillation identification method and device based on Transformer
CN113855037A
Twelve-lead electrocardiosignal automatic classification method based on double attention mechanism
CN115568860A