Model training method and atrial fibrillation heart beat detection method

By pre-processing and feature extraction of electrocardiograms, combining multi-layer iterative methods of position encoding and encoder decoder, accurate detection of atrial fibrillation heart beats is achieved, solving the problem of insufficient position prediction and detection capabilities in the existing technology, and improving The robustness and generalization performance of the model.

CN119302669AActive Publication Date: 2025-01-14AEROSPACE INFORMATION RES INST CAS
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202411482688.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-23
Publication Date
2025-01-14
Estimated Expiration
2044-10-23

AI Technical Summary

Technical Problem

The existing electrocardiogram (AF) detection methods are difficult to accurately predict the position while paying attention to the classification of atrial fibrillation, and the traditional QRS detection algorithm lacks performance in many arrhythmia scenarios, limiting the detection ability of the model.

Method used

Using model training method, the ECG recording samples are preprocessed, and the feature extraction network is input to extract the ECG features, and the position encoding function is used to construct position encoding, combining the encoder and decoder for multi-layer loop iteration, and the bounding box and classification prediction are updated. , realize accurate detection of heart fibrillation.

Benefits of technology

The accuracy of atrial fibrillation heart shooting detection and the generalization performance of the model are improved, the characteristic ambiguity caused by atrial fibrillation and non-atrial fibrillation heart shooting in the electrocardiogram segment is avoided, and the robustness of the model in practical applications is enhanced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119302669A_ABST
    Figure CN119302669A_ABST
Patent Text Reader

Abstract

The invention provides a model training method and an atrial fibrillation heart beat detection method. The method comprises the following steps: inputting a target electrocardiogram segment into a feature extraction network to output electrocardiogram features; inputting the electrocardiogram features and the first position codes into an encoder to output electrocardiogram code features; and repeating the following operations until the number of cycles is consistent with the number of layers of the decoder to obtain an atrial fibrillation heart beat detection model: inputting the electrocardiogram coding characteristics, the first position code, the decoder embedding and the second position code into the yth decoding layer to obtain the output of the yth decoding layer, inputting a bounding box to predict the output offset in the head, and utilizing the offset to obtain the atrial fibrillation heart beat detection model. Updating to obtain a prediction bounding box; the classification prediction result of the heart beat is output in the input classification prediction head; and performing loss calculation on the category label and the bounding box label of the target electrocardiogram segment and the classification prediction result and the prediction bounding box of the heart beat to obtain a classification loss value and a bounding box loss value so as to adjust model parameters of the to-be-trained model and obtain an adjusted model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the technical field of physiological signal processing, and in particular to a model training method and an atrial fibrillation heartbeat detection method. Background Art

[0002] Electrocardiogram (ECG) can be used to assist in the clinical diagnosis of atrial fibrillation. Therefore, timely and accurate detection of atrial fibrillation in the heartbeat signal in the ECG is important for the early detection of atrial fibrillation. However, most existing ECG-based AF (Atrial fibrillation) detection methods often only focus on segment-level atrial fibrillation classification tasks, are unable to identify atrial fibrillation of a single heartbeat in a fine-grained manner, and ignore the effective extraction of irregular heartbeat location information, which limits the generalization performance of the model in practical applications. Existing beat-level AF detection methods usually use a single heartbeat signal as input, and still require the additional use of a QRS detection algorithm for heartbeat location. However, the traditional threshold-based QRS detection algorithm still has insufficient performance in a variety of arrhythmia scenarios, and incorrect location results may further limit the detection capabilities of the model.

[0003] Therefore, how to accurately predict the position while paying attention to the classification of atrial fibrillation heartbeats is a technical problem that needs to be solved in the prior art. Summary of the invention

[0004] In view of the above problems, the present disclosure provides a model training method and an atrial fibrillation heartbeat detection method.

[0005] According to a first aspect of the present disclosure, a model training method is provided, comprising:

[0006] Preprocess each electrocardiogram recording sample in the sample set to obtain a target electrocardiogram segment, wherein the target electrocardiogram segment includes M heartbeats, M is an integer greater than or equal to 1, and each heartbeat is marked with a category label and a two-dimensional true value bounding box label, and the category label is used to characterize whether the heartbeat is an atrial fibrillation heartbeat;

[0007] Input the target ECG segment into a feature extraction network, and output an ECG feature corresponding to the target ECG segment;

[0008] Using the position coding function, constructing a first position coding corresponding to the electrocardiogram feature;

[0009] Inputting the electrocardiogram feature and the first position code into an encoder, and outputting the electrocardiogram code feature;

[0010] Repeat the following operations until the first cycle is consistent with the number of layers of the decoder to obtain an atrial fibrillation heartbeat detection model:

[0011] When it is determined that the first cycle number is inconsistent with the number of layers of the decoder,

[0012] Inputting the electrocardiogram coding feature, the first position code, the decoder embedding corresponding to the yth decoding layer and the second position code into the yth decoding layer to obtain the output of the yth decoding layer, wherein the decoder includes Y decoding layers, y is an integer greater than or equal to 1 and less than or equal to Y; the decoder embedding corresponding to the yth decoding layer is the output of the y-1th decoding layer, and the second position code corresponding to the yth decoding layer is constructed according to the P bounding boxes updated by the output of the y-1th decoding layer;

[0013] Input the output of the y-th decoding layer into the bounding box prediction head of the y-th decoding layer, and output the offset corresponding to each of the P bounding boxes;

[0014] Using the offsets corresponding to the P bounding boxes, the P bounding boxes are updated to obtain P predicted bounding boxes updated by the output of the y-th decoding layer;

[0015] 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 the P reference heart beats corresponding to the decoder embedding, wherein the prediction bounding box corresponds to the reference heart beat one by one, and the prediction bounding box is used to represent the position of the reference chip in the target electrocardiogram segment;

[0016] The category labels and two-dimensional true bounding box labels of the M heartbeats in the target electrocardiogram segment are respectively calculated with the classification prediction results and prediction bounding boxes of the P reference heartbeats to obtain classification loss values ​​and bounding box loss values;

[0017] According to the above classification loss value and the above bounding box loss value, the model parameters of the model to be trained are adjusted to obtain an adjusted model, wherein the above adjusted model includes a feature extraction network, an encoder and a decoder.

[0018] A second aspect of the present disclosure provides a method for detecting atrial fibrillation, comprising:

[0019] Sampling the electrocardiogram record to be detected to a target sampling frequency, and dividing the electrocardiogram record to be detected at the target sampling frequency into a plurality of electrocardiogram segments to be detected according to a target time period;

[0020] For each of the above-mentioned electrocardiogram segments to be detected, the above-mentioned electrocardiogram segments to be detected are input into the atrial fibrillation heartbeat detection model, and the classification prediction results and prediction boundary boxes corresponding to each heartbeat in the above-mentioned electrocardiogram segments to be detected are output, wherein the above-mentioned classification prediction results are used to determine the atrial fibrillation heartbeats in the above-mentioned electrocardiogram segments to be detected.

[0021] A third aspect of the present invention provides an electronic device, comprising: one or more processors; 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 execute the above method.

[0022] The fourth aspect of the present invention also provides a computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, causes the processor to execute the above method.

[0023] The fifth aspect of the present invention also provides a computer program product, including a computer program, which implements the above method when executed by a processor.

[0024] According to the model training method and atrial fibrillation heartbeat detection method provided by the present disclosure, the electrocardiogram recording samples in the sample set are first preprocessed to improve the quality of the samples and the accuracy of the model training. The target electrocardiogram segment is input into the feature extraction network to extract the corresponding electrocardiogram feature. The first position code corresponding to the electrocardiogram feature is constructed by using the position coding function, and the first position code and the electrocardiogram feature are input into the encoder, which helps to capture the position dependency to supplement the position representation ability of the model. The electrocardiogram coding feature output by the encoder, the first position code, the decoder are embedded and the second position code is input into the decoder. The position query is updated by updating the bounding box representing the heartbeat position layer by layer, that is, the second position code, so as to effectively locate the atrial fibrillation heartbeat. Since the target electrocardiogram segment includes multiple heartbeats, the trained model can provide a heartbeat-level prediction, effectively avoiding the feature ambiguity problem caused by the electrocardiogram segment containing both atrial fibrillation heartbeats and non-atrial fibrillation heartbeats. In addition, since the loss calculation is performed once based on the output of each decoding layer, the speed of model training is improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] The above contents and other objects, features and advantages of the present disclosure will become more apparent through the following description of the embodiments of the present disclosure with reference to the accompanying drawings, in which:

[0026] Figure 1 A diagram schematically shows an application scenario of a model training method and an atrial fibrillation heartbeat detection method according to an embodiment of the present disclosure;

[0027] Figure 2 A flowchart of a model training method according to an embodiment of the present disclosure is schematically shown;

[0028] Figure 3 The structure diagram of the model to be trained according to the embodiment of the present disclosure is schematically shown;

[0029] Figure 4 A schematic diagram schematically shows the backbone structure of a feature extraction network according to an embodiment of the present disclosure;

[0030] Figure 5 The schematic diagram of the structure of the decoder and the encoder according to the embodiment of the present disclosure is shown;

[0031] Figure 6 A flowchart of using an encoder to output electrocardiogram encoding features according to an embodiment of the present disclosure is schematically shown;

[0032] Figure 7 A flowchart for obtaining the output of the y-th decoding layer according to an embodiment of the present disclosure is schematically shown;

[0033] Figure 8 A flowchart of an atrial fibrillation heartbeat detection method according to an embodiment of the present disclosure is schematically shown;

[0034] Fig. 9 The structure block diagram of the model training device according to the embodiment of the present disclosure is schematically shown;

[0035] Fig.10 A schematic diagram of a structural block diagram of an atrial fibrillation heartbeat detection device according to an embodiment of the present disclosure is shown; and

[0036] Fig.11 A block diagram of an electronic device suitable for implementing a model training method and an atrial fibrillation heartbeat detection method according to an embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION

[0037] Hereinafter, embodiments of the present disclosure will 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 present disclosure. In the following detailed description, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of the embodiments of the present disclosure. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessary confusion of the concepts of the present disclosure.

[0038] The terms used herein are only for describing specific embodiments and are not intended to limit the present disclosure. The terms "comprise", "include", etc. used herein indicate the existence of the features, steps, operations and / or components, but do not exclude the existence or addition of one or more other features, steps, operations or components.

[0039] All terms (including technical and scientific terms) used herein have the meanings commonly understood by those skilled in the art unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification and should not be interpreted in an idealized or overly rigid manner.

[0040] When using expressions such as "at least one of A, B, and C, etc.", they should generally be interpreted according to the meaning of the expression commonly understood by those skilled in the art (for example, "a system having at least one of A, B, and C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.).

[0041] In the technical solution of the present disclosure, the user information (including but not limited to user personal information, user image information, user device information, such as location information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved are all information and data authorized by the user or fully authorized by all parties, and the collection, storage, use, processing, transmission, provision, disclosure and application of the relevant data comply with relevant laws, regulations and standards, take necessary confidentiality measures, do not violate public order and good morals, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0042] In the scenario of using personal information for automated decision-making, the methods, devices, and systems provided by the embodiments of the present disclosure provide users with corresponding operation portals for users to choose to agree or reject the automated decision-making results; if the user chooses to reject, the expert decision-making process will be entered. The expression "automated decision-making" here refers to the activity of automatically analyzing and evaluating a person's behavioral habits, interests and hobbies, or economic, health, credit status, etc. through computer programs, and making decisions. The expression "expert decision-making" here refers to the activity of making decisions by people who specialize in a certain field, have specialized experience, knowledge and skills, and have reached a certain level of professionalism.

[0043] In the process of implementing the present disclosure, it was found that on the electrocardiogram, the characteristics of atrial fibrillation are irregular RR intervals, the disappearance of the P wave and its replacement by the f wave. Currently, medical experts are still needed to interpret the electrocardiogram data, and manual visual inspection of the electrocardiogram is also a very time-consuming and error-prone task, which greatly reduces the chance of timely detection of atrial fibrillation. Therefore, it is necessary to develop reliable automated methods to analyze and interpret long-term electrocardiogram records.

[0044] In recent years, deep learning (DL) technology has performed well in feature extraction and classification due to its unique adaptive ability. 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 usually give diagnostic predictions based on input ECG segments or RR interval sequences (RRI) extracted from ECG. However, there are still some neglected issues in existing deep learning methods that need further study.

[0046] First, most existing AF detection methods divide ECG records into fixed-length segments as a whole to generate a single prediction label, which makes it impossible to provide beat-level prediction labels. In addition, 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 to embed the two into overlapping feature spaces.

[0047] Second, existing AF detection models expect isolated single heartbeat signals as input to achieve beat-level detection, which cannot provide sufficient rhythm location information for AF detection.

[0048] Furthermore, existing deep learning methods often only focus on atrial fibrillation classification tasks and ignore the extraction of rhythm position information in ECG, which limits the generalization performance of the model in real applications. In addition, AF detection methods that use a single heartbeat signal or RRI sequence as input still require clear positioning of the heartbeat signal. In the model training phase, you can usually rely on the heartbeat annotations of the dataset, but in the inference phase of actual applications, you still need to use the QRS detection algorithm. The traditional threshold-based QRS detection algorithm still has insufficient performance in a variety of arrhythmia scenarios, and incorrect positioning results may further limit the detection capabilities of the model.

[0049] Therefore, how to accurately predict the position while paying attention to the classification of atrial fibrillation heartbeats is a technical problem that needs to be solved in the prior art. Based on this, the present disclosure provides a model training method and an atrial fibrillation heartbeat detection method to solve the above problem. In addition, the present disclosure also provides a model training device and an atrial fibrillation heartbeat detection device to implement the above model training method and atrial fibrillation heartbeat detection method.

[0050] Figure 1 The application scenario diagram of the model training method and the atrial fibrillation heartbeat detection method according to the embodiments of the present disclosure is schematically shown.

[0051] like Figure 1As shown, the 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 is used to provide a medium for 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, wireless communication links, or optical fiber cables, etc.

[0052] The user can use the first terminal device 101, the second terminal device 102, and the third terminal device 103 to interact with the server 105 through 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 platform software, etc. (only for example).

[0053] The first terminal device 101, the second terminal device 102, and the third terminal device 103 may be various electronic devices having display screens and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.

[0054] The server 105 may be a server that provides various services, such as a background management server (only as an example) that provides support for websites browsed by users using the first terminal device 101, the second terminal device 102, and the third terminal device 103. The background management server may analyze and process the received data such as 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 device.

[0055] For example, each ECG recording sample in the sample set can be preprocessed by the server 105 to obtain a target ECG segment, so as to input the target ECG segment into a feature extraction network, output an ECG feature corresponding to the target ECG segment, and construct a first position code corresponding to the ECG feature by using a position coding function, so as to input the ECG feature and the first position code into the encoder, and output the ECG coding feature; repeat the following operations until the first cycle round is consistent with the number of layers of the decoder, and obtain an atrial fibrillation heartbeat detection model: when it is determined that the first cycle round is inconsistent with the number of layers of the decoder, the ECG coding feature, the first position code, the decoder embedding corresponding to the yth decoding layer, and the second position code are input into the yth decoding layer to obtain the output of the yth decoding layer ; Input the output of the y-th decoding layer into the bounding box prediction head of the y-th decoding layer, and output the offset corresponding to each of the P bounding boxes; Use the offset corresponding to each of the P bounding boxes to update the P bounding boxes, and obtain the P predicted bounding boxes updated by the output of the y-th decoding layer; 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 the P reference heart beats corresponding to the decoder embedding; Perform loss calculation on the category labels and two-dimensional true value bounding box labels of the M heart beats in the target electrocardiogram segment and the classification prediction results and predicted bounding boxes of the P reference heart beats, respectively, to obtain classification loss values ​​and bounding box loss values; According to the classification loss value and the bounding box loss value, adjust the model parameters of the model to be trained to obtain the adjusted model.

[0056] It should be noted that the model training method and atrial fibrillation heartbeat detection method provided in the embodiments of the present disclosure can generally be executed by the server 105. Accordingly, the model training device and atrial fibrillation heartbeat detection device provided in the embodiments of the present disclosure can generally be arranged in the server 105. The model training method and atrial fibrillation heartbeat detection method provided in the embodiments of the present disclosure can also be executed by a server or server cluster that is different from the server 105 and can communicate with the first terminal device 101, the second terminal device 102, the third terminal device 103 and / or the server 105. Accordingly, the model training device and atrial fibrillation heartbeat detection device provided in the embodiments of the present disclosure can also be arranged in a server or server cluster that is different from the server 105 and can communicate with the first terminal device 101, the second terminal device 102, the third terminal device 103 and / or the server 105.

[0057] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.

[0058] The following will be based on Figure 1 The scene described by Figure 2~Figure 8The model training method and atrial fibrillation heartbeat detection method of the embodiments of the present disclosure are described in detail.

[0059] Figure 2 A flowchart of a model training method according to an embodiment of the present disclosure is schematically shown.

[0060] like Figure 2 As shown, the method 200 includes operations S210 to S221.

[0061] In operation S210, each electrocardiogram recording sample in the sample set is preprocessed to obtain a target electrocardiogram segment.

[0062] The target electrocardiogram segment may include M heart beats, where M is an integer greater than or equal to 1, and each heart beat is marked with a category label and a two-dimensional true value bounding box label.

[0063] According to an embodiment of the present disclosure, multiple electrocardiogram recording samples in a sample set are preprocessed to improve the quality of the samples and facilitate the accuracy of model training, and based on the category label and two-dimensional true value bounding box label marked for each heartbeat, loss calculation is performed with the predicted classification result and bounding box to adjust the parameters of the model. Among them, the category label may include an atrial fibrillation label (AF) and a non-atrial fibrillation label (Non-AF) to characterize whether the heartbeat is an atrial fibrillation heartbeat; the two-dimensional true value bounding box label is used to indicate the position of the heartbeat in the target electrocardiogram segment.

[0064] Figure 3 The structural diagram of the model to be trained according to an embodiment of the present disclosure is schematically 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 electrocardiogram segment is input into a feature extraction network, and an electrocardiogram feature corresponding to the target electrocardiogram segment is output.

[0067] According to an embodiment of the present disclosure, a target ECG signal may be input into the feature extraction network 310 to extract features from the target ECG signal and obtain ECG features corresponding to the target ECG signal.

[0068] In operation S212, a first position code corresponding to the electrocardiogram feature is constructed using the position code function.

[0069] According to an embodiment of the present disclosure, since the Transformer architecture has permutation invariance, a fixed position encoding is added to the input of each attention module in the encoder 320 to capture position dependencies, which helps to supplement the position representation capability of the model.

[0070] According to an embodiment of the present disclosure, the sine function is used to construct a position encoding vector at the same scale, Positional encoding function mapped to D-dimensional sinusoidal embedding , which can be expressed as the following formulas (1) and (2).

[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 vector of feature length D corresponding to each time point in the time dimension of the ECG feature. The length of the feature dimension of the ECG feature is D. The subscripts 2i and 2i+1 represent the index in the encoding vector. When i is an odd number, formula (2) is used, and when i is an even number, formula (1) is used. i refers to D and takes values ​​from 0 to D / 2. T is a hyperparameter. The typical value used in the encoder is T=10000.

[0074] According to an embodiment of the present disclosure, by using the formula (1) and formula (2) corresponding to the above position encoding function, according to the electrocardiogram feature, a first position encoding (Positional Encodings) corresponding to the electrocardiogram feature can be constructed.

[0075] In operation S213, the electrocardiogram feature and the first position code are input into an encoder, and the electrocardiogram code feature is output.

[0076] According to an embodiment of the present disclosure, the encoder 320 is composed of a plurality of encoding layers having the same structure, and they are all capable of encoding and generating encoding features with the same resolution as the input electrocardiogram features, that is, when the electrocardiogram features are input into the encoder, the encoder can be used to extract the electrocardiogram encoding features (Encoder Features) in the electrocardiogram features, and when the first position encoding is input into the encoder, the encoder can be used to capture positional dependencies, which helps to supplement the positional representation capability of the model.

[0077] According to the embodiment of the present disclosure, based on the above formula (1) and formula (2), the position coding is independent of the specific value of the feature, but is related to the length and position of the feature, that is, the shape of the feature. Therefore, as long as the shape of the feature is fixed, the corresponding position coding is fixed. Therefore, the position coding input to each coding layer in the encoder 320 is the same, which is the first position coding. 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 coding and the output of the previous coding layer.

[0078] In operation S214, the electrocardiogram encoding feature, the first position code, the decoder embedding corresponding to the yth decoding layer, and the second position code are input into the yth decoding layer to obtain the output of the yth decoding layer.

[0079] In which, the decoder 330 may include Y decoding layers, y is an integer greater than or equal to 1 and less than or equal to Y; the decoder embedding corresponding to the yth decoding layer is the output of the y-1th decoding layer, and the second position code corresponding to the yth decoding layer is constructed based on P bounding boxes obtained by updating the output of the y-1th decoding layer, where P is an integer greater than M.

[0080] According to an embodiment of the present disclosure, the decoder 330 may include Y identical decoding layers for decoding P targets, that is, the number of predicted heart beats output by the decoder 330 is P.

[0081] According to an embodiment of the present disclosure, the number of predicted heartbeats output by the trained model is subject to a fixed limit, that is, in the inference stage of actual application, the number of predicted heartbeats is P=N, but the number of heartbeats in the electrocardiogram segment input into the trained model is uncertain. In order to enable the trained model to more accurately detect electrocardiogram segments containing different numbers of heartbeats, it is necessary to set the number of predicted heartbeats output by the model to be significantly larger than the possible number of heartbeats in the electrocardiogram segment during the training process, that is, N is much larger than the possible M. The model only needs to predict NM of the heartbeats as non-target heartbeats, which are invalid predictions. For example, for an electrocardiogram segment of t seconds in length, the maximum number of heartbeats that may appear is 60, and the output of the model can be set to 100.

[0082] According to an embodiment of the present disclosure, when y takes a value of 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 heartbeats, and the second position encoding corresponding to the first decoding layer is constructed based on the reference bounding boxes of the random P reference heartbeats using the position encoding function, i.e., the above formulas (1) and (2); when y is greater than 1, the decoder embedding corresponding to the yth decoding layer is the output of the y-1th decoding layer, and the second position encoding corresponding to the yth decoding layer is constructed based on the P bounding boxes obtained by updating the output of the y-1th decoding layer.

[0083] In operation S215, the output of the y-th decoding layer is input into the bounding box prediction head of the y-th decoding layer, and the offset corresponding to each of the P bounding boxes is output.

[0084] According to an embodiment 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 obtain a predicted bounding box according to the prediction of the bounding box prediction head, and obtain a predicted classification result according to the prediction of the classification prediction head.

[0085] According to an embodiment of the present disclosure, the output of the yth decoding layer is input into the bounding box prediction head of the decoding layer, and the offset corresponding to each of the P bounding boxes can be output. To provide the updated bounding box for the y+1th decoding layer, iterative updates help to further reduce the difficulty of optimization. Among them, the bounding box prediction head is ,The bounding box prediction head consists of three fully connected layers, is the offset of the center point of the bounding box, Offset to the bounding box width.

[0086] In operation S216, the P bounding boxes are updated using offsets corresponding to the P bounding boxes, and P predicted bounding boxes are obtained by updating the output of the y-th decoding layer.

[0087] According to an embodiment of the present disclosure, the offsets corresponding to 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 an embodiment of the present disclosure, given a normalized bounding box predicted by the y-1th decoding layer , then the y-th decoding layer can update the bounding box to the corresponding predicted bounding box , which can be expressed by the following formula (3).

[0089] (3)

[0090] in, is the qth predicted bounding box among the P predicted bounding boxes corresponding to the y-1th decoding layer, is the qth predicted bounding box among the P predicted bounding boxes corresponding to the yth decoding layer, is the relative offset of the qth bounding box predicted by the yth decoding layer for the center point, is the relative offset of the qth bounding box predicted by the yth decoding layer to the box width, and Represent the sigmoid function and the inverse sigmoid function respectively.

[0091] In operation S217, the output of the yth decoding layer is input into the classification prediction head of the yth decoding layer, and the classification prediction results of the P reference heartbeats corresponding to the decoder embedding are output.

[0092] The predicted bounding box corresponds to the reference heart beat one by one, and the predicted bounding box is used to represent the position of the reference heart beat in the target electrocardiogram segment.

[0093] According to an embodiment of the present disclosure, the output of the y-th decoding layer is layer normalized and input into the classification prediction head of the decoding layer, and the classification prediction results corresponding to each of the P reference heart beats can be output, wherein the classification prediction results can indicate that the reference heart beat is one of an atrial fibrillation heart beat, a non-atrial fibrillation heart beat, and a non-target heart beat, that is, the classification prediction results can be used to determine the atrial fibrillation heart beat among the P reference heart beats, and the classification prediction head is ,The classification prediction head contains two fully connected layers.

[0094] In operation S218, the category labels and two-dimensional true bounding box labels of the M heartbeats in the target electrocardiogram segment are respectively compared with the classification prediction results and predicted bounding boxes of the P reference heartbeats to obtain classification loss values ​​and bounding box loss values.

[0095] According to an embodiment of the present disclosure, a loss calculation is performed on the predicted bounding box and classification prediction result predicted by the output of each decoding layer based on the category labels of the M heart beats in the target electrocardiogram segment and the two-dimensional true value bounding box labels, and the classification loss value and the bounding box loss value are calculated to speed up model training.

[0096] In operation S219, model parameters of the model to be trained are adjusted according to the classification loss value and the bounding box loss value to obtain an adjusted model, wherein the adjusted model includes a feature extraction network, an encoder, and a decoder.

[0097] Among them, 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 of the decoder.

[0099] According to an embodiment of the present disclosure, when the first loop round is inconsistent with the number of layers of the decoder, the above operations S214 to S219 are performed; when the first loop round is consistent with the number of layers of the decoder, operation S221 is performed.

[0100] In operation S221, the adjusted model is determined as an atrial fibrillation heartbeat detection model.

[0101] According to an embodiment of the present disclosure, a model trained using a target electrocardiogram segment is determined as an atrial fibrillation heartbeat detection model, wherein the target electrocardiogram segment is at least one.

[0102] According to an embodiment of the present disclosure, the electrocardiogram recording samples in the sample set are first preprocessed to improve the quality of the samples and the accuracy of model training. The target electrocardiogram segment is input into the feature extraction network to extract the corresponding electrocardiogram feature. The first position code corresponding to the electrocardiogram feature is constructed by using the position coding function, and the first position code and the electrocardiogram feature are input into the encoder, which helps to capture the position dependency to supplement the position representation capability of the model. The electrocardiogram coding feature output by the encoder, the first position code, the decoder embedding and the second position code are input into the decoder. The position query is updated by updating the bounding box representing the heartbeat position layer by layer, that is, the second position code, so as to effectively locate the atrial fibrillation heartbeat. Since the target electrocardiogram segment includes multiple heartbeats, the trained model can provide a heartbeat-level prediction, effectively avoiding the feature ambiguity problem caused by the electrocardiogram segment containing both atrial fibrillation heartbeats and non-atrial fibrillation heartbeats. In addition, since the loss calculation is performed once based on the output of each decoding layer, the speed of model training is improved.

[0103] According to an embodiment of the present disclosure, each electrocardiogram recording sample in a sample set is preprocessed to obtain a target electrocardiogram segment, including: sampling each electrocardiogram recording sample in the sample set to a target sampling frequency; filtering each electrocardiogram recording sample at the target sampling frequency to obtain a filtered electrocardiogram recording sample; dividing each filtered electrocardiogram recording sample into a plurality of electrocardiogram segments according to a target time period; normalizing the plurality of electrocardiogram segments to obtain a normalized electrocardiogram segment; and annotating the normalized electrocardiogram segment with a category label and a two-dimensional true value bounding box label to obtain a target electrocardiogram segment.

[0104] According to an embodiment of the present disclosure, the sampling frequency of each electrocardiogram recording sample in the sample set can be sampled to the target sampling frequency. , in order to facilitate accurate training of the model.

[0105] According to an embodiment of the present disclosure, due to the aging of the equipment, changes in environmental conditions, etc., there may still be noise influence in the ECG recording samples, and the noise 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 the filtered ECG recording samples.

[0106] For example, a bandpass Butterworth filter with a filter order of 5 and a bandpass frequency range of 0.5-40 Hz can be used to remove baseline drift and high-frequency noise in the electrocardiogram recording sample. 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 the embodiments of the present disclosure, the presence of baseline drift and high-frequency noise may cause the characteristics of the electrocardiogram recording samples to be disturbed during the model training process, which may affect the accuracy and stability of the measurement results. Therefore, filtering the electrocardiogram recording samples at the target sampling frequency can eliminate the influence of baseline drift and high-frequency noise on the electrocardiogram, improve the quality of the samples, and avoid interference with subsequent model training.

[0108] According to the embodiments of the present disclosure, since the length of the input image segment for model processing is limited, it is necessary to segment the filtered ECG recording sample into multiple ECG segments according to the target time period to avoid interference of multiple sample segments of different lengths on model training. For example, segment the filtered ECG recording sample into non-overlapping 1 second ECG segment.

[0109] According to an embodiment of the present disclosure, in order to facilitate data processing in model training, the ECG segment is normalized to obtain a normalized ECG segment. Each heartbeat in the normalized ECG segment is labeled with a category label and a two-dimensional true value bounding box label to obtain a target ECG segment. For example, the ECG segment can be z-score normalized.

[0110] According to an embodiment of the present disclosure, the length of the target electrocardiogram segment is , but the number of heartbeats contained in different target ECG segments is different. The target ECG segment can be defined as , the target truth set corresponding to the target ECG segment can be expressed as , where M can represent the number of heart beats in the target ECG segment, It can be represented as the element corresponding to the i-th heart beat in the target ECG segment. It can be expressed as ,in, It can be represented as a category label (AF or Non-AF). For example, it can be labeled with 0 or 1, where 1 represents atrial fibrillation and 0 represents non-atrial fibrillation. can be represented as a 2D ground truth bounding box label, is the normalized center point coordinate, is the width relative to the sample length.

[0111] Among them, the two-dimensional true value bounding box of each heart beat in the target ECG segment can be obtained through the normalized ECG segment.

[0112] For example, the two-dimensional true value bounding box of the heart beat includes position and width. The R peak position can be used as the center position of the bounding box, that is, the center point coordinate, and the empirical value of 400ms can be sampled as the width of the bounding box. The position of each heart beat is normalized to [0, 1] relative to the starting point of the sliding window.

[0113] According to an embodiment of the present disclosure, in order to ensure the accuracy of subsequent training models, each electrocardiogram recording sample in the sample set is sampled to the target sampling frequency and filtered to eliminate the influence of baseline drift and high-frequency noise, and the segmented electrocardiogram segments are normalized to facilitate data processing in the model training process, and the normalized electrocardiogram segments are annotated with category labels and two-dimensional true value bounding box labels so that loss calculation can be performed subsequently based on the annotated labels and predicted results. Thus, each electrocardiogram recording sample in the sample set is preprocessed to improve the quality of the sample, so as to improve the accuracy of model training.

[0114] According to an embodiment of the present disclosure, a target ECG segment is input into a feature extraction network, and an ECG feature corresponding to the target ECG segment is output, including: inputting the target ECG segment into a first convolutional layer and a pooling layer in sequence, and outputting 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 the ECG feature.

[0115] Among them, the feature extraction network 310 may include a first convolutional layer, a second convolutional layer, a pooling layer and a residual block, the time dimension length of the electrocardiogram feature is determined by the kernel size of the convolutional layer, and the feature dimension length of the electrocardiogram feature is determined by the step size of the pooling layer.

[0116] According to an embodiment of the present disclosure, the target ECG segment is first input into the first convolutional layer in the feature extraction network 310 to extract the features of the target ECG segment, and then passes through the pooling layer to reduce the length of the time dimension of the extracted features to obtain a first feature vector.

[0117] According to an embodiment of the present disclosure, the first feature vector is input into the residual block again to alleviate the problem of gradient vanishing, and a second feature vector is obtained. The feature dimension length of the second feature vector is adjusted by the second convolution layer to reach the target feature dimension length D, and the electrocardiogram feature is obtained. Among them, the convolution layer, the pooling layer and the residual block in the feature extraction network 310 are one-dimensional.

[0118] Figure 4 A schematic diagram schematically shows the backbone structure of a feature extraction network according to an embodiment of the present disclosure.

[0119] like Figure 4 As shown, the embodiment 400 is a backbone structure of the 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 an embodiment of the present disclosure, the number of residual blocks 430 can be set as needed. The residual block 430 introduces a jump connection to directly add the input of the residual block 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 problem of gradient disappearance.

[0121] According to an embodiment of the present disclosure, the target electrocardiogram segments (EGG Segments) may be input as follows: Figure 4 The feature extraction network shown here outputs ECG Features.

[0122] According to an embodiment of the present disclosure, generally speaking, the residual block 430 only includes a convolution layer 431 and a convolution layer 432, wherein the convolution layer 431 and the convolution layer 432 constitute a residual connection. Figure 4 The residual block 430 shown in the figure also includes a pooling layer 433 as a whole, to indicate that a residual connection structure consisting of two convolutional layers is followed by a pooling layer. This is one embodiment, and the residual connection structure consisting of two convolutional layers can also be regarded as a whole, i.e., a residual block, and a pooling layer is connected behind the residual block, i.e., a residual block is followed by a pooling layer, but only some residual blocks may be followed by a pooling layer.

[0123] According to an embodiment of the present disclosure, the target ECG segment can be defined as ,in, It 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 convolution layer, and the length of the time dimension can be reduced based on the step size of the pooling layer.

[0124] According to an embodiment of the present disclosure, when the length of the electrocardiogram feature to be obtained is set to be reduced by 48 times in the time dimension and the feature dimension is increased by 128, Figure 4 Taking the backbone structure 400 of the feature extraction network 310 as an example, the kernel size of the first convolution layer 410 is 3, the step size of the pooling layer 420 is 3 and the kernel size is 3, the kernel size of the convolution layer 431 and the convolution layer 432 in the four residual blocks 430 is 3, the step size of the pooling layer 433 is 2 and the kernel size is 2, and the kernel size of the second convolution layer 440 is 1. Thus, it can be obtained that in the time dimension , the electrocardiogram feature with a feature dimension of 128. The second convolutional layer 440 is used to adjust the number of feature vector channels to the required number, that is, to adjust the feature dimension of the feature vector to the required length, such as D=128.

[0125] Among them, the number of residual blocks, step size, kernel size, and number of channels in the feature extraction network 310 can be set as needed.

[0126] According to an embodiment of the present 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] Among them, the main function of the batch normalization layer is to reduce the internal covariate shift. By normalizing the output of each layer, the input of each layer maintains a similar distribution, thereby accelerating the training process and improving the stability of the model. The ReLU activation layer is a nonlinear activation function that enhances the expressiveness of the model by introducing nonlinear mapping, and can alleviate the gradient vanishing problem, so that the information in the deep network can be effectively propagated backward.

[0128] According to an embodiment of the present disclosure, the length of the feature dimension is increased based on the kernel size of the convolutional layer in the feature extraction network to improve the accuracy of model training, and the length of the time dimension is reduced based on the step size of the pooling layer in the feature extraction network to effectively reduce the size of the feature while retaining important features, which is beneficial to reducing the amount of calculation and increasing the robustness and translation invariance of the feature. The residual structure of the residual block in the feature extraction network is based on the residual structure, so that the integrity of the gradient is better maintained during the training process, and the network can learn more complex feature representations, thereby improving the accuracy and generalization ability of the model.

[0129] Figure 5 The structural diagram of a decoder and an encoder according to an embodiment of the present disclosure is schematically shown.

[0130] like Figure 5 As shown, the embodiment 500 is a backbone structure of the encoder 320 and the decoder 330 .

[0131] According to an embodiment of the present disclosure, the backbone structure 510 of each encoding layer in the encoder (Encoder) 320 includes a multi-head self-attention module (Multi-head Self-attention) 511, an addition and layer normalization module (Add & Norm) 512, a feed-forward network (FFN) 513, an addition and layer normalization module (Add & Norm) 514 and a position encoding function.

[0132] Among them, the multi-head self-attention module 511 and the addition and layer normalization module 512 form a residual connection, and the feedforward network 513 and the addition and layer normalization module 514 also form a residual connection.

[0133] The feed-forward network 513 consists of two fully connected layers, and the two fully connected layers are connected using a ReLU activation layer.

[0134] According to an embodiment of the present disclosure, the backbone structure 520 of each decoding layer in the decoder (Decoder) 330 includes a multi-head self-attention module (Multi-head Self-attention) 521, an addition and layer normalization module (Add & Norm) 522, an MLP (Multi-layer Perceptron) 523, a multi-head cross-attention module (Multi-heat Cross-attention) 524, an addition and layer normalization module (Add & Norm) 525, a feed-forward network (FFN) 526, an addition and layer normalization module (Add & Norm) 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 of the multi-head self-attention module 511, the multi-head self-attention module 521 and the multi-head cross-attention module can be set to H=8.

[0136] Figure 6 The flowchart of using an encoder to output electrocardiogram encoding features according to an embodiment of the present disclosure is schematically 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 the key vector, and the feature vector corresponding to the x-th coding layer is input 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.

[0139] Among them, the encoder 320 may include X coding layers, 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 xth coding layer is the output of the x-1th coding layer; when x is 1, the feature vector corresponding to the 1st coding layer is the electrocardiogram feature.

[0140] According to an embodiment of the present disclosure, in each encoding layer, the feature vector is combined with the first position code to generate a query Q, a key K, and a value V as inputs of the multi-head self-attention module 511. For the x-th encoding layer in the encoder 320, the feature vector corresponding to the x-th encoding layer and the first position code are used as the query vector and the key vector, and the feature vector corresponding to the x-th encoding layer is used as the value vector, that is, the sum of the feature vector corresponding to the x-th encoding layer and the first position code is used as the query vector Q, the sum of the feature vector corresponding to the x-th encoding layer and the first position code is used as the key vector K, and the feature vector corresponding to the x-th encoding layer is used as the value vector V.

[0141] The query vector , key vector , value vector , .

[0142] According to an embodiment of the present disclosure, for each decoding layer in the encoder 320, in the multi-head self-attention module 511, the query vector , key vector Sum value vector Linear Projection By using multi-head attention, we can get Group , and , where H is the number of heads in the multi-head self-attention module 511, , a typical setting is , which is equivalent to dividing the feature length of the feature vector. Each head in the multi-head self-attention module 511 can process D / H-dimensional features; the weight matrix , and These are all learnable parameters of the linear projection layer.

[0143] According to an embodiment of the present 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 is the transpose operation, is the first in the multi-head self-attention module 511 The output of the head.

[0146] According to an embodiment of the present disclosure, the outputs of all heads in the multi-head self-attention module 511 are concatenated in the feature dimension and fed to a weight parameter The linear layer is used to generate the final output, that is, the output of the multi-head self-attention module 511 can be expressed as the following formula (5).

[0147] (5)

[0148] in, is the first in the multi-head self-attention module 511 The output of the head, the symbol Cat represents the concatenation function.

[0149] In operation S620, the output of the multi-head self-attention module and the feature vector are added and normalized to obtain the input of the feedforward network of the x-th encoding layer.

[0150] According to an embodiment of the present 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 by 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 to obtain the output of the feedforward network.

[0152] According to an embodiment of the present disclosure, the input of the feedforward network 513 is input into the feedforward network 513 to obtain the output of the feedforward network.

[0153] In operation S640, the input of the feedforward network and the output of the feedforward network are added and normalized to obtain the output of the x-th encoding layer.

[0154] According to an embodiment of the present disclosure, the feedforward network 513 and the addition and layer normalization module 514 form a residual connection, the output of the feedforward network is added to the input of the feedforward network, and the added vector is normalized to obtain the output of the xth coding layer.

[0155] In operation S650, it is determined whether the second loop round is consistent with the number of layers of the encoder.

[0156] According to an embodiment of the present disclosure, when the second loop round is inconsistent with the number of layers of the encoder, the above operations S610 to S640 are performed; when the second loop round is consistent with the number of layers of the encoder, operation S660 is performed.

[0157] In operation S660, the output of the encoding layer obtained when the second cycle number is consistent with the number of layers of the encoder is determined as the electrocardiogram encoding feature.

[0158] According to an embodiment of the present disclosure, when the second cycle number is X, the output of the encoding layer obtained after this cycle is determined as the electrocardiogram encoding feature.

[0159] According to an embodiment of the present disclosure, the electrocardiogram features and the first position code are input into the encoder 320, and the multi-head self-attention module 511 in each encoding layer of the encoder 320 is used to focus on different positions in the input features to capture position dependencies and improve the expressiveness of the model. In addition, based on the residual connection formed by the multi-head self-attention module 511 in each encoding layer and the addition and layer normalization module 512 and the residual connection formed by the feedforward network 513 and the addition and layer normalization module 514, the problem of gradient disappearance is alleviated. Thus, the electrocardiogram features are input into the encoder 320 to extract the electrocardiogram coding features.

[0160] Figure 7 The flowchart for obtaining the output of the yth decoding layer according to an embodiment of the present disclosure is schematically shown.

[0161] like Figure 7 As shown, the method 700 includes operations S710 to S760.

[0162] In operation S710, the decoder embedding corresponding to the yth decoding layer and the second position encoding are used as the key vector and the query vector, and the decoder embedding corresponding to the yth decoding layer is input as the value vector into the multi-head self-attention module of the yth decoding layer to obtain the output of the multi-head self-attention module of the yth decoding layer.

[0163] According to an embodiment of the present disclosure, considering that the key K in the multi-head cross attention module 524 in each decoding layer in the decoder 330 contains two parts of information, namely, the content part (ECG encoding feature) and the position part (first position encoding), a dual query mode consisting of content queries and positional queries is introduced in the multi-head self-attention module 521. Among them, 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 an embodiment of the present disclosure, in order to make the position similarity of the query vector Q and the key vector K in the multi-head cross attention module 524 in each decoding layer more consistent, it is selected to directly learn the bounding box, and the second position encoding can be derived from the bounding box through the position encoding function of the above formula (1) and formula (2).

[0165] According to the embodiments of the present disclosure, is the first A frame, , given a bounding box Derived Location Queries It can be expressed as the following formula (6).

[0166] (6)

[0167] Among them, PE can represent the position encoding function that maps floating point numbers to D-dimensional sine embeddings , that is, the above formula (1) and formula (2), the hyperparameter T used in the position encoding function here is 20; the symbol Cat represents the connection function; MLP is represented as a multi-layer perceptron, that is, the MLP model 523 in each decoding layer, , projecting the 2D vector into D dimension to obtain a second position code, the MLP model 523 includes two fully connected layers and the parameters are shared between all decoding layers; and are the content query and position query corresponding to the y-th decoding layer, and D is the dimension of the decoder embedding and the second position encoding.

[0168] According to an embodiment of the present disclosure, the multi-head self-attention module 521 in each decoding layer in the decoder 330 can be used for query Q updating (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 the present 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 the present 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 the present disclosure, by taking the decoder embedding corresponding to the yth decoding layer and the second position encoding as the key vector and the query vector, the decoder embedding corresponding to the yth decoding layer is input as a value vector into the multi-head self-attention module 521 of the yth decoding layer to obtain the output of the multi-head self-attention module 521 of the yth decoding layer.

[0175] In operation 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 the present 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 added vector is normalized to obtain a normalized vector.

[0177] In operation S730, the normalized vector and the second position code are used as query vectors, the first position code and the electrocardiogram code features are used as key vectors, and the electrocardiogram code features are used as value vectors 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 the present 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 to obtain the output of the multi-head cross-attention module 524.

[0179] According to an embodiment of the present 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, is the output of the multi-head self-attention module 521 in the y-th decoding layer, Representation layer normalization function, is the content query corresponding to the y-th decoding layer, It is the position query corresponding to the y-th decoding layer.

[0182] According to an embodiment of the present 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, is the position in the electrocardiogram encoding feature output by the encoder 320 The eigenvector at is the position code corresponding to position x, is the vector corresponding to position x in the key vector.

[0185] According to an embodiment of the present 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, is the vector corresponding to position x in the value vector.

[0188] In operation S740, 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 the present disclosure, the multi-head cross-attention module 524 forms a residual connection with the addition and layer normalization module 525, the output of the multi-head cross-attention module 524 is added to the normalized vector, and the added vector is normalized to obtain the input of the feedforward network 526.

[0190] In operation S750, the input of the feedforward network is input into the feedforward network to obtain the output of the feedforward network.

[0191] According to an embodiment of the present disclosure, the input of the feedforward network is input into the feedforward network 527 to obtain the output of the feedforward network.

[0192] In operation S760, the output of the feedforward network and the input of the feedforward network are added and normalized to obtain the output of the yth decoding layer.

[0193] According to an embodiment of the present disclosure, the feedforward network 526 forms a residual connection with the addition and layer normalization module 527, the input of the feedforward network 526 is added to the output of the feedforward network 526, and the added vector is normalized to obtain the output of the yth decoding layer.

[0194] According to an embodiment of the present disclosure, for each decoding layer in the 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 position of the heartbeat according to the similarity between the query vector and the key vector, so as to continuously approach the true heartbeat by updating the query vector of the multi-head cross-attention module 524 layer by layer, so as to achieve accurate prediction of the heartbeat type and position bounding box.

[0195] According to an embodiment of the present disclosure, the decoder embedding corresponding to the first decoding layer is obtained by the following operations, including: randomly generating N reference heart beats, and determining the learnable embedding vectors corresponding to each of the N reference heart beats as the decoder embedding corresponding to the N reference heart beats, wherein N is an integer greater than M; randomly selecting Q heart beats from the M heart beats of the target electrocardiogram segment, wherein Q=PN; performing label flipping on the category labels of the Q heart beats to obtain Q reference heart beats, wherein the Q reference heart beats are marked with noise labels after label flipping; based on the noise labels of the Q reference heart beats, generating label embedding vectors corresponding to each of the Q reference heart beats, and determining the decoder embedding corresponding to the batch of Q parameters based on the label embedding vectors; based on the decoder embeddings corresponding to the N reference heart beats and the decoder embeddings corresponding to the Q reference heart beats, combining and generating the decoder embedding corresponding to the first decoding layer.

[0196] According to an embodiment of the present disclosure, the initial query of the first decoding layer of the decoder 330 needs to prepare the initial decoder embeddings and the initial bounding box respectively. Here, the initial bounding box (Boxes) adopts a fixed frame width and uniformly distributed center points. For example, the width of the initial bounding box can be 400ms.

[0197] According to an embodiment of the present disclosure, N reference heart beats may be randomly generated first, wherein N needs to be much larger than the possible M to ensure that the number of predicted heart beats output by the model is significantly larger than the possible number of heart beats in the electrocardiogram segment.

[0198] According to an embodiment of the present disclosure, before performing loss calculation based on the predicted results of the output of each decoding layer of the decoder 330 to update the parameters of the adjustment model, it is necessary to first match the predicted heartbeat with the true heartbeat. Therefore, in order to avoid instability problems caused by matching, denoising training (DN) is introduced in the process of training the model, that is, for the initial query of the first decoding layer of the decoder 330, a part of noise queries based on the true heartbeat are introduced.

[0199] According to an embodiment of the present disclosure, the noise query is also composed of a content query and a position query. The noise label can generate a part of the initial content query of the decoder 330 for the first decoding layer, and the noise bounding box can generate a part of the initial position query of the decoder 330 for the first decoding layer.

[0200] According to an embodiment of the present disclosure, Q heartbeats can be randomly selected from the M heartbeats in the target electrocardiogram segment, and label flipping can be used to flip the category labels of the Q heartbeats, so as to randomly flip the category labels of the Q heartbeats to other labels to obtain Q reference heartbeats, wherein the Q reference heartbeats are marked with noise labels, and the noise labels are obtained after the corresponding category labels are flipped.

[0201] Among them, you can also use hyperparameters To control the ratio of label flipping in Q heart beats; in the actual application reasoning stage of the model, Q=0, that is, no noise query is introduced in the actual application process.

[0202] According to an embodiment of the present disclosure, since the decoder embedding corresponding to the first decoding layer includes vectors corresponding to Q reference heartbeats for representing noise queries, and the true heartbeats corresponding to the Q reference heartbeats can be directly determined, the prediction results corresponding to the Q reference heartbeats and the category labels of the true heartbeats corresponding to the Q reference heartbeats can be directly calculated for loss subsequently to alleviate the instability problem caused by matching.

[0203] According to an embodiment of the present disclosure, the second position code corresponding to the first decoding layer is obtained by the following operations, including: randomly generating N bounding boxes of reference heart beats; adding random noise to the two-dimensional true value bounding boxes of Q heart beats to obtain bounding boxes of Q reference heart beats; using a position encoding function to generate an initial position code based on the bounding boxes of N reference heart beats and the bounding boxes of Q reference heart beats; inputting the initial position code into a multilayer perceptron, and outputting the second position code corresponding to the first decoding layer.

[0204] According to an embodiment of the present disclosure, a bounding box corresponding to each of the N reference heart beats may be randomly generated. Random noise may be added to the two-dimensional true value bounding box of the Q heart beats to obtain a noise bounding box, i.e., a bounding box of the Q reference heart beats. A position encoding function may be used to first generate an initial position encoding, and then an MLP (multi-layer perceptron) 523 may be used to obtain a second position encoding corresponding to the first decoding layer.

[0205] According to the embodiment of the present disclosure, based on the two-dimensional true value bounding box, a noise bounding box can be generated by using a center moving method. The noise scale λ can be set as needed to control the random generation of the noise bounding box, and random noise can be added to the center of the two-dimensional true value bounding box. To achieve center movement and ensure , so that the center of the moved box is still within the original bounding box, where w refers to the width of the corresponding two-dimensional true value bounding box, to further consider contrastive denoising training (CDN) to help the model avoid repeated output of the same prediction target.

[0206] According to an embodiment of the present disclosure, in contrast denoising training, by setting and Two different noise scales are used to generate positive and negative queries. Positive queries have a noise level less than The noise scale is , and it is expected to reconstruct its corresponding ground truth box. The negative query has a noise scale greater than and less than The noise scale of is expected to be predicted as "Non-obj", where the smaller It is usually adopted because hard samples that are closer to the 2D ground-truth bounding box are more helpful in improving performance.

[0207] For example, for denoising training, you can set , and To control the noise level.

[0208] According to the embodiments of the present disclosure, due to the initial content query generated based on the noise label and the initial position query generated based on the noise bounding box, the corresponding prediction results can be reconstructed from the noise label and the noise bounding box, so that the prediction result corresponding to the noise query can bypass matching and directly calculate its loss with the corresponding true heartbeat, alleviating the instability problem caused by matching.

[0209] According to an embodiment of the present disclosure, the category labels and two-dimensional true value bounding box labels of M heart beats in the target electrocardiogram segment are respectively compared with the classification prediction results and prediction bounding boxes of P reference heart beats to obtain classification loss values ​​and bounding box loss values, including: filling the true value results of NM non-target heart beats into the initial true value arrangement to obtain the target true value arrangement; sorting the prediction results of N reference heart beats to obtain multiple prediction arrangements; for each prediction arrangement, according to the target true value arrangement and the prediction arrangement, calculating the classification prediction probability value, intersection-over-union ratio and L1 norm; according to the classification prediction probability value, intersection-over-union ratio and L1 norm corresponding to the prediction arrangement, calculating the matching cost corresponding to the prediction arrangement; and determining the arrangement with the smallest corresponding matching cost among the multiple prediction arrangements as the target prediction arrangement.

[0210] The initial truth value arrangement includes the true value results of each of the M heart beats, and the true value results of each of the M heart beats in the target electrocardiogram segment can be obtained from the target truth value set The target truth value arrangement includes the true value results of each of the N heartbeats. The true value results include the category label corresponding to the heartbeat and the two-dimensional true value bounding box label. The arrangement of the true value results of each of the N heartbeats in the target truth value arrangement is fixed. The prediction result (Prediction) 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 category label in the prediction arrangement and the target truth value arrangement is consistent with the classification prediction result.

[0211] According to an embodiment of the present disclosure, content queries and location queries for the decoder 330 are both for P reference heartbeats, and the classification prediction results and prediction bounding boxes obtained by output prediction of each decoding layer in the decoder 330 are also for P reference heartbeats, and the P reference heartbeats include Q reference heartbeats generated by the target ECG segment. Since the target ECG segment includes M heartbeats, P is much larger than M, and the prediction results corresponding to the Q reference heartbeats can directly determine the corresponding heartbeats in the target ECG segment, that is, the prediction results corresponding to the Q reference heartbeats do not need to be matched, then the prediction results corresponding to N=PQ reference heartbeats need to be matched first. In order to ensure that each prediction result can correspond to the true value result one-to-one 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 the embodiments of the present disclosure, Figure 3 In the matching (Matching) 340 shown in , the left side is the prediction arrangement (Predictions) and the right side is the target true value arrangement (Ground Truth).

[0213] According to an embodiment of the present disclosure, since the prediction results corresponding to the N reference heartbeats are not directly paired with the true value results, during training, it is necessary to calculate the loss based on the optimal two-part matching between the target true value arrangement and multiple prediction arrangements.

[0214] According to an embodiment of the present disclosure, the Hungarian algorithm can be used to effectively calculate the optimal bipartite matching in two sets from the cost matrix of the object, that is, to find the N elements with the minimum matching cost. The predicted arrangement of can be expressed as the following formula (13).

[0215] (13)

[0216] in, is the true value result in the target true value arrangement Prediction results in the prediction array The pairwise matching cost between Can be expressed as a predicted arrangement.

[0217] According to an embodiment of the present disclosure, the prediction results corresponding to N reference heart beats are arranged to obtain a plurality of prediction arrangements, so as to calculate the matching cost for each prediction arrangement and the target true value arrangement, so that the prediction arrangement with the minimum matching cost can be determined by the above formula (13) for use in loss calculation with the true value results in the target true value arrangement.

[0218] According to an embodiment of the present disclosure, the matching cost includes a position cost and a classification cost. , define the predicted bounding box as ,definition The classification prediction probability value of the class is , where the classification is The negative probability of the class is used as the classification cost, and 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 an embodiment of the present disclosure, for a predicted arrangement and a target true value arrangement, the intersection-over-union ratio corresponding to the predicted arrangement can be calculated by the following formula (14).

[0220] (14)

[0221] According to an embodiment of the present disclosure, for a predicted arrangement and a target true value arrangement, the L1 norm corresponding to the predicted arrangement can be calculated by the following formula (15).

[0222] (15)

[0223] in, Indicates the length of the box, Indicates the length of the smallest interval that can cover two bounding boxes.

[0224] According to an embodiment of the present disclosure, based on the classification prediction probability value, intersection-over-union ratio and L1 norm corresponding to a certain prediction arrangement, the matching cost corresponding to the prediction arrangement can be calculated. The calculation formula of the matching cost can be expressed as the following formula (16).

[0225] (16)

[0226] in, , , is a hyperparameter, Indicates that the corresponding true value result is not a non-target heartbeat. The value is 1, otherwise the value is 0.

[0227] According to an embodiment of the present disclosure, the corresponding matching costs of multiple prediction arrangements are calculated using the above formula (16) to determine the arrangement with the smallest matching cost as the target prediction arrangement.

[0228] According to an embodiment of the present disclosure, for the prediction results corresponding to N reference heart beats, it is necessary to first match and then calculate the loss to avoid a large error in the loss value calculated in the case of mismatch. 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 that the prediction arrangement matches the target true value arrangement, the prediction arrangement with the smallest matching cost is determined as the target prediction arrangement, so that the target prediction arrangement and the target true value arrangement can be used for loss calculation to avoid a large error in loss calculation caused by matching problems.

[0229] According to an embodiment of the present disclosure, the above-mentioned model training method also includes: using a classification loss function to calculate a first classification loss value according to a predicted probability value corresponding to a target prediction arrangement; using a bounding box loss function to calculate a first bounding box loss value according to an intersection-and-union ratio and an L1 norm corresponding to the target prediction arrangement; calculating a classification prediction probability value corresponding to the Q reference heartbeats according to 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; using a classification loss function to calculate a second classification loss value according to the classification prediction probability value corresponding to the Q reference heartbeats; calculating an intersection-and-union ratio and an L1 norm corresponding to the Q reference heartbeats according to the predicted bounding boxes of each of the Q reference heartbeats and the two-dimensional true value bounding box labels of each of the Q heartbeats corresponding to the Q reference heartbeats; using a bounding box loss function to calculate a second bounding box loss value according to the intersection-and-union ratio and the L1 norm corresponding to the Q reference heartbeats.

[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 an embodiment of the present disclosure, since the prediction results corresponding to P reference heart beats include prediction results corresponding to N randomly generated reference heart beats and prediction results corresponding to Q reference heart beats generated based on target electrocardiogram segments, the loss values ​​corresponding to the N reference heart beats can be calculated based on the target prediction arrangement, and the loss values ​​corresponding to the Q reference heart beats can be calculated based on the prediction results of the Q reference heart beats and the corresponding true value results.

[0232] According to an embodiment of the present disclosure, when the target prediction arrangement is determined, a classification loss function can be used to calculate a first classification loss value according to the prediction probability value corresponding to the target prediction arrangement. The classification loss function can be expressed as the following formula (17).

[0233] (17)

[0234] Among them, In the case of , while in other cases .

[0235] According to an embodiment of the present disclosure, a first bounding box loss value can be calculated using a bounding box loss function according to an intersection-over-union ratio and an L1 norm corresponding to a 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 for adjusting the loss weight. The bounding box loss function is a linear combination of the L1 norm loss and the one-dimensional GIoU loss.

[0238] According to an embodiment of the present disclosure, based on the classification prediction results of each of the Q reference heart beats and the category labels in the true value results of each of the Q heart beats corresponding to the Q reference heart beats, the classification prediction probability values ​​corresponding to the Q reference heart beats can be calculated, and the second classification loss value can be calculated based on the classification prediction probability values ​​corresponding to the Q reference heart beats using the classification loss function, that is, through the above formula (17).

[0239] According to an embodiment of the present disclosure, based on the predicted bounding boxes of the Q reference heartbeats and the two-dimensional true bounding box labels of the Q heartbeats corresponding to the Q reference heartbeats, the intersection-and-union ratio and L1 norm corresponding to the Q reference heartbeats can be calculated by the above formula (14) and formula (15). Using the bounding box loss function, that is, by the above formula (18), the second bounding box loss value can be calculated based on the intersection-and-union ratio and L1 norm corresponding to the Q reference heartbeats.

[0240] According to an embodiment of the present disclosure, considering the linear combination of the classification loss value and the bounding box loss value, the total loss can be calculated by the following formula (19).

[0241] (19)

[0242] in, is the classification loss coefficient.

[0243] According to the embodiments of the present disclosure, since the Q reference heartbeats can directly determine the category label and the two-dimensional true value bounding box label in the corresponding real result, there is no need to perform matching first. The second classification loss value and the second bounding box loss value can be directly calculated according to the Q reference heartbeats and the corresponding Q heartbeats through the above formulas (17) and (18), so that the parameters of the model can be adjusted according to the second classification loss value and the second bounding box loss value to alleviate the problem of unstable matching to a certain extent.

[0244] According to an embodiment of the present disclosure, in the process of training an atrial fibrillation heartbeat detection model, an adaptive moment estimation algorithm (Adam optimizer) can be used to optimize the model. Similarly, the hyperparameters involved in the model can also be determined by grid search and cross validation to fine-tune these parameters. The cost coefficient of the bipartite matching in the above formula (16) is ; The loss function coefficient in the above formula (19) .

[0245] According to an embodiment of the present 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 of learning rate with the training cycle can be expressed as the following formula (20).

[0246] (20)

[0247] in, is the number of cycles of the current training. is the total number of training rounds. In this disclosure, Can be set to 30.

[0248] Figure 8 The flowchart of the atrial fibrillation heartbeat detection method according to the embodiment of the present disclosure is schematically shown.

[0249] like Figure 8 As shown, the method 800 includes operation S810 and operation S820.

[0250] In operation S810, the electrocardiogram record to be detected is sampled to a target sampling frequency, and the electrocardiogram record to be detected at the target sampling frequency is segmented into a plurality of electrocardiogram segments to be detected according to a target time period.

[0251] According to an embodiment of the present disclosure, since the obtained electrocardiogram segments to be detected need to be input into an atrial fibrillation heartbeat detection model later, in order to improve the accuracy of the output, the electrocardiogram records to be detected need to be sampled to a target sampling frequency and segmented according to a target time period, wherein 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 target time period.

[0252] In operation S820, for each electrocardiogram segment to be detected, the electrocardiogram segment to be detected is input into an atrial fibrillation heartbeat detection model, and a classification prediction result and a prediction bounding box corresponding to each heartbeat in the electrocardiogram segment to be detected are output.

[0253] According to an embodiment of the present disclosure, the atrial fibrillation heartbeat detection model is obtained by performing the above-mentioned operations S210 to S221. The classification prediction result can indicate that the heartbeat is one of an atrial fibrillation heartbeat, a non-atrial fibrillation heartbeat, and a non-target heartbeat, that is, the classification prediction result can be used to determine the atrial fibrillation heartbeat in the electrocardiogram segment to be detected. The predicted bounding box can be used to determine the position of the heartbeat in the electrocardiogram segment to be detected.

[0254] According to the embodiments of the present disclosure, due to the use of the atrial fibrillation heartbeat detection model, it is possible to provide beat-level predictions, effectively avoiding the feature ambiguity problem caused by the electrocardiogram segments containing both atrial fibrillation segments and non-atrial fibrillation segments, thereby achieving accurate and rapid detection of atrial fibrillation heartbeats in the electrocardiogram segments and effectively locating the atrial fibrillation heartbeats.

[0255] According to the embodiments of the present disclosure, in the process of training the atrial fibrillation heartbeat detection model, a positioning task is introduced on the basis of the classification task to fully extract the rhythm position information of the electrocardiogram segment, which helps the model to make more accurate atrial fibrillation heartbeat detection according to the global rhythm position information, ensures the generalization ability of the model in real application scenarios, and can also achieve robust atrial fibrillation heartbeat detection; and in the process of training the atrial fibrillation heartbeat detection model, the position query of the decoder is constructed using the two-dimensional true value bounding box coordinates representing the heartbeat position, and the decoder updates the bounding box layer by layer iteratively, so as to effectively locate the atrial fibrillation heartbeat; in the process of training the atrial fibrillation heartbeat detection model, denoising training is also introduced to stabilize the two-part matching, and through the contrast denoising mechanism, positive noise samples and negative noise samples with the same true value are added at the same time through two scales of noise scales to help the model avoid repeated detection of the same heartbeat; at the same time, the present disclosure adopts an end-to-end implementation method, and implicitly performs the heartbeat positioning task when performing atrial fibrillation heartbeat detection, avoiding the multi-step processing of first locating and segmenting the heartbeat and then performing atrial fibrillation detection in the prior art.

[0256] Based on the above model training method, the present disclosure also provides a model training device. Fig. 9 The device is described in detail.

[0257] Fig. 9 The structural block diagram of the model training device according to an embodiment of the present disclosure is schematically shown.

[0258] like Fig. 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 ECG record sample in the sample set to obtain a target ECG segment, wherein the target ECG segment includes M heartbeats, M is an integer greater than or equal to 1, and each heartbeat is marked with a category label and a two-dimensional true value bounding box label, and 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 ECG segment into the feature extraction network and output the ECG feature corresponding to the target ECG segment. In one embodiment, the first input module 911 can be used to perform the operation S211 described above, which will not be described in detail here.

[0261] The construction module 912 is used to construct a first position code corresponding to the electrocardiogram feature using the position code function. In one embodiment, the construction module 912 can be used to perform the operation S212 described above, which will not be described in detail here.

[0262] The second input module 913 is used to input the electrocardiogram feature and the first position code into the encoder, and output the electrocardiogram code feature. 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 coding features, the first position code, the decoder embedding corresponding to the yth decoding layer and the second position code into the yth decoding layer when it is determined that the first cycle round is inconsistent with the number of layers of the decoder, so as to obtain the output of the yth decoding layer, wherein the decoder includes Y decoding layers, y is an integer greater than or equal to 1 and less than or equal to Y; the decoder embedding corresponding to the yth decoding layer is the output of the y-1th decoding layer, and the second position code corresponding to the yth decoding layer is constructed according to the P bounding boxes obtained by updating the output of the y-1th 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 yth decoding layer into the bounding box prediction head of the yth 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 updating module 916 is used to update the P bounding boxes using the offsets corresponding to the P bounding boxes, and obtain the P predicted bounding boxes updated by the output of the y-th decoding layer. In one embodiment, the updating 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 the P reference heart beats corresponding to the decoder embedding, wherein the prediction bounding box corresponds to the reference heart beat one by one, and the prediction bounding box is used to characterize the position of the reference heart beat 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 calculate the loss of the category labels and two-dimensional true bounding box labels of the M heart beats in the target electrocardiogram segment and the classification prediction results and prediction bounding boxes of the P reference heart beats, respectively, to obtain the classification loss value and the bounding box loss value. 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 according to the classification loss value and the bounding box loss value to obtain an 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 obtaining module 920 is used to obtain the atrial fibrillation heartbeat detection model when the first cycle round is consistent with the number of layers of the decoder. In one embodiment, the second obtaining module 920 can be used to perform the operation S221 described above, which will not be repeated here.

[0270] According to an embodiment of the present disclosure, the preprocessing module 910 includes a sampling unit, a filtering unit, a segmentation unit, a first obtaining unit, and a labeling unit.

[0271] The sampling unit is used to sample each electrocardiogram record sample in the sample set to a target sampling frequency.

[0272] The filtering unit is used to filter each electrocardiogram record sample at the target sampling frequency to obtain a filtered electrocardiogram record sample.

[0273] The segmentation unit is used to segment each filtered electrocardiogram record sample into a plurality of electrocardiogram segments according to a target time period.

[0274] The first obtaining unit is used to normalize the multiple electrocardiogram segments to obtain normalized electrocardiogram segments.

[0275] The labeling unit is used to label the normalized electrocardiogram segment with a category label and a two-dimensional true value bounding box label to obtain a target electrocardiogram segment.

[0276] According to an embodiment of the present 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 input the target electrocardiogram segment into the first convolution layer and the pooling layer in sequence, and output a first feature vector.

[0278] The second input unit is used to input the first eigenvector into the residual block to obtain a second eigenvector.

[0279] The adjustment unit is used to use the second convolution layer to adjust the feature dimension length of the second feature vector to obtain the electrocardiogram feature, wherein the time dimension length of the electrocardiogram feature is determined by the kernel size of the convolution layer, and the feature dimension length of the electrocardiogram feature is determined by the step size of the pooling layer.

[0280] According to an embodiment of the present 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 it is determined that the second cycle round is inconsistent with the number of layers of the encoder, use the feature vector corresponding to the x-th encoding layer and the first position code as the query vector and the key vector, and input the feature vector corresponding to the x-th encoding layer as the value vector into the multi-head self-attention module of the x-th encoding layer to obtain the output of the multi-head self-attention module of the x-th encoding layer, wherein the encoder includes X encoding layers, 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 encoding layer is the output of the x-1-th encoding layer; when x is 1, the feature vector corresponding to the 1st encoding layer is the electrocardiogram feature.

[0282] The second acquisition unit is used to add and normalize the output and feature vector of the multi-head attention module to obtain the input of the feedforward network of the x-th encoding 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 obtaining unit is used to add and normalize the input of the feedforward network and the output of the feedforward network to obtain the output of the xth encoding layer.

[0285] The first determining unit determines the output of the encoding layer obtained when the second cycle round is consistent with the number of layers of the encoder as the electrocardiogram encoding feature.

[0286] According to an embodiment of the present 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 input the decoder embedding corresponding to the yth decoding layer and the second position encoding as the key vector and the query vector, and the decoder embedding corresponding to the yth decoding layer as the value vector into the multi-head self-attention module of the yth decoding layer to obtain the output of the multi-head self-attention module of the yth decoding layer.

[0288] The fourth obtaining 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 electrocardiogram code feature as the key vector, and the electrocardiogram code 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 obtaining 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 of the feedforward network and the input of the feedforward network to obtain the output of the yth decoding layer.

[0293] According to an embodiment of the present disclosure, the first obtaining module 918 includes a filling unit, a sorting unit, a first calculating unit, a second calculating unit, and a second determining unit.

[0294] A filling unit is used to fill the true value results of NM non-target heart beats into the initial true value arrangement to obtain a target true value arrangement, wherein the initial true value arrangement includes the true value results of each of the M heart beats, the target true value arrangement includes the true value results of each of the N heart beats, the true value results include the category labels corresponding to the heart beats and the two-dimensional true value bounding box labels, and the arrangement of the true value results of each of the N heart beats in the target true value arrangement is fixed.

[0295] A sorting unit, used to sort the prediction results of each of the N reference heart beats to obtain a plurality of 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, the intersection-over-union ratio and the L1 norm for each prediction arrangement according to the target true value arrangement and the prediction arrangement, wherein the classification prediction probability value represents the probability that the corresponding category label in the prediction arrangement and the target true value arrangement is consistent with the classification prediction result.

[0297] The second calculation unit is used to calculate the matching cost corresponding to the predicted arrangement according to the classification prediction probability value, intersection-over-union ratio and L1 norm corresponding to the predicted arrangement.

[0298] The second determining unit is used to determine the arrangement with the smallest corresponding matching cost among the multiple predicted arrangements as the target predicted arrangement.

[0299] According to an embodiment of the present disclosure, the first obtaining module 918 further includes a third calculating unit, a fourth calculating unit, a fifth calculating unit, a sixth calculating unit, a seventh calculating unit and an eighth calculating unit.

[0300] The third calculation unit is used to calculate a first classification loss value by using a classification loss function according to a prediction probability value corresponding to a target prediction arrangement.

[0301] The fourth calculation unit is used to calculate a first bounding box loss value by using a bounding box loss function according to an intersection-and-union ratio and an L1 norm corresponding to the target prediction arrangement.

[0302] The fifth calculation unit is used to calculate the classification prediction probability values ​​corresponding to the Q reference heart beats according to the classification prediction results of each of the Q reference heart beats and the category labels of each of the Q heart beats corresponding to the Q reference heart beats.

[0303] The sixth calculation unit is used to calculate a second classification loss value by using a classification loss function according to the classification prediction probability values ​​corresponding to the Q reference heart beats.

[0304] The seventh calculation unit is used to calculate the intersection-and-union ratio and L1 norm corresponding to the Q reference heartbeats according to the predicted bounding boxes of the Q reference heartbeats and the two-dimensional true bounding box labels of the Q heartbeats corresponding to the Q reference heartbeats.

[0305] The eighth calculation unit is used to calculate a second bounding box loss value by using a bounding box loss function according to an intersection-and-union ratio and an L1 norm corresponding to the Q reference heart beats.

[0306] According to an embodiment of the present disclosure, any multiple 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 acquisition module 918, the adjustment module 919 and the second acquisition module 920 can be combined into one module for implementation, or any one of the modules can be split into multiple modules. Alternatively, at least part of the functions of one or more of these modules can be combined with at least part of the functions of other modules and implemented in one module. According to an embodiment of the present 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 acquisition module 918, the adjustment module 919 and the second acquisition module 920 can be at least partially implemented as a hardware circuit, 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 a package, an application-specific integrated circuit (ASIC), or can be implemented by hardware or firmware such as any other reasonable way of integrating or packaging the circuit, or can be implemented in any one of the three implementation methods of software, hardware and firmware or in an appropriate combination of any of them. 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 acquisition module 918, the adjustment module 919 and the second acquisition module 920 can be at least partially implemented as a computer program module, which can perform corresponding functions when the computer program module is executed.

[0307] Based on the above atrial fibrillation heartbeat detection method, the present disclosure also provides an atrial fibrillation heartbeat detection device. Fig.10 The device is described in detail.

[0308] Fig.10 The structural block diagram of the atrial fibrillation heartbeat detection device according to an embodiment of the present disclosure is schematically shown.

[0309] like Fig.10 As shown, the atrial fibrillation detection device 1000 of this embodiment includes a sampling segmentation module 1010 and a sixth input module 1020 .

[0310] The sampling and segmentation module 1010 is used to sample the electrocardiogram record to be detected to the target sampling frequency, and to segment the electrocardiogram record to be detected at the target sampling frequency into multiple electrocardiogram segments to be detected according to the target time period. In one embodiment, the sampling and 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 the ECG segment to be detected into the atrial fibrillation heartbeat detection model for each of the ECG segments to be detected, and output the classification prediction results and prediction bounding boxes corresponding to each heartbeat in the ECG segment to be detected, wherein the classification prediction results are used to determine the atrial fibrillation heartbeat 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 an embodiment of the present disclosure, any multiple modules in the sampling segmentation module 1010 and the sixth input module 1020 can be combined into one module for implementation, or any one of the modules can be split into multiple modules. Alternatively, at least part of the functions of one or more of these modules can be combined with at least part of the functions of other modules and implemented in one module. According to an embodiment of the present disclosure, at least one of the sampling segmentation module 1010 and the sixth input module 1020 can be at least partially implemented as a hardware circuit, 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 a package, an application-specific integrated circuit (ASIC), or can be implemented by hardware or firmware such as any other reasonable way of integrating or packaging the circuit, or implemented in any one of the three implementation methods of software, hardware and firmware or in any appropriate combination of any of them. 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, and when the computer program module is run, the corresponding function can be executed.

[0313] Fig.11 A block diagram of an electronic device suitable for implementing a model training method and an atrial fibrillation heartbeat detection method according to an embodiment of the present disclosure is schematically shown.

[0314] like Fig.11As shown, the 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 part 1108 to a random access memory (RAM) 1103. The processor 1101 may include, for example, a general-purpose microprocessor (such as a CPU), an instruction set processor and / or a related chipset and / or a special-purpose microprocessor (for example, an application-specific integrated circuit (ASIC)), etc. The processor 1101 may also include an 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] In RAM 1103, various programs and data required for the operation of electronic device 1100 are stored. Processor 1101, ROM 1102 and RAM 1103 are connected to each other through bus 1104. Processor 1101 performs various operations of the method flow according to the embodiment of the present disclosure by executing the program in ROM 1102 and / or RAM 1103. It should be noted that the program can also be stored in one or more memories other than ROM 1102 and RAM 1103. Processor 1101 can also perform various operations of the method flow according to the embodiment of the present disclosure by executing the program stored in the one or more memories.

[0316] According to an embodiment of the present disclosure, the electronic device 1100 may further include an input / output (I / O) interface 1105, which is also connected to the bus 1104. The electronic device 1100 may further include one or more of the following components connected to the input / output (I / O) interface 1105: an input portion 1106 including a keyboard, a mouse, etc.; an output portion 1107 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage portion 1108 including a hard disk, etc.; and a communication portion 1109 including a network interface card such as a LAN card, a modem, etc. The communication portion 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 magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1110 as needed, so that a computer program read therefrom is installed into the storage portion 1108 as needed.

[0317] The present disclosure also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or may exist independently without being assembled into the device / apparatus / system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the method according to the embodiment of the present disclosure is implemented.

[0318] According to an embodiment of the present disclosure, a computer-readable storage medium may be a non-volatile computer-readable storage medium, for example, may include but is not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, an apparatus, or a device. For example, according to an embodiment of the present disclosure, a computer-readable storage medium may include the ROM 1102 and / or RAM 1103 described above and / or one or more memories other than ROM 1102 and RAM 1103.

[0319] The embodiment of the present disclosure also includes a computer program product, which includes a computer program, and the computer program includes a program code for executing the method shown in the flowchart. When the computer program product is run in a computer system, the program code is used to enable the computer system to implement the model training method and atrial fibrillation heartbeat detection method provided by the embodiment of the present disclosure.

[0320] The above functions defined in the system / device of the embodiment of the present disclosure are performed when the computer program is executed by the processor 1101. According to the embodiment of the present disclosure, the system, device, module, unit, etc. described above can be implemented by a computer program module.

[0321] In one embodiment, the computer program may rely on tangible storage media such as optical storage devices, magnetic storage devices, etc. In another embodiment, the computer program may also be transmitted and distributed in the form of signals on a network medium, and downloaded and installed through the communication part 1109, and / or installed from a removable medium 1111. The program code contained in the computer program may be transmitted using any appropriate network medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.

[0322] In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 1109, and / or installed from the removable medium 1111. When the computer program is executed by the processor 1101, the above functions defined in the system of the embodiment of the present disclosure are performed. According to the embodiment of the present disclosure, the system, device, means, module, unit, etc. described above can be implemented by a computer program module.

[0323] According to an embodiment of the present disclosure, the program code for executing the computer program provided by the embodiment of the present disclosure can be written in any combination of one or more programming languages. Specifically, these computing programs can be implemented using high-level process and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages ​​include, but are not limited to, Java, C++, python, "C" language or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, partially on the remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (for example, using an Internet service provider to connect through the Internet).

[0324] The flow charts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0325] It will be appreciated by those skilled in the art that the features described in the various embodiments of the present disclosure may be combined and / or combined in a variety of ways, even if such combinations or combinations are not explicitly described in the present disclosure. In particular, without departing from the spirit and teachings of the present disclosure, the features described in the various embodiments of the present disclosure may be combined and / or combined in a variety of ways. All of these combinations and / or combinations fall within the scope of the present disclosure.

[0326] The embodiments of the present disclosure are described above. However, these embodiments are only for illustrative purposes and are not intended to limit the scope of the present disclosure. Although the embodiments are described above, this does not mean that the measures in the various embodiments cannot be used in combination to advantage. Without departing from the scope of the present disclosure, those skilled in the art may make a variety of substitutions and modifications, which should all fall within the scope of the present disclosure.

Claims

1. A model training method, comprising: Preprocessing each electrocardiogram recording sample in the sample set to obtain a target electrocardiogram segment, wherein the target electrocardiogram segment includes M heartbeats, M is an integer greater than or equal to 1, and each heartbeat is marked with a category label and a two-dimensional true value bounding box label, and the category label is used to characterize whether the heartbeat is an atrial fibrillation heartbeat; Inputting the target electrocardiogram segment into a feature extraction network, and outputting an electrocardiogram feature corresponding to the target electrocardiogram segment; Using the position coding function, constructing a first position coding corresponding to the electrocardiogram feature; Inputting the electrocardiogram feature and the first position code into an encoder, and outputting the electrocardiogram code feature; Repeat the following operations until the first cycle is consistent with the number of layers of the decoder to obtain an atrial fibrillation heartbeat detection model: In the case where it is determined that the first cycle round is inconsistent with the number of layers of the decoder, Inputting the electrocardiogram encoding feature, the first position code, the decoder embedding corresponding to the yth decoding layer, and the second position code into the yth decoding layer to obtain the output of the yth decoding layer, wherein the decoder includes Y decoding layers, y is an integer greater than or equal to 1 and less than or equal to Y; the decoder embedding corresponding to the yth decoding layer is the output of the y-1th decoding layer, and the second position code corresponding to the yth decoding layer is constructed according to P bounding boxes obtained by updating the output of the y-1th decoding layer, where P is an integer greater than M; Inputting the output of the y-th decoding layer into the bounding box prediction head of the y-th decoding layer, and outputting the offset corresponding to each of the P bounding boxes; Using the offsets corresponding to the P bounding boxes, the P bounding boxes are updated to obtain P predicted bounding boxes updated by the output of the y-th decoding layer; Inputting the output of the y-th decoding layer into the classification prediction head of the y-th decoding layer, and outputting the classification prediction results of the P reference heart beats corresponding to the decoder embedding, wherein the prediction bounding box corresponds to the reference heart beat one by one, and the prediction bounding box is used to represent the position of the reference heart beat in the target electrocardiogram segment; Perform loss calculation on the category labels and two-dimensional true bounding box labels of the M heartbeats in the target electrocardiogram segment and the classification prediction results and prediction bounding boxes of the P reference heartbeats to obtain classification loss values ​​and bounding box loss values; According to the classification loss value and the bounding box loss value, the model parameters of the model to be trained are adjusted to obtain an 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 recording sample in the sample set to obtain a target electrocardiogram segment includes: Sampling each electrocardiogram recording sample in the sample set to a target sampling frequency; Performing filtering processing on each electrocardiogram record sample at the target sampling frequency to obtain a filtered electrocardiogram record sample; Segmenting each of the filtered electrocardiogram recording samples into a plurality of electrocardiogram segments according to a target time period; Normalizing the multiple electrocardiogram segments to obtain normalized electrocardiogram segments; and The normalized electrocardiogram segment is labeled with a category label and a two-dimensional true value bounding box label to obtain the target electrocardiogram segment.

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 a residual block, and the target electrocardiogram segment is input into the feature extraction network, and the electrocardiogram feature corresponding to the target electrocardiogram segment is output, including: Inputting the target electrocardiogram segment into the first convolutional layer and the pooling layer in sequence, and outputting a first feature vector; Inputting the first eigenvector into the residual block to obtain a second eigenvector; The second convolutional layer is used to adjust the feature dimension length of the second feature vector to obtain the electrocardiogram feature, wherein the time dimension length of the electrocardiogram feature is determined by the kernel size of the convolutional layer, and the feature dimension length of the electrocardiogram feature is determined by the step size of the pooling layer.

4. The method according to claim 1, wherein: The step of inputting the electrocardiogram feature and the first position code into an encoder and outputting the electrocardiogram code feature comprises repeatedly performing the following operations until the second cycle round is consistent with the number of layers of the encoder: When it is determined that the second cycle number is inconsistent with the number of layers of the encoder, Taking the feature vector corresponding to the x-th coding layer and the first position code as the query vector and the key vector, and inputting 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, wherein the encoder includes X coding layers, 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; Adding and normalizing the output of the multi-head attention module and the feature vector to obtain the input of the feedforward network of the x-th encoding layer; Inputting the input of the feedforward network into the feedforward network to obtain the output of the feedforward network; Adding and normalizing the input of the feedforward network and the output of the feedforward network to obtain the output of the x-th encoding layer; The output of the encoding layer obtained when the second cycle round is consistent with the number of layers of the encoder is determined as the electrocardiogram encoding feature.

5. The method according to claim 1, wherein: The step of inputting the electrocardiogram encoding feature, the first position code, the decoder embedding corresponding to the yth decoding layer, and the second position code into the yth decoding layer to obtain the output of the yth decoding layer includes: Using the decoder embedding corresponding to the y-th decoding layer and the second position encoding as a key vector and a query vector, and inputting the decoder embedding corresponding to the y-th decoding layer as a value vector into the multi-head self-attention module of the y-th decoding layer, to obtain an output of the multi-head self-attention module of the y-th decoding layer; Adding and normalizing the output of the multi-head self-attention module and the decoder embedding to obtain a normalized vector; Using the normalized vector and the second position code as a query vector, using the first position code and the electrocardiogram encoding feature as a key vector, and inputting the electrocardiogram encoding feature as a value vector into the multi-head cross-attention module of the y-th decoding layer to obtain an output of the multi-head cross-attention module of the y-th decoding layer; Adding and normalizing 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; Inputting the input of the feedforward network 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 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 by the following operations, including: Randomly generate N reference heartbeats, and determine the learnable embedding vectors corresponding to each of the N reference heartbeats as decoder embeddings corresponding to the N reference heartbeats, where N is an integer greater than M; Randomly select Q heart beats from the M heart beats of the target electrocardiogram segment, where Q is an integer greater than 1, Q=PN; Flipping the category labels of the Q heartbeats to obtain Q reference heartbeats, wherein the Q reference heartbeats are marked with noise labels after the label flipping; Generate a label embedding vector corresponding to each of the Q reference heart beats according to the noise labels of the Q reference heart beats, and determine the label embedding vector as a decoder embedding corresponding to the Q reference heart beats; A decoder embedding corresponding to the first decoding layer is generated based on the decoder embedding corresponding to the N reference heartbeats and the decoder embedding corresponding to the Q reference heartbeats.

7. The method according to claim 6, wherein: The second position code corresponding to the first decoding layer is obtained by the following operations, including: Randomly generate bounding boxes of the N reference heart beats; Adding random noise to the two-dimensional true value bounding boxes of the Q heart beats to obtain the bounding boxes of the Q reference heart beats; Using the position encoding function, generating an initial position encoding according to the bounding boxes of the N reference heart beats and the bounding boxes of the Q reference heart beats; The initial position code is input into a multi-layer perceptron, and a second position code corresponding to the first decoding layer is output.

8. The method according to claim 7, wherein: The loss calculation is performed on the category labels and two-dimensional true value bounding box labels of the M heartbeats in the target electrocardiogram segment and the classification prediction results and prediction bounding boxes of the P reference heartbeats to obtain the classification loss value and the bounding box loss value, including: Filling the true value results of NM non-target heart beats into the initial true value arrangement to obtain a target true value arrangement, wherein the initial true value arrangement includes the true value results of each of the M heart beats, the target true value arrangement includes the true value results of each of the N heart beats, the true value results include the category labels and two-dimensional true value bounding box labels corresponding to the heart beats, and the arrangement of the true value results of each of the N heart beats in the target true value arrangement is fixed; sorting the prediction results of each of the N reference heart beats to obtain a plurality of prediction arrangements, wherein the prediction results include classification prediction results and prediction bounding boxes; For each of the predicted arrangements, a classification prediction probability value, an intersection-over-union ratio, and an L1 norm are calculated based on the target true value arrangement and the predicted arrangement, wherein the classification prediction probability value represents the probability that the corresponding category labels in the predicted arrangement and the target true value arrangement are consistent with the classification prediction result; Calculating a matching cost corresponding to the predicted arrangement according to the classification prediction probability value, intersection-over-union ratio and L1 norm corresponding to the predicted arrangement; and The arrangement with the smallest corresponding matching cost among the multiple predicted arrangements is determined as the target predicted 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, the bounding box loss value includes a first bounding box loss value and a second bounding box loss value, and the method further includes: Using a classification loss function, the first classification loss value is calculated according to the prediction probability value corresponding to the target prediction arrangement; Calculating the first bounding box loss value using a bounding box loss function according to an intersection-over-union ratio and an L1 norm corresponding to the target prediction arrangement; Calculate the classification prediction probability values ​​corresponding to the Q reference heart beats according to the classification prediction results of each of the Q reference heart beats and the category labels of each of the Q heart beats corresponding to the Q reference heart beats; Using the classification loss function, according to the classification prediction probability values ​​corresponding to the Q reference heart beats, the second classification loss value is calculated; Calculate the intersection-over-union ratio and L1 norm corresponding to the Q reference heartbeats according to the predicted bounding boxes of the Q reference heartbeats and the two-dimensional true bounding box labels of the Q heartbeats corresponding to the Q reference heartbeats; The second bounding box loss value is calculated by using the bounding box loss function according to the intersection-over-union ratio and the L1 norm corresponding to the Q reference heart beats.

10. A method for detecting atrial fibrillation, comprising: Sampling the electrocardiogram record to be detected to a target sampling frequency, and dividing the electrocardiogram record to be detected at the target sampling frequency into a plurality of electrocardiogram segments to be detected according to a target time period; For each of the electrocardiogram segments to be detected, the electrocardiogram segment to be detected is input into an atrial fibrillation heartbeat detection model, and a classification prediction result and a prediction bounding box corresponding to each heartbeat in the electrocardiogram segment to be detected are output, wherein the atrial fibrillation heartbeat detection model is trained according to the method described in any one of claims 1 to 9, and the classification prediction result is used to determine the atrial fibrillation heartbeat in the electrocardiogram 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

  • Electrocardiogram-based arrhythmia identification and detection method and system

    CN116503673A

  • Transmission exterior line resource identification and detection method, device and equipment and storage medium

    CN117076983A

  • Energy storage apparatus

    KR1020250041504A