Automated Lung Sound Classification Using a Hybrid CNN-LSTM Network and Focal Loss Function

Georgios Petmezas, Grigorios-Aris Cheimariotis, Leandros Stefanopoulos, Bruno Miguel Machado Rocha, Rui Pedro Paiva, Aggelos K. Katsaggelos, Nicos Maglaveras2022 · DOI

TL;DR

This paper introduces a novel hybrid deep learning model combining Convolutional Neural Networks (CNNs) and Long Short-Term Memory (LSTM) networks, enhanced with a Focal Loss function, to automatically classify four types of lung sounds. This approach significantly improves the accuracy of detecting respiratory conditions like crackles and wheezes, addressing the critical need for reliable and efficient diagnostic tools.

What Problem Does This Paper Address?

Respiratory diseases are a major global health concern, contributing significantly to mortality. Early diagnosis and continuous monitoring are crucial for effective management, and lung auscultation (listening to lung sounds with a stethoscope) is a cornerstone of this process. However, manual interpretation of lung sounds is inherently subjective, time-consuming, and requires extensive medical expertise. This subjectivity and the sheer volume of data generated by modern monitoring devices create a bottleneck in diagnosis and patient care. While AI has shown promise in automating this task, challenges remain, particularly in handling imbalanced datasets where some lung sound categories are much rarer than others, leading to biased models. This paper aims to tackle these issues by developing a robust and accurate automated lung sound classification system.

Methods

The core of this research is a hybrid deep learning architecture that leverages the strengths of both CNNs and LSTMs.

  • Feature Extraction (CNN): The process begins by transforming raw audio samples of lung sounds into Short-Time Fourier Transform (STFT) spectrograms. These 2D representations capture the frequency content over time. A Convolutional Neural Network (CNN) is then employed to process these spectrograms. The CNN's convolutional layers act as feature extractors, learning to identify complex patterns and hierarchical features within the spectrograms. This also serves to reduce the dimensionality of the data.
  • Temporal Dependency Modeling (LSTM): The features extracted by the CNN are then fed into a Long Short-Term Memory (LSTM) network. LSTMs are a type of recurrent neural network specifically designed to capture long-term dependencies in sequential data. In this context, the LSTM learns the temporal relationships between different parts of the lung sound signal, which is crucial for accurately classifying sounds that evolve over time.
  • Handling Data Imbalance (Focal Loss): A key innovation in this work is the use of the Focal Loss (FL) function. Standard cross-entropy loss can be overwhelmed by the large number of easily classified examples in imbalanced datasets, leading the model to focus less on the rare but important misclassified examples. Focal Loss addresses this by down-weighting the loss assigned to well-classified examples and up-weighting the loss for misclassified ones, effectively guiding the model to pay more attention to challenging cases.

Datasets

The study utilizes the ICBHI 2017 Respiratory Sound Database. This publicly available dataset contains 5.5 hours of recorded respiratory sounds from 126 subjects, with audio samples manually annotated by medical experts. It includes four categories of lung sounds: normal, crackles, wheezes, and a combination of crackles and wheezes. The database is noted for its class imbalance, with normal sounds being the most frequent.

Key Insights and Ideas

  • Synergy of CNN and LSTM: The hybrid CNN-LSTM architecture proves highly effective. The CNN excels at extracting discriminative spatial features from spectrograms, while the LSTM excels at capturing the temporal dynamics of these features, leading to a more comprehensive understanding of the lung sound.
  • Focal Loss is Crucial for Imbalance: The explicit use of Focal Loss significantly boosts performance, particularly in scenarios with imbalanced data. This highlights the importance of specialized loss functions in real-world medical applications where data distribution is often uneven.
  • Spectrograms as Effective Representations: STFT spectrograms, when processed by a deep learning model, provide a rich and informative representation of lung sounds for classification.
  • Importance of Hyperparameter Tuning: The study demonstrates that optimizing parameters like the number of convolutional layers and dropout rate is critical for achieving peak performance.

Key Results

The proposed hybrid CNN-LSTM model with Focal Loss achieved state-of-the-art results across various evaluation strategies:

  • Official 60/40 split: Sensitivity 47.37%, Specificity 82.46%, Score 64.92%, Accuracy 73.69%.
  • Interpatient 10-fold Cross-Validation: Sensitivity 52.78%, Specificity 84.26%, Score 68.52%, Accuracy 76.39%.
  • Leave-One-Out Cross-Validation: Sensitivity 60.29%, Accuracy 74.57%.

The paper also shows that using Focal Loss outperformed the classic cross-entropy loss, and a hybrid CNN-LSTM architecture performed better than a CNN-only approach.

Limitations and Future Work

The authors acknowledge several limitations:

  • Limited Class Scope: The model was trained to classify only three types of adventitious lung sounds (crackles, wheezes, and both). It cannot detect other important lung sound categories like rhonchi or squawks.
  • Generalizability: While the ICBHI 2017 database is well-established, it has a limited number of respiratory cycles. This might affect the generalizability of the findings to larger, more diverse datasets.

Future work suggested includes:

  • Expanding Classification: Incorporating more lung sound categories into the classification task.
  • Cross-Database Validation: Testing the model's performance on data from other databases to assess its robustness.
  • Exploring Other Features: Investigating alternative or complementary feature extraction methods beyond STFT spectrograms.
  • Real-time Implementation: Further development for real-time lung sound classification, as the prediction phase of the current model is already quite fast.

Summary updated

BibTeX
@misc{petmezas2022automated,
  author = {Georgios Petmezas and Grigorios-Aris Cheimariotis and Leandros Stefanopoulos and Bruno Miguel Machado Rocha and Rui Pedro Paiva and Aggelos K. Katsaggelos and Nicos Maglaveras},
  title = {{Automated Lung Sound Classification Using a Hybrid CNN-LSTM Network and Focal Loss Function}},
  year = {2022},
  doi = {10.3390/s22031232},
}
Figure