Application

Desktop Analysis Software

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.

Audio Analysis Mode

Main window
FFT Spectrum View

The main window displays the FFT spectrum of the current frame.

  • X-axis: frequency (20–80 kHz)
  • Y-axis: magnitude (volts)

A frame slider allows navigation through the recording. Playback controls can automatically advance frames. It is also possible to replay the recording at a slower rate to show every FFT frame.

FFT Spectrum View
Main window
Mean FFT Window

The second main window shows a plot of the mean energy per FFT to visualise generally how energy is evolving over time.

  • X-axis: time
  • Y-axis: the mean computed on the FFT spectrum

Two lines allow the user to graphically visualise how the noise floor computed via the Adaptive Noise Floor and the threshold used by stage 1 of the click detection algorithm are evolving.

Mean FFT Window
Main window
Inverse FFT (iFFT)

The iFFT tool reconstructs the time-domain waveform (512 samples) from FFT magnitude and phase data, applying a Tukey taper to suppress Gibbs ringing and allowing analysis with higher temporal resolution.

The window shows:

  • top panel: FFT spectrum
  • bottom panel: reconstructed waveform (512 samples)
Inverse FFT reconstruction
Waveform characterization

Envelope and Decay Analysis

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.

Envelope and Decay Analysis
Click Detection

Click Detection Algorithm v6

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.

Detection pipeline

Click Detection Pipeline

- Distinguish ultrasonic clicks from environmental noise and automatically detect stress situations -

Pre-computing

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 Flowchart

Stage 1

Operating 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 Flowchart

Stage 2

Stage 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 Flowchart

Stage 3

After 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 Flowchart

Stage 4

The 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 Flowchart

Results

402 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 Flowchart

Stress Detection Algorithm

Once 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 Examples
Voltage mode

Voltage Curve-Fitting Analysis

For 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.

Voltage curve fitting