Methods, devices, equipment, and media for detecting atrial fibrillation heart sounds in small samples.
By employing a selective state-space model and data augmentation strategies, the problems of scarce annotations and interference resistance in small-sample detection of heart sound signals are solved, enabling efficient and accurate atrial fibrillation detection on portable devices, suitable for screening in homes and primary healthcare settings.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- GUANGDONG UNIV OF TECH
- Filing Date
- 2026-04-09
- Publication Date
- 2026-06-30
AI Technical Summary
Existing atrial fibrillation detection technologies based on heart sound signals suffer from problems such as scarce labeled data, insufficient ability to model long-term time-series dependencies, and poor anti-interference capabilities, making it difficult to achieve efficient and accurate atrial fibrillation detection in small-sample scenarios and portable devices.
A selective state-space model is used to extract heart sound features. Combined with data augmentation, imbalanced learning strategy and pseudo-label iterative training, an atrial fibrillation heart sound recognition model is constructed through source domain pre-training and target domain fine-tuning. The selective state-space model is used for long-range modeling and efficient detection is achieved on low-computing-power devices.
High-precision atrial fibrillation detection was achieved in small sample scenarios, improving the model's noise resistance and generalization ability. It is suitable for long-term feature recognition in portable devices and meets the screening needs of families and primary healthcare institutions.
Smart Images

Figure CN122296908A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of medical signal processing and artificial intelligence-assisted diagnostic technology, specifically to a method, device, equipment, and medium for detecting atrial fibrillation heart sounds in a small sample. Background Technology
[0002] Atrial fibrillation is one of the most common sustained arrhythmias in clinical practice. It has an insidious onset and a long course, and is prone to causing serious complications such as stroke and heart failure, resulting in high rates of disability and mortality. It has become a significant cardiovascular disease threatening public health. Early screening and timely diagnosis are crucial for reducing adverse events associated with atrial fibrillation.
[0003] Currently, the gold standard for the clinical diagnosis of atrial fibrillation is an electrocardiogram (ECG). ECG directly records the heart's electrical activity and confirms the diagnosis by identifying features such as the disappearance of P waves and absolutely irregular RR intervals. However, traditional ECG equipment is bulky and requires professional operation, making it difficult to conduct long-term, continuous, and large-scale population screening in communities and homes. While Holter monitoring can provide long-term monitoring, it is inconvenient to wear, costly, and has limited availability, failing to meet the needs of large-scale early screening.
[0004] Heart sounds are generated by mechanical activities such as valvular closure and blood flow vibration, and are highly correlated with cardiac electrical activity. During atrial fibrillation, the ventricular rhythm becomes absolutely irregular, which is directly reflected in the irregular intervals and uneven intensities of heart sounds. Therefore, detecting atrial fibrillation based on heart sounds is feasible. Furthermore, heart sounds can be collected using lightweight devices such as smartphones and portable stethoscopes, offering advantages such as being non-invasive, low-cost, easily accessible, and suitable for long-term home monitoring. This makes it a promising candidate to become an important screening method for atrial fibrillation besides electrocardiograms.
[0005] However, existing intelligent atrial fibrillation detection technologies based on heart sound signals still have significant limitations in practical applications, mainly in the following aspects:
[0006] Firstly, labeled data is scarce, resulting in weak model generalization ability. Obtaining high-quality labeled heart sound data in clinical settings is difficult, especially for atrial fibrillation heart sound datasets diagnosed via electrocardiogram, which are typically small-sample and imbalanced. Traditional deep learning models rely on large amounts of data for training, and are prone to overfitting when data is insufficient, leading to low detection accuracy and poor stability in real-world scenarios, making it difficult to meet clinical screening requirements.
[0007] Secondly, the modeling ability for long-term temporal dependencies is insufficient: The core pathological feature of atrial fibrillation is the absolute irregularity of the heart rhythm. This feature can only be stably manifested within a certain length of time segment, which places high demands on the model's long-range receptive field and temporal modeling ability. Traditional convolutional neural networks have limited receptive fields, making it difficult to capture the rhythm dependencies across time segments in heart sound signals; although recurrent neural networks (RNN, LSTM, GRU) have some temporal modeling capabilities, they suffer from low parallel computing efficiency and vanishing gradients in long sequences, making it impossible to efficiently and accurately model the long-term temporal features of heart sounds.
[0008] Third, it has poor anti-interference ability and insufficient robustness in real-world scenarios: Heart sound signals collected in non-laboratory environments such as homes and communities are easily interfered with by environmental noise, breathing sounds, body movements, and sensor contact noise, resulting in a low signal-to-noise ratio. Most existing algorithms are trained on clean data and are sensitive to noise. Under low signal-to-noise ratio conditions, their detection performance drops sharply, making them prone to false positives and false negatives, and difficult to apply stably on portable and mobile devices.
[0009] Therefore, developing a method for detecting atrial fibrillation heart sounds that has low data dependence, strong long-term modeling capability, good noise resistance, and is suitable for small sample scenarios and portable devices has become a key technical problem that urgently needs to be solved in this field. Summary of the Invention
[0010] In order to overcome the shortcomings of the prior art, the present invention provides a method for detecting atrial fibrillation heart sounds in a small sample, a corresponding device, an electronic device, and a computer-readable storage medium.
[0011] The technical solution of the present invention to solve the above-mentioned technical problems is:
[0012] A method for detecting atrial fibrillation heart sounds in a small sample, comprising the following steps:
[0013] S1: Preprocess and augment the heart sound signals to construct a source domain dataset containing labeled data, unlabeled data, and weakly labeled data;
[0014] S2: Construct a heart sound feature extraction network based on a selective state-space model. The heart sound feature extraction network includes an input layer, a feature embedding layer, a state-space encoding layer, and a classification output layer. Supervised or self-supervised training of the heart sound feature extraction network is performed using labeled data from the source domain dataset to obtain pre-trained weights.
[0015] S3: Load the pre-trained weights, use the heart sound data of confirmed atrial fibrillation as small sample data of the target domain, freeze the shallow parameters corresponding to the input layer and feature embedding layer in the heart sound feature extraction network, fine-tune the parameters of the state space encoding layer and classification output layer of the heart sound feature extraction network only, and introduce an imbalanced learning strategy during the fine-tuning process to obtain a fine-tuned model that fits the target domain.
[0016] S4: Use the fine-tuned model to predict unlabeled or weakly labeled heart sound data in the source domain dataset; set a confidence threshold, calculate the confidence level based on the atrial fibrillation prediction probability output by the fine-tuned model, filter out heart sound data with a confidence level higher than the confidence threshold and generate pseudo-labels; combine the labeled data in the source domain dataset, the small sample data in the target domain, and the heart sound data with pseudo-labels to form a mixed training set, and iteratively retrain the heart sound feature extraction network accordingly until the preset training termination condition is met, to obtain the final atrial fibrillation heart sound recognition model;
[0017] S5: Input the heart sound signal to be detected into the atrial fibrillation heart sound recognition model, output the atrial fibrillation prediction probability, and output the atrial fibrillation prediction result based on the atrial fibrillation prediction probability.
[0018] Preferably, in step S1, the preprocessing includes: uniformly resampling the acquired heart sound signals to a preset sampling rate and normalizing them; comparing the normalized heart sound signals with a preset fixed duration based on their duration; and performing cropping or padding based on the comparison results so that the heart sound signals finally reach the preset fixed duration; the data enhancement includes random noise injection, pitch shifting, and time stretching.
[0019] Preferably, in step S1, during the process of trimming or filling the normalized heart sound signal to a preset fixed duration, when the duration of the original heart sound signal is less than the preset fixed duration, a rhythm-preserving cyclic mirror filling method is used to extend the signal. Specifically, the starting and ending points of the heart sound signal are detected, and the phase of the heart sound cycle at the starting and ending points is determined; the heart sound signal is extended by mirror flip splicing or full-cycle cyclic copy splicing to avoid phase truncation at the splicing position; within a preset millisecond range of the splicing boundary, a Hanning window is used to perform cross-fade-in and fade-out smoothing processing on the splicing area to make the first derivative of the signal at the splicing point continuous and eliminate high-frequency artifacts.
[0020] Preferably, in step S2, the preprocessed one-dimensional heart sound signal is passed to the feature embedding layer through the input layer; the feature embedding layer uses one-dimensional convolution to map the time-domain heart sound signal into high-dimensional features and inputs them to the state space coding layer; the state space coding layer contains multiple state space coding modules, each of which uses a selective mechanism to dynamically adjust the state transition parameters, performs global context modeling of the high-dimensional features with linear time complexity, and outputs the modeling features to the classification output layer; the classification output layer processes the modeling features through a fully connected layer and outputs the atrial fibrillation prediction probability.
[0021] Preferably, in step S2, the step of training the heart sound feature extraction network based on the source domain dataset is as follows:
[0022] The mixed labels in the source domain dataset are converted into a classification task of normal heart sounds and other abnormal heart sounds that are not atrial fibrillation.
[0023] The preprocessed one-dimensional heart sound signal is input into the heart sound feature extraction network. The signal is mapped to a high-dimensional feature space through the feature embedding layer. Multiple state space coding modules are used to perform global context modeling on the high-dimensional features to obtain the global feature vector of the heart sound. The global feature vector is then input into the classification output layer to obtain the corresponding classification prediction probability.
[0024] The error between the classification prediction probability and the true label in the source domain is calculated based on the classification loss function. Based on the error, the parameters of the heart sound feature extraction network are iteratively updated using an adaptive optimizer. During the parameter update process, the learning rate is first linearly warmed up and increased, and then dynamically decayed and adjusted according to the cosine annealing method.
[0025] When the validation set loss remains unchanged or no longer decreases after multiple iterations, training is stopped, the classification output layer of the heart sound feature extraction network is removed, and only the parameters of the feature embedding layer and the state space coding layer are retained, and these parameters are used as pre-training weights.
[0026] Preferably, in step S3, during the process of fine-tuning the parameters of the heart sound feature extraction network, a weighted loss function is simultaneously used to dynamically allocate training weights according to the difficulty of sample classification, increase the training weights of difficult-to-classify samples, and strengthen the model's learning of difficult-to-classify samples; at the same time, oversampling technology is combined to oversample the atrial fibrillation positive samples in the small sample data of the target domain to balance the ratio of atrial fibrillation positive samples to normal heart sound negative samples in the target domain dataset.
[0027] Preferably, in step S4, the calculation steps and filtering logic of the confidence level are as follows: obtain the atrial fibrillation prediction probability corresponding to each set of heart sound data output by the fine-tuning model, and determine the non-atrial fibrillation probability of the corresponding heart sound data based on the atrial fibrillation prediction probability; compare the atrial fibrillation prediction probability with the non-atrial fibrillation probability, and select the probability with the larger value as the confidence level of the current heart sound data; compare the calculated confidence level with the preset confidence level threshold, filter out heart sound data with a confidence level higher than the confidence level threshold, and generate corresponding pseudo-labels for the filtered heart sound data for subsequent construction of the mixed training set.
[0028] A small-sample atrial fibrillation heart sound detection device includes:
[0029] The dataset construction module is used to preprocess and augment the collected heart sound signals, and to build a source domain dataset containing labeled data, unlabeled data and weakly labeled data.
[0030] The network construction and pre-training module is used to construct a heart sound feature extraction network based on a selective state space model, and to perform supervised or self-supervised training on the constructed heart sound feature extraction network using labeled data in the source domain dataset to obtain pre-trained weights.
[0031] The transfer fine-tuning module is used to load the pre-trained weights and use the heart sound data of confirmed atrial fibrillation as small sample data of the target domain. By freezing the shallow parameters corresponding to the input layer and feature embedding layer in the heart sound feature extraction network, the parameters of the state space encoding module and the classification output layer of the heart sound feature extraction network are fine-tuned only. An imbalanced learning strategy is introduced during the fine-tuning process to obtain a fine-tuned model that fits the target domain.
[0032] The iterative retraining module uses the fine-tuned model to predict unlabeled or weakly labeled heart sound data in the source domain dataset. Based on the atrial fibrillation prediction probability output by the fine-tuned model, it calculates the confidence level, filters out heart sound data with a confidence level higher than a preset confidence threshold, and generates pseudo-labels. The labeled data in the source domain dataset, the small sample data in the target domain, and the heart sound data with pseudo-labels are combined to form a mixed training set. The heart sound feature extraction network is iteratively retrained until the preset training termination condition is met, and the final atrial fibrillation heart sound recognition model is obtained.
[0033] The detection output module is used to receive the heart sound signal to be detected, input the heart sound signal to be detected into the atrial fibrillation heart sound recognition model, output the atrial fibrillation prediction probability, and output the atrial fibrillation prediction result based on the atrial fibrillation prediction probability.
[0034] An electronic device includes a central processing unit and a memory, the central processing unit being configured to invoke and run a computer program stored in the memory to perform the steps of the small sample atrial fibrillation heart sound detection method.
[0035] A computer-readable storage medium stores, in the form of computer-readable instructions, a computer program implemented according to the small-sample atrial fibrillation heart sound detection method, which, when called by a computer, executes the steps included in the corresponding method.
[0036] Compared with the prior art, the present invention has the following advantages and beneficial effects:
[0037] 1. This invention relies on the efficient long-range modeling capability of the selective state-space model to fully explore the rhythmic variation patterns of heart sound signals in the long-term time dimension, accurately identify the unique irregular rhythmic features of atrial fibrillation heart sounds, and effectively distinguish atrial fibrillation from normal heart sounds and other abnormal heart sounds, thereby improving the accuracy and specificity of atrial fibrillation detection.
[0038] 2. This invention adopts a multi-stage progressive learning strategy, which accumulates general heart sound features through pre-training on the source domain dataset, fine-tunes and adapts the target domain dataset to atrial fibrillation small samples, and semi-supervised iterative mining of weakly labeled data value. This progressive approach achieves efficient model training and overcomes the technical bottleneck of deep learning models having difficulty converging and low recognition accuracy in extremely small sample scenarios. Therefore, this invention can achieve stable detection without large-scale labeling of atrial fibrillation samples.
[0039] 3. This invention combines the advantages of linear time complexity of selective state-space models, which can significantly reduce the computational power consumption of model inference and is compatible with low-computation portable devices such as smartphones and portable heart sound acquisition devices; at the same time, it takes into account both detection accuracy and deployment convenience, and can quickly complete atrial fibrillation screening, meeting the needs of scenarios such as home self-testing and primary healthcare screening, and helping to detect and intervene in atrial fibrillation early. Attached Figure Description
[0040] Figure 1 This is a schematic flowchart of the small-sample atrial fibrillation heart sound detection method of the present invention.
[0041] Figure 2 This is a structural diagram of a heart sound feature extraction network based on a selective state-space model.
[0042] Figure 3 This is a schematic diagram of a three-stage transfer learning strategy.
[0043] Figure 4 This is a schematic diagram of the internal structure of a selective state-space model. Detailed Implementation
[0044] The present invention will be further described in detail below with reference to the embodiments and accompanying drawings, but the embodiments of the present invention are not limited thereto.
[0045] Example 1
[0046] See Figures 1-4 The small-sample atrial fibrillation heart sound detection method of the present invention includes the following steps:
[0047] S1: Preprocess and augment the heart sound signals to construct a source domain dataset containing labeled data, unlabeled data, and weakly labeled data;
[0048] In this embodiment, large-scale, easily accessible heart sound data is selected to construct the source domain dataset. The preprocessing includes: uniformly resampling the acquired heart sound signals to a preset sampling rate (preferably 1000Hz-4000Hz) and normalizing them to eliminate amplitude differences; comparing the normalized heart sound signals with a preset fixed duration based on their duration; and cropping or padding based on the comparison results to ensure the heart sound signals ultimately reach the preset fixed duration (preferably 5 seconds-30 seconds). Specifically, during the cropping or padding of the normalized heart sound signals to the preset fixed duration, if the duration of the original heart sound signal is less than the preset fixed duration... For extended duration, a rhythm-preserving cyclic mirror fill method is used to prolong the signal. Specifically, the start and end points of the heart sound signal are detected, and the phase of the heart sound cycle at the start and end points is determined. The heart sound signal is prolonged by mirror flip splicing (i.e., the original heart sound signal is reversed and appended to the end) or by full-cycle cyclic copy splicing to avoid "clicking" caused by phase truncation at the splicing point. At the splicing boundary (within a preset millisecond range before and after, such as 50ms), a Hanning window is used to perform cross-fade-in and fade-out smoothing on the splicing area to ensure the continuity of the first derivative at the splicing point, thereby eliminating high-frequency artifacts that may be misjudged as noise by the model.
[0049] In addition, to address the scarcity of atrial fibrillation samples in the target domain, a specialized acoustic enhancement strategy was designed, including but not limited to random noise injection, pitch shifting, and time stretching. Random noise injection simulates the real acquisition environment, pitch shifting simulates individual differences, and time stretching simulates heart rate changes, thereby expanding the limited atrial fibrillation samples by several to tens of times. This can then be used to expand the scarce atrial fibrillation samples in the subsequent model training phase.
[0050] S2: Construct a heart sound feature extraction network based on a selective state-space model (SSM). The heart sound feature extraction network includes an input layer, a feature embedding layer, a state-space encoding layer, and a classification output layer. By using labeled data from the source domain dataset to supervise or self-supervisedly train the heart sound feature extraction network, the network can learn the basic acoustic structural features of the heart sound signal (such as S1 / S2 heart sound localization and noise recognition) and obtain pre-trained weights.
[0051] In this embodiment, the preprocessed one-dimensional heart sound signal is fed into the feature embedding layer through the input layer; the feature embedding layer uses one-dimensional convolution to map the time-domain heart sound signal into high-dimensional features and inputs them into the state space coding layer; the state space coding layer contains multiple (preferably 3-6) state space coding modules, each of which uses a selective mechanism to dynamically adjust the state transition parameters (i.e., the parameters of the state transition matrix) according to the input content, thereby achieving selective memorization of the input sequence, performing global context modeling of the high-dimensional features with linear time complexity, and outputting the modeling features to the classification output layer; the classification output layer processes the modeling features through a fully connected layer and outputs the atrial fibrillation prediction probability.
[0052] Furthermore, the steps for training the heart sound feature extraction network based on the source domain dataset are as follows:
[0053] The mixed heterogeneous label mapping of the source domain dataset is used as a binary or multi-class classification proxy task of "normal" and "non-critical abnormality". The aim is to allow the model to learn the basic acoustic features and quasi-periodic patterns of heart sound signals, rather than focusing on the diagnosis of atrial fibrillation itself. The preprocessed one-dimensional heart sound signal is input into the heart sound feature extraction network. The signal is mapped to a high-dimensional feature space through a feature embedding layer. Multiple state-space encoding modules are used to perform global context modeling of the high-dimensional features to obtain a global feature vector of the heart sound. This global feature vector is then input into the classification output layer to obtain the corresponding classification prediction probability. The error between the classification prediction probability and the true label of the source domain is calculated based on the standard cross-entropy loss function. The error is addressed by iteratively updating the parameters of the heart sound feature extraction network using the AdamW optimizer to reduce the risk of model overfitting. During the parameter update process, the learning rate is first linearly increased and then dynamically adjusted using cosine annealing. For example, the learning rate is linearly increased from a minimum to a peak value (e.g., 1e-3) in the first 10 epochs, and then smoothly decayed according to a cosine curve. When the validation set loss remains unchanged or no longer decreases after multiple iterations, training is stopped, the classification output layer of the heart sound feature extraction network is removed, and only the parameters of the feature embedding layer and the state space coding layer are retained. These parameters are then used as the pre-training weights of the "general heart sound feature extractor".
[0054] S3: Load the pre-trained weights, use the heart sound data of confirmed atrial fibrillation as small sample data of the target domain, freeze the shallow parameters corresponding to the input layer and feature embedding layer in the heart sound feature extraction network, fine-tune the parameters of the state space encoding layer and classification output layer of the heart sound feature extraction network only, and introduce an imbalanced learning strategy during the fine-tuning process to obtain a fine-tuned model that fits the target domain.
[0055] In the process of fine-tuning the parameters of the heart sound feature extraction network, considering that the target domain is atrial fibrillation data with a small sample size, in practical applications, the number of positive atrial fibrillation samples is far less than the number of negative normal heart sound samples. This can easily lead to the model training being biased towards normal heart sound samples, resulting in problems such as low accuracy in identifying atrial fibrillation samples and missed classification of difficult-to-classify samples. Therefore, this invention adopts an imbalanced learning strategy that combines a weighted loss function (such as Focal Loss) with oversampling techniques (such as SMOTE) to balance the learning of difficult-to-classify samples with the balance between positive and negative samples. The specific implementation process is as follows:
[0056] To address the issue of insufficient accuracy in identifying difficult-to-classify samples, this invention simultaneously employs a weighted loss function, abandoning the traditional fixed-weight loss calculation method and dynamically allocating training weights based on the classification difficulty of the samples. For example, during the parameter fine-tuning of the heart sound feature extraction network, a closed-loop dynamic weighted loss function strategy based on validation set feedback is adopted: in the early training phase (Epoch 0), static weights are initialized according to the physical ratio of positive to negative atrial fibrillation samples in the target domain dataset. (e.g., assigning high weights to a very small number of atrial fibrillation samples) and standard At the end of each epoch, the recall (reflecting the missed diagnosis rate) and precision (reflecting the false diagnosis rate) of the atrial fibrillation category are calculated in real time on the validation set. If the recall of the atrial fibrillation category in the current epoch is found to be lower than a preset safety threshold (i.e., severe missed diagnoses), the model will automatically increase the recall of the atrial fibrillation category in the next epoch. Value, using an exponential reward formula The forced model focuses on missed atrial fibrillation samples and simultaneously up-regulates... If the recall rate meets the target but the accuracy rate is extremely low (i.e., the model degenerates with rampant false positives), a smoothing callback mechanism is triggered to appropriately reduce the accuracy. The value allows the model's attention to return to negative samples of normal heart sounds to reduce false alarms. Through this closed-loop feedback dynamic weight adjustment mechanism, the model can effectively avoid falling into the local optimum trap of "fitting the majority class" or "blindly guessing the minority class" in extreme few-sample scenarios, and significantly improve the detection sensitivity and specificity of the model in real clinical scenarios.
[0057] Furthermore, during parameter fine-tuning, the model continuously assesses the classification difficulty of each sample. For samples with large classification errors and difficult to identify correctly (such as samples with high similarity between atrial fibrillation signals and other abnormal heart sounds, or samples with a lot of signal noise), its training weight is automatically increased. For samples with small classification errors and easy identification, their training weight is appropriately reduced. This dynamic weighting method guides the model to focus more on difficult-to-classify samples, strengthening the model's feature learning ability for difficult-to-classify samples and reducing the probability of misclassification and missed classification of difficult-to-classify samples. Simultaneously, addressing the imbalance between the number of positive atrial fibrillation samples and negative normal heart sound samples in the small sample data of the target domain, oversampling technology is used to oversample the positive atrial fibrillation samples in the small sample data of the target domain. Specifically, by reasonably replicating and slightly perturbing the positive samples of atrial fibrillation, the number of positive samples of atrial fibrillation is increased, so that the ratio of positive samples of atrial fibrillation to negative samples of normal heart sounds in the target domain dataset tends to be balanced. This can effectively avoid the model from becoming biased due to sample imbalance, and ensure that the model can learn fully from both positive samples of atrial fibrillation and negative samples of normal heart sounds during the training process. This improves the model's sensitivity and generalization ability to identify atrial fibrillation samples, and avoids the model being unable to effectively capture the core features of atrial fibrillation heart sounds due to too few positive samples.
[0058] This invention applies weighted loss function and oversampling technique simultaneously to the parameter fine-tuning process. The two work synergistically: oversampling technique solves the problem of sample imbalance and provides a balanced training data foundation for the model; weighted loss function solves the problem of insufficient learning of difficult-to-classify samples, guides the model to focus on key samples, and ultimately enables the fine-tuned model to accurately identify atrial fibrillation samples in the target domain, adapting to the atrial fibrillation heart sound detection needs in scenarios with small samples and imbalance.
[0059] S4: Use the fine-tuned model to predict unlabeled or weakly labeled heart sound data in the source domain dataset; set a confidence threshold (e.g., 0.8-0.95), calculate the confidence level based on the atrial fibrillation prediction probability output by the fine-tuned model, filter out heart sound data with a confidence level higher than the confidence threshold and generate pseudo-labels; combine the labeled data in the source domain dataset, the small sample data in the target domain, and the heart sound data with pseudo-labels to form a mixed training set, and iteratively retrain the heart sound feature extraction network accordingly to further improve the model's generalization ability; until the preset training termination condition is met, the final atrial fibrillation heart sound recognition model is obtained;
[0060] In this embodiment, the calculation steps and filtering logic of the confidence level are as follows: obtain the atrial fibrillation prediction probability corresponding to each set of heart sound data output by the fine-tuning model, and determine the non-atrial fibrillation probability of the corresponding heart sound data based on the atrial fibrillation prediction probability; compare the atrial fibrillation prediction probability with the non-atrial fibrillation probability, and select the probability with the larger value as the confidence level of the current heart sound data; compare the calculated confidence level with a preset confidence level threshold, filter out heart sound data with a confidence level higher than the confidence level threshold, and generate corresponding pseudo-labels for the filtered heart sound data for subsequent construction of the mixed training set.
[0061] S5: Input the heart sound signal to be detected into the atrial fibrillation heart sound recognition model, output the atrial fibrillation prediction probability, and output the atrial fibrillation prediction result based on the atrial fibrillation prediction probability;
[0062] In this embodiment, the small-sample atrial fibrillation heart sound detection method of the present invention is adaptable to portable application scenarios. The specific implementation process is as follows: The user's raw heart sound data can be collected through a portable acquisition device (such as a smartphone microphone, a portable heart sound acquisition device, etc.). After the acquisition is completed, the preprocessing operations described in step S1 (including resampling, normalization, pruning, or rhythm-preserving cyclic mirror filling, etc.) are sequentially performed on the raw heart sound data to ensure the standardization and integrity of the heart sound signal. After the preprocessing is completed, the standardized heart sound signal is input into a pre-trained atrial fibrillation heart sound recognition model. The atrial fibrillation heart sound recognition model performs feature extraction, classification and recognition on the input heart sound signal, and outputs the corresponding atrial fibrillation prediction probability. The system automatically classifies the user's heart sound state according to the value of the atrial fibrillation prediction probability and a preset judgment threshold, and intuitively displays the classification results to the user. The classification results specifically include three categories: "normal heart sound", "atrial fibrillation heart sound", and "other abnormal heart sound", realizing convenient and rapid detection of atrial fibrillation and meeting the needs of home self-testing, primary medical screening and other scenarios.
[0063] Finally, the small-sample atrial fibrillation heart sound detection method of the present invention has the following advantages:
[0064] Firstly, it effectively solves the problem of small sample detection of atrial fibrillation heart sounds. This invention adopts a combination strategy of source domain pre-training, target domain fine-tuning and data augmentation, which can achieve high-precision atrial fibrillation identification in extremely small sample scenarios with only a few dozen confirmed atrial fibrillation samples. This can significantly reduce the dependence of deep learning models on large-scale labeled data and solve the technical bottleneck of scarce labeled data for atrial fibrillation and difficulty in training models in clinical practice.
[0065] Secondly, it boasts stronger and more efficient long-term temporal feature modeling capabilities: This invention is the first to apply a selective state-space model to atrial fibrillation detection, which can fully capture the long-term, global rhythmic variation features in the heart sound signal. Compared with traditional convolutional neural networks, this invention has a global receptive field, which can completely model the dependencies between cardiac cycles; compared with Transformer-type models, this invention reduces the sequence inference complexity from O(L²) to linear complexity O(L), significantly improving computational efficiency while ensuring recognition accuracy, making it more suitable for real-time deployment on low-computing-power devices and mobile terminals.
[0066] Thirdly, the model's generalization and robustness are significantly improved: This invention fully utilizes a large amount of unlabeled and weakly labeled heart sound data in the source domain through a semi-supervised iterative and pseudo-label learning mechanism, expands effective training information, and enhances the model's adaptability to heart sound signals from different acquisition devices, different noise environments, and different populations. This effectively reduces the impact of signal interference, device differences, and changes in data distribution on the detection results, enabling the model to maintain stable and reliable atrial fibrillation detection performance even in complex clinical scenarios.
[0067] Fourth, it has a stronger learning ability for imbalanced data: By combining the weighted loss function and the oversampling strategy, this invention can effectively alleviate the model bias problem caused by the scarcity of positive samples and the imbalance of positive and negative sample distribution in atrial fibrillation, and strengthen the learning ability for atrial fibrillation samples that are difficult to classify and easy to miss, thereby further improving the sensitivity and specificity of atrial fibrillation identification.
[0068] Example 2
[0069] The small-sample atrial fibrillation heart sound detection device of the present invention includes:
[0070] The dataset construction module is used to preprocess and augment the collected heart sound signals, and to build a source domain dataset containing labeled data, unlabeled data and weakly labeled data.
[0071] The network construction and pre-training module is used to construct a heart sound feature extraction network based on a selective state space model. The heart sound feature extraction network includes an input layer, a feature embedding layer, a state space encoding layer, and a classification output layer. It is also used to perform supervised or self-supervised training on the heart sound feature extraction network using labeled data in the source domain dataset to obtain pre-trained weights.
[0072] The transfer fine-tuning module is used to load the pre-trained weights and use the heart sound data of confirmed atrial fibrillation as the target domain small sample data; it is also used to freeze the shallow parameters corresponding to the input layer and feature embedding layer in the heart sound feature extraction network, and only fine-tune the parameters of the deep encoding module and classification output layer of the heart sound feature extraction network. During the fine-tuning process, an imbalanced learning strategy is adopted to obtain a fine-tuned model that fits the target domain.
[0073] The iterative retraining module is used to predict unlabeled or weakly labeled heart sound data in the source domain dataset using the fine-tuned model; it is also used to set a confidence threshold, calculate the confidence level based on the atrial fibrillation prediction probability output by the fine-tuned model, filter out heart sound data with a confidence level higher than the confidence threshold and generate pseudo-labels; it is also used to construct a mixed training set by combining labeled data in the source domain dataset, small sample data in the target domain dataset and heart sound data with pseudo-labels, and iteratively retrain the heart sound feature extraction network until the preset training termination condition is met, to obtain the final atrial fibrillation heart sound recognition model;
[0074] The detection output module is used to receive the heart sound signal to be detected, input the heart sound signal to be detected into the atrial fibrillation heart sound recognition model, and output the atrial fibrillation prediction probability.
[0075] Example 3
[0076] The electronic device of the present invention includes a central processing unit and a memory, wherein the central processing unit is used to call and run a computer program stored in the memory to perform the steps of the small sample atrial fibrillation heart sound detection method described in Embodiment 1.
[0077] Example 4
[0078] The computer-readable storage medium of the present invention stores, in the form of computer-readable instructions, a computer program implemented according to the small sample atrial fibrillation heart sound detection method described in Embodiment 1. When the computer program is called and executed by a computer, it performs the steps included in the corresponding method.
[0079] The above are preferred embodiments of the present invention, but the embodiments of the present invention are not limited to the above content. Any changes, modifications, substitutions, combinations, or simplifications made without departing from the spirit and principle of the present invention shall be considered equivalent substitutions and shall be included within the protection scope of the present invention.
Claims
1. A method for detecting atrial fibrillation heart sounds in a small sample, characterized in that, Includes the following steps: S1: Preprocess and augment the heart sound signals to construct a source domain dataset containing labeled data, unlabeled data, and weakly labeled data; S2: Construct a heart sound feature extraction network based on a selective state-space model. The heart sound feature extraction network includes an input layer, a feature embedding layer, a state-space encoding layer, and a classification output layer. Supervised or self-supervised training of the heart sound feature extraction network is performed using labeled data from the source domain dataset to obtain pre-trained weights. S3: Load the pre-trained weights, use the heart sound data of confirmed atrial fibrillation as small sample data of the target domain, freeze the shallow parameters corresponding to the input layer and feature embedding layer in the heart sound feature extraction network, fine-tune the parameters of the state space encoding layer and classification output layer of the heart sound feature extraction network only, and introduce an imbalanced learning strategy during the fine-tuning process to obtain a fine-tuned model that fits the target domain. S4: Use the fine-tuned model to predict unlabeled or weakly labeled heart sound data in the source domain dataset; A confidence threshold is set, and the confidence level is calculated based on the atrial fibrillation prediction probability output by the fine-tuned model. Heart sound data with a confidence level higher than the confidence threshold are selected and pseudo-labels are generated. The labeled data in the source domain dataset, the small sample data in the target domain, and the heart sound data with pseudo-labels are combined to form a mixed training set. The heart sound feature extraction network is iteratively retrained according to this set until the preset training termination condition is met, and the final atrial fibrillation heart sound recognition model is obtained. S5: Input the heart sound signal to be detected into the atrial fibrillation heart sound recognition model, output the atrial fibrillation prediction probability, and output the atrial fibrillation prediction result based on the atrial fibrillation prediction probability.
2. The method for detecting atrial fibrillation heart sounds in a small sample size according to claim 1, characterized in that, In step S1, the preprocessing includes: resampling the collected heart sound signals to a preset sampling rate and normalizing them; comparing the normalized heart sound signals with a preset fixed duration based on their duration; and performing cropping or padding based on the comparison results so that the heart sound signals finally reach the preset fixed duration; the data enhancement includes random noise injection, pitch shifting, and time stretching.
3. The method for detecting atrial fibrillation heart sounds in a small sample according to claim 2, characterized in that, In step S1, during the process of trimming or padding the normalized heart sound signal to a preset fixed duration, when the duration of the original heart sound signal is less than the preset fixed duration, a rhythm-preserving cyclic mirror padding method is used to extend the signal. Specifically, the starting and ending points of the heart sound signal are detected, and the phase of the heart sound cycle at the starting and ending points is determined. The heart sound signal is extended by mirror flipping splicing or full-cycle cyclic copying splicing to avoid phase truncation at the splicing position. Within a preset millisecond range of the splicing boundary, a Hanning window is used to perform cross-fade-in and fade-out smoothing on the splicing area to make the first derivative of the signal at the splicing point continuous and eliminate high-frequency artifacts.
4. The method for detecting atrial fibrillation heart sounds in a small sample according to claim 1, characterized in that, In step S2, the preprocessed one-dimensional heart sound signal is transmitted to the feature embedding layer through the input layer; The feature embedding layer uses one-dimensional convolution to map the time-domain heart sound signal into high-dimensional features and inputs them into the state space coding layer. The state space coding layer contains multiple state space coding modules. Each state space coding module uses a selective mechanism to dynamically adjust the state transition parameters, perform global context modeling of the high-dimensional features with linear time complexity, and output the modeling features to the classification output layer. The classification output layer processes the modeling features through a fully connected layer and outputs the atrial fibrillation prediction probability.
5. The method for detecting atrial fibrillation heart sounds in a small sample according to claim 4, characterized in that, In step S2, the steps for training the heart sound feature extraction network based on the source domain dataset are as follows: The mixed labels in the source domain dataset are converted into a classification task of normal heart sounds and other abnormal heart sounds that are not atrial fibrillation. The preprocessed one-dimensional heart sound signal is input into the heart sound feature extraction network. The signal is mapped to a high-dimensional feature space through the feature embedding layer. Multiple state space coding modules are used to perform global context modeling on the high-dimensional features to obtain the global feature vector of the heart sound. The global feature vector is then input into the classification output layer to obtain the corresponding classification prediction probability. The error between the classification prediction probability and the true label in the source domain is calculated based on the classification loss function. Based on the error, the parameters of the heart sound feature extraction network are iteratively updated using an adaptive optimizer. During the parameter update process, the learning rate is first linearly warmed up and increased, and then dynamically decayed and adjusted according to the cosine annealing method. When the validation set loss remains unchanged or no longer decreases after multiple iterations, training is stopped, the classification output layer of the heart sound feature extraction network is removed, and only the parameters of the feature embedding layer and the state space coding layer are retained, and these parameters are used as pre-training weights.
6. The method for detecting atrial fibrillation heart sounds in a small sample according to claim 1, characterized in that, In step S3, during the fine-tuning of the parameters of the heart sound feature extraction network, a weighted loss function is simultaneously used to dynamically allocate training weights according to the difficulty of sample classification, increase the training weights of difficult-to-classify samples, and strengthen the model's learning of difficult-to-classify samples; at the same time, oversampling technology is combined to oversample the atrial fibrillation positive samples in the small sample data of the target domain to balance the ratio of atrial fibrillation positive samples to normal heart sound negative samples in the target domain dataset.
7. The method for detecting atrial fibrillation heart sounds in a small sample according to claim 1, characterized in that, In step S4, the calculation steps and filtering logic of the confidence level are as follows: obtain the atrial fibrillation prediction probability corresponding to each set of heart sound data output by the fine-tuning model, and determine the non-atrial fibrillation probability of the corresponding heart sound data based on the atrial fibrillation prediction probability; compare the atrial fibrillation prediction probability with the non-atrial fibrillation probability, and select the probability with the larger value as the confidence level of the current heart sound data; compare the calculated confidence level with a preset confidence level threshold, filter out heart sound data with a confidence level higher than the confidence level threshold, and generate corresponding pseudo-labels for the filtered heart sound data for subsequent construction of the mixed training set.
8. A small-sample atrial fibrillation heart sound detection device, characterized in that, include: The dataset construction module is used to preprocess and augment the collected heart sound signals, and to build a source domain dataset containing labeled data, unlabeled data and weakly labeled data. The network construction and pre-training module is used to construct a heart sound feature extraction network based on a selective state space model, and to perform supervised or self-supervised training on the constructed heart sound feature extraction network using labeled data in the source domain dataset to obtain pre-trained weights. The transfer fine-tuning module is used to load the pre-trained weights and use the heart sound data of confirmed atrial fibrillation as small sample data of the target domain. By freezing the shallow parameters corresponding to the input layer and feature embedding layer in the heart sound feature extraction network, the parameters of the state space encoding module and the classification output layer of the heart sound feature extraction network are fine-tuned only. An imbalanced learning strategy is introduced during the fine-tuning process to obtain a fine-tuned model that fits the target domain. The iterative retraining module uses the fine-tuned model to predict unlabeled or weakly labeled heart sound data in the source domain dataset. Based on the atrial fibrillation prediction probability output by the fine-tuned model, it calculates the confidence level, filters out heart sound data with a confidence level higher than a preset confidence threshold, and generates pseudo-labels. The labeled data in the source domain dataset, the small sample data in the target domain, and the heart sound data with pseudo-labels are combined to form a mixed training set. The heart sound feature extraction network is iteratively retrained until the preset training termination condition is met, and the final atrial fibrillation heart sound recognition model is obtained. The detection output module is used to receive the heart sound signal to be detected, input the heart sound signal to be detected into the atrial fibrillation heart sound recognition model, output the atrial fibrillation prediction probability, and output the atrial fibrillation prediction result based on the atrial fibrillation prediction probability.
9. An electronic device comprising a central processing unit and a memory, characterized in that, The central processing unit is used to invoke and run a computer program stored in the memory to perform the steps of the small sample atrial fibrillation heart sound detection method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, It stores, in the form of computer-readable instructions, a computer program implementing the small sample atrial fibrillation heart sound detection method according to any one of claims 1 to 7, which, when called by a computer, executes the steps included in the corresponding method.