In parallel, a desktop app capable of analysing and visualizing data in real time was to be developed. The app was also designed to reflect our project's mission, ensuring accessibility to all computer platforms, while still being capable of detailed scientific analysis of both voltage signals and ultrasonic data.
PlantLeaf's desktop app is free to download here and the full code is open-sourced in our GitHub repository under the AGPLv3 licence.
Additional tools are available for waveform characterization:
The exponential fit is overlaid on the envelope and colour-coded by fit quality — green (R² ≥ 0.70), orange (R² ≥ 0.45) and red (R² < 0.45). R² and τ are both computed on the Gaussian-smoothed envelope and the fitting process is described here.
Along with the PlantLeaf app, a 4-stage algorithm (version 6) to detect ultrasonic clicks autonomously and in real time was developed. No official research has ever published an algorithm capable of distinguishing clicks from noises using only one microphone and inexpensive instrumentation. Where earlier versions of our algorithm relied on fixed, hand-tuned thresholds, v6 replaces them with an adaptive noise floor and a trained machine-learning classifier to make everything more robust both in silent and noisy environments, across different hardware gains and different plant species.
- Distinguish ultrasonic clicks from environmental noise and automatically detect stress situations -
The audio signal is transmitted as a 512-point FFT packet along with int8-encoded phase for 390 frames/s. Then, the algorithm compensates for the non-flat frequency response of the SPU0410LR5H-QB microphone using a conservative 50% correction (estimated error ±2.9 dB).
Finally, the data can reach the Adaptive Noise Estimator, which consists of two parallel sliding-window minimum-statistics estimators sharing one burst-protection gate and one window length — one in the FFT energy domain (for Stage 1), one in the iFFT/Hilbert envelope domain (for the time-domain features). A third buffer is also computed for frequency bin tracking.
View FlowchartOperating on Ê_floor(i) from buffer B1, this stage is intended to discard all the frames that are not energetic enough to be clicks. Two filters are applied: first, the candidate has to be at least 1.5 times more energetic than the noise floor; second, the local maxima of the frame-energy series is selected. Events longer than 3 frames are not discarded anymore, as they were in v5.
View FlowchartStage 2 is intended to discard all easily-distinguishable noise and let all clicks continue. It uses 4 hard gates, with thresholds confirmed not to block any click over our 200 hours of recordings as well as in official datasets from ongoing research (Khait et al.). Furthermore, it prevents out-of-distribution noise from reaching Stage 3's SVM and consequently corrupting its scalars.
View FlowchartAfter an initial pre-processing pipeline necessary to create the context in which the features can be computed, a trained SVM is used to classify noise and clicks. Trained on hard-negatives and clicks from over 200 hours of recordings of noise, control (plant-only) and stressed plants, it uses 7 features computed on the iFFT of the event to finally decide whether an event is a click or not.
View FlowchartThe final candidates pass a deduplication stage meant to merge events that are within 40 µs of each other and are consequently physically the same click.
View Flowchart402 861 exported rows · 32 recordings exhaustively labelled (6 074 rows: 189 clicks, 99 ambiguous, 5 786 noise). 0.93 cross-validated AUC-ROC, 0.96 on held-out. 0 clicks lost to stage 2.
View FlowchartOnce accepted click events reach this layer, a sliding-window statistic tracks their rate in real time and raises a transient stress-event flag whenever it crosses a threshold calibrated empirically on control recordings, rather than derived from a theoretical noise model.
Hysteresis and a refractory period keep the detector from chattering near the threshold and collapse a single physical burst into one reported onset, with the threshold itself re-measured on baseline data after any change upstream in the pipeline.
See Click ExamplesFor electrical signals, the app automatically fits the best mathematical model to each selected event:
Fitting uses non-linear least squares scipy.optimize.curve_fit, reporting the goodness of fit R² in quality bands and the signal energy via trapezoidal integration. Across 20 recorded action potentials the model reached a mean R² of ≈ 0.976, confirming strong agreement with the observed physiology.