Acoustic Emission Analysis, Real-Time Acquisition & Machine Learning Platform for Plant Cavitation Monitoring
- ๐ Overview
- โจ Key Features
- ๐ Benchmark Results (Classical ML vs. Deep Learning)
- ๐ ๏ธ Technology Stack
- ๐น๏ธ Hardware Setup
- ๐ Installation & Setup
- ๐ฎ Usage Guide
- ๐ Project Architecture
- ๐ฌ Scientific Reproducibility
AE-Lab is an end-to-end laboratory and software platform designed to record, process, and classify Acoustic Emission (AE) events in plants. It specifically targets xylem cavitation phenomenaโmicroscopic air bubble collapse events within vascular plant tissues under drought or mechanical stress.
By interfacing directly with high-frequency oscilloscope hardware (PicoScope), the platform captures ultrasonic transients at sampling rates up to 50 MS/s. The raw signals undergo feature engineering and are benchmarked across both Classical Machine Learning (Random Forest, XGBoost, Support Vector Machines) and Deep Learning pipelines (1D Waveform Convolutional Neural Networks and 2D Continuous Wavelet Transform networks).
-
PicoScope Hardware Interface: Native integration via
picosdkfor high-frequency oscilloscope data acquisition. - Live Oscilloscope & FFT Dashboard: A Streamlit-based interface visualizing raw waveforms ($V(t)$) and real-time Fast Fourier Transform (FFT) spectra.
- Automated Triggering: Configurable voltage triggers capture discrete transient bursts with pre-trigger buffering to avoid clipping event shock fronts.
-
Noise vs. Cavitation Detection: Classifies genuine cavitation events against ambient acoustic noise and electrical transients (achieving
$>99.5%$ accuracy and$100%$ signal recall). - Plant Species Classification: Leave-One-Plant-Out (LOPO) cross-validation assessing species-specific acoustic traits across unseen specimens (Capsicum annuum, Helianthus annuus, Solanum lycopersicum).
- Stress Type Diagnosis: Distinguishes mechanical cutting (xylem severance) from hydraulic drought stress across grouped plant cross-validation folds.
-
1D-CNN on Raw Waveforms: Processes decimated raw voltage series (
$3{,}125$ samples at$12.5\text{ MS/s}$ ) with hierarchical temporal convolutional kernels, bypassing manual feature extraction. -
2D-CNN on CWT Scalograms: Converts waveforms into time-frequency power scalograms via analytic complex Morlet wavelets (
$32\text{ frequency scales} \times 128\text{ time steps}$ ) to capture non-stationary resonance decay. - Unified Benchmark Suite: Leakage-free, multi-seed cross-validation comparing classical and deep architectures on strictly identical sample partitions.
- Interactive 3D UMAP / t-SNE Projections: High-dimensional acoustic feature space exploration in interactive 3D WebGL plots.
- Anomaly Detection: Identifies outliers and mislabeled events using Isolation Forests and Gaussian Mixture Models.
- Visual Lasso Relabeling: Rapid manual relabeling of acoustic clusters directly in the UI to clean ground-truth datasets.
All models are evaluated under strict grouped validation protocols without data leakage:
| Task | Classical ML Baseline | 1D Waveform CNN | 2D CWT Scalogram CNN | Key Physical Finding |
|---|---|---|---|---|
| 1. Noise vs. Cavitation (4,855 hold-out events) |
99.53% Acc / 0.9787 Macro F1 (Random Forest, 10 features) |
99.41% Acc / 0.9738 Macro F1 (99.4% Signal Recall, 0.976 F2) |
90.34% Acc / 0.8027 Macro F1 (90.7% Signal Recall) |
Full Success: Raw 1D-CNN completely eliminates manual feature engineering for noise screening. |
| 2. Plant Species (LOPO) (13 plants, 575 test events) |
15.30% Acc / 0.1452 Macro F1 (XGBoost + UMAP, 65 features) |
17.80% Acc / 0.1966 Macro F1 (32.25% Mean Plant Acc) |
19.94% Acc / 0.1802 Macro F1 (32.49% Mean Plant Acc) |
Specimen Bottleneck: Handcrafted & deep models stall below chance due to plant acoustic transfer function. |
| 3. Stress Type (196 samples) (98 Drought vs. 98 Cut) |
44.39% Acc / 0.4406 Macro F1 (SVM RBF, 62 features) |
43.88% Acc / 0.4303 Macro F1 (Raw 1D series) |
53.57% Acc / 0.5288 Macro F1 (Morlet Scalogram) |
Acoustic Overlap: Single burst transients overlap physically; contextual environmental data required. |
| 3. Stress Type (502 samples) (251 Drought vs. 251 Cut) |
56.77% Acc / 0.5674 Macro F1 (SVM RBF, 62 features) |
33.27% Acc / 0.3307 Macro F1 (Raw 1D series) |
59.83% Acc / 0.5807 Macro F1 (Morlet Scalogram) |
CWT Advantage: Time-frequency representation extracts subtle fracture dynamics on larger data cohorts. |
Detailed metrics, derivations, and confusion matrices are documented in results/deep_learning/model_comparison_summary.md.
| Category | Components & Libraries |
|---|---|
| Deep Learning | PyTorch (torch, torch.nn), PyWavelets (pywt) |
| Classical ML | Scikit-Learn, Imbalanced-Learn (SMOTE), XGBoost, Optuna |
| Unsupervised ML | UMAP-Learn, HDBSCAN |
| Web Dashboard | Streamlit, Plotly Express, Plotly Graph Objects |
| Hardware Acquisition | PicoSDK (Pico Technology 5000-series Oscilloscopes) |
| Data Processing | Pandas, NumPy, SciPy, Pillow |
| Database | SQLite3 (metadata.db) |
The physical setup consists of a piezoelectric acoustic emission sensor (e.g., Pico-HF) coupled to the plant stem, interfaced through preamplifiers into a PicoScope digital oscilloscope.
To ensure acoustic contact without damaging delicate vascular tissues, the sensor is clamped using acoustic couplant gel and buffered with a compliant backing on the opposing stem side:
- Python 3.10+ (64-bit recommended)
- PicoScope Drivers: Install the official Pico Technology drivers corresponding to your oscilloscope hardware (Windows / Linux).
# Clone repository
git clone https://github.com/ETCE-LAB/AE-Lab.git
cd AE-Lab
# Create and activate virtual environment
python -m venv venv
# Windows:
venv\Scripts\activate
# Linux/macOS:
source venv/bin/activate
# Install dependencies
pip install -r requirements.txtDownload the existing dataset here: https://doi.org/10.25625/S6FHPE
Create a new folder at root level in this project
mkdir dataExtract all .zip files into this folder.
The metadata.db references the measurements by their filename. Place the metadata.db at root level in this project.
If existing apps are running, restart them to refresh the connection.
Launch the interactive Streamlit data acquisition interface:
streamlit run data_collection/data_collection.pyAllows connecting to the PicoScope, configuring trigger thresholds, and monitoring real-time waveforms and FFT spectrograms.
Launch the data analysis and exploratory machine learning suite:
streamlit run data_analysis/data_analysis.pyVisualizes recordings, evaluates trained models on test sets, and explores 3D UMAP feature projections with interactive lasso relabeling.
# Train noise rejection Random Forest
python model_training/train_and_save_noise_model.py
# Train plant species classifier (Leave-One-Plant-Out)
python model_training/train_and_save_plant_model.py
# Train stress diagnosis SVM
python model_training/train_and_save_stress_model.py# Run the complete, leakage-free benchmark across all tasks:
python model_training/deep_learning/unified_benchmark.py all --seeds 3
# Or benchmark specific tasks individually:
python model_training/deep_learning/unified_benchmark.py noise
python model_training/deep_learning/unified_benchmark.py plant
python model_training/deep_learning/unified_benchmark.py stress
# Generate Markdown reports and summary comparison tables:
python model_training/deep_learning/compare_models.pyAE-Lab/
โโโ .documentation/ # Visual assets, hardware setup diagrams, and schematics
โโโ data/ # Raw Spectrum and Frequency data files
โโโ data_collection/ # Real-time PicoScope interface, streamer & acquisition UI
โ โโโ data_collection.py # Streamlit acquisition dashboard
โ โโโ picoscope_measure.py # Hardware controller & oscilloscope trigger loops
โ โโโ feature_cache.csv # Pre-extracted acoustic feature cache
โโโ data_analysis/ # Analysis dashboards, unsupervised clustering & lasso relabeling
โ โโโ data_analysis.py # Main analysis dashboard
โ โโโ unsupervised_pipeline.py # 3D UMAP & clustering engine
โโโ helper_scripts/ # Feature extraction, audio transform & SQLite sync utilities
โโโ model_training/ # Supervised ML & Deep Learning training pipelines
โ โโโ train_and_save_noise_model.py # Classical Noise classifier (Random Forest)
โ โโโ train_and_save_plant_model.py # Classical Plant classifier (XGBoost LOPO)
โ โโโ train_and_save_stress_model.py # Classical Stress classifier (SVM RBF)
โ โโโ deep_learning/ # End-to-end Deep Learning benchmark suite
โ โโโ dataset.py # Waveform decimation, Morlet CWT generator & PyTorch Datasets
โ โโโ models.py # 1D-CNN (Waveform) & 2D-CNN (CWT Scalogram) architectures
โ โโโ unified_benchmark.py # Synchronized, leakage-free benchmark runner
โ โโโ compare_models.py # Automated report & markdown table generator
โ โโโ plot_comparison.py # Interactive Plotly visual benchmark comparisons
โโโ models/ # Saved models, encoders, scalers, and JSON metadata
โ โโโ *.pkl # Classical models, scalers, and label encoders
โ โโโ deep_learning/ # Trained PyTorch weights (*.pt) & benchmark metric JSONs
โโโ results/ # HTML interactive charts, cluster outputs & evaluations
โ โโโ deep_learning/ # Comprehensive thesis reports & comparison summaries
โโโ .gitignore # Git exclusion rules (ignores raw wave data, large caches, scratch)
โโโ metadata.db # SQLite database tracking recordings, labels, and metadata
โโโ requirements.txt # Project dependencies
This repository contains the experimental framework and models developed in the Bachelor thesis:
"Machine Learning-Based Detection and Classification of Plant Xylem Cavitation Events Using Acoustic Emission Sensors"
Author: Marius Peter
Institution: Institute for Software and Systems Engineering, Clausthal University of Technology

