Skip to content

Repository files navigation

🫁 Respiratory Disease Diagnosis Using Cough Sound Analysis

A deep learning framework for non-invasive, automated respiratory disease detection through cough audio analysis.

📌 Overview

This project presents an automated two-stage pipeline for diagnosing respiratory diseases from cough sounds — without any invasive procedures or specialized medical equipment.

Stage 1 — Cough Detection: Distinguishes cough sounds from background noise using MFCC features + CNN classifier.
Stage 2 — Disease Classification: Classifies detected coughs into specific respiratory conditions using a multi-class CNN model.
Stage 3 — Wavelet Enhancement: Uses Continuous Wavelet Transform (CWT) scalograms to improve time-frequency representation and disease discrimination.


🎯 Diseases Classified

  • Asthma
  • Bronchitis
  • Chronic Obstructive Pulmonary Disease (COPD)
  • Pneumonia
  • Bronchiolitis
  • Bronchiectasis
  • Upper Respiratory Tract Infection (URTI)
  • Healthy (control)

🏗️ System Architecture

Raw Audio Input
      │
      ▼
┌─────────────────────────────┐
│  Preprocessing              │
│  • Noise reduction          │
│  • Amplitude normalization  │
│  • 6-second segmentation    │
└─────────────┬───────────────┘
              │
     ┌────────┴────────┐
     ▼                 ▼
┌─────────┐     ┌──────────────┐
│  MFCC   │     │  Wavelet CWT │
│ Features│     │  Scalograms  │
└────┬────┘     └──────┬───────┘
     │                 │
     ▼                 ▼
┌─────────┐     ┌──────────────┐
│ CNN     │     │ CNN          │
│ Phase 1 │     │ Phase 2      │
│ (Cough  │     │ (Disease     │
│ Detect) │     │ Classify)    │
└────┬────┘     └──────┬───────┘
     │                 │
     └────────┬────────┘
              ▼
       Disease Prediction
       + Class Probabilities

📊 Results

Phase 1 — Cough Detection (MFCC + CNN)

Metric Value
Detection Accuracy 97.4%
Confidence Score (sample) 0.9931
F1-Score 0.9709
Accuracy Score 0.9815

Phase 2 — Disease Classification (MFCC + CNN)

Sampling Rate Precision Recall F1-Score Accuracy
12 kHz 0.49 0.48 0.46 0.93
16 kHz 0.40 0.53 0.44 0.87
22.05 kHz 0.48 0.52 0.48 0.86
40 kHz 0.60 0.45 0.49 0.93

Overall validation accuracy: 92%

Phase 3 — Wavelet-CNN Classification

Class Precision Recall F1-Score
Bronchiectasis 0.92 0.92 0.92
Bronchiolitis 0.94 0.92 0.93
COPD 0.96 0.90 0.91
Healthy 0.94 0.94 0.95
Pneumonia 0.92 0.94 0.94
URTI 0.92 0.92 0.92
Overall Accuracy 0.90

🛠️ Methodology

Feature Extraction — MFCC

  1. Pre-emphasis — First-order FIR filter (α = 0.95–0.97)
  2. Framing — 20–30 ms overlapping frames
  3. Windowing — Hamming window
  4. STFT — Short-Time Fourier Transform for spectral analysis
  5. Mel Filter Bank — Perceptual frequency scaling
  6. DCT — Discrete Cosine Transform for cepstral coefficients (12–20 coefficients)

Feature Extraction — Wavelet Transform

  1. CWT — Continuous Wavelet Transform using Morlet wavelet
  2. Scalogram — 2D time-frequency energy map
  3. Log Compression — Enhances dynamic range
  4. CNN Input — Scalogram images fed to CNN for classification

CNN Architecture (MFCC-based)

Input (MFCC: 40 coefficients × Time Frames)
  → Conv2D (32 filters, 3×3) + ReLU + BatchNorm + MaxPooling
  → Conv2D (64 filters, 3×3) + ReLU + BatchNorm + MaxPooling
  → Conv2D (128 filters, 3×3) + ReLU + BatchNorm
  → Global Average Pooling
  → Dense (128) + ReLU + Dropout (0.4)
  → Output (Softmax, n_classes)

📁 Dataset

ICBHI 2017 Respiratory Sound Database

  • 126 participants (children, adults, elderly)
  • 920 labeled recordings (10–90 seconds each)
  • ~5.5 hours of audio
  • 6,898 respiratory cycles
    • 886 with wheezes
    • 1,864 with crackles
    • 506 with both

🔧 Tech Stack

  • Language: Python
  • Audio Processing: Librosa, NumPy, SciPy
  • Feature Extraction: MFCC, CWT (Morlet Wavelet)
  • Deep Learning: TensorFlow / Keras (CNN)
  • Visualization: Matplotlib
  • Data Augmentation: Noise addition, time stretching, pitch shifting

🚀 Key Findings

  • Cough detection CNN achieves 97.4% accuracy with MFCC features
  • 12 kHz sampling rate offers the most balanced performance for disease classification — most clinically relevant cough features lie below 6–8 kHz
  • Wavelet (CWT) scalograms outperform MFCCs for non-stationary transient events (crackles, wheezes), improving accuracy from ~83% to 90%
  • COPD and Pneumonia achieve the highest per-class accuracy due to distinct spectral signatures
  • Minority classes (URTI, LRTI) suffer from limited data — augmentation and GAN-based synthesis recommended for future work

🔭 Future Scope

  • Expand dataset with more diverse cough samples
  • GAN-based data synthesis for rare disease classes
  • Transfer learning and attention mechanisms for subtle acoustic variations
  • Real-time mobile/web-based screening tool
  • Explainable AI (XAI) for clinical trust
  • Multi-modal integration (audio + patient metadata)

📚 References

  1. Al-Anazi et al., "Artificial intelligence in respiratory care," Annals of Thoracic Medicine, 2024.
  2. Albawi et al., "Understanding of Convolutional Neural Network (CNN)," ICET, 2017.
  3. Ghrabli, Elgendi & Menon, "A spectrogram-based framework for identifying spectral fingerprints in cough sounds," 2024.
  4. Author et al., "AI-assisted COVID-19 cough screening using MFCC and log-Mel features," 2023.
  5. Sriram, Kumar & Singh, "AI-based cough sound analysis: A survey of ML and DL methods," 2022.
  6. Author et al., "Systematic review of AI-based biomedical sound analysis," 2024.
  7. Bhattacharya et al., "Wavelet-enhanced CNN for chronic cough detection," 2022.
  8. Aykanat et al., "Automatic classification of adventitious respiratory sounds using CNNs," 2017.

"By combining signal processing and deep learning, this framework provides a scalable and efficient solution for automated respiratory disease diagnosis — supporting remote health monitoring and early screening."

About

Automated respiratory disease diagnosis from cough sounds using MFCC + Wavelet CNN. Detects cough with 97.4% accuracy and classifies COPD, Pneumonia, Bronchiectasis & more with 92% accuracy. Built with Python, Librosa & TensorFlow.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages