Overview
The signal processing pipeline transforms magnified video signals into accurate vital sign measurements. This involves temporal bandpass filtering to isolate physiological frequencies, followed by FFT-based spectral analysis to extract dominant frequencies.The pipeline uses scientifically validated techniques from digital signal processing, including Butterworth filters and Fast Fourier Transform (FFT) with Hamming windowing.
Temporal Bandpass Filtering
Temporal filtering isolates the frequency components that correspond to heart rate and respiratory rate by removing DC components, low-frequency drift, and high-frequency noise.Filter Design
The system uses Butterworth bandpass filters for their maximally flat frequency response in the passband:src/evm/temporal_filtering.py:3-27
Why Butterworth Filters?
Why Butterworth Filters?
Advantages:
- Maximally flat passband (no ripples)
- Predictable roll-off characteristics
- Stable for low-order implementations
- Computationally efficient
- Chebyshev (steeper roll-off but passband ripples)
- Bessel (better phase response but slower roll-off)
- Elliptic (sharpest cutoff but both passband and stopband ripples)
Filter Application
Theapply_temporal_bandpass() function applies the filter along the temporal axis of the video tensor:
src/evm/temporal_filtering.py:30-60
The
filtfilt() function applies the filter twice (forward and backward) to achieve zero-phase distortion, which is critical for preserving temporal alignment of physiological signals.Frequency Bands
Heart Rate Band
Frequency Range: 0.8 - 3.0 HzBPM Equivalent: 48 - 180 BPMConfiguration:Captures cardiac pulse variations visible through photoplethysmography.
Respiratory Rate Band
Frequency Range: 0.2 - 0.8 HzBPM Equivalent: 12 - 48 breaths/minConfiguration:Captures breathing-related motion and color changes.
src/config.py:3-14
Dual-Band Filtering
While both bands can be filtered in a single function call, the system processes them independently for maximum flexibility:src/evm/temporal_filtering.py:63-95
Signal Extraction
After filtering and amplification, spatial averaging converts the 4D tensor (Time × Height × Width × Channels) into a 1D temporal signal.Spatial Averaging
src/evm/signal_analysis.py:4-23
Why Green Channel for Heart Rate?
Why Green Channel for Heart Rate?
The green channel (wavelength ~550 nm) provides the best signal-to-noise ratio for photoplethysmography:
- Maximum hemoglobin absorption: Green light is strongly absorbed by hemoglobin
- Reduced motion artifacts: Less sensitive to skin tone variations
- Better penetration: Optimal depth for capillary bed imaging
Frequency Analysis via FFT
Fast Fourier Transform (FFT) converts the temporal signal from time domain to frequency domain, allowing identification of dominant periodicities.Signal Preprocessing
Before FFT, the signal undergoes preprocessing to improve spectral quality:src/evm/signal_analysis.py:25-55
Hamming Window
A Hamming window reduces spectral leakage by smoothly tapering the signal at boundaries:src/evm/signal_analysis.py:57-67
Spectral Leakage Explained
Spectral Leakage Explained
The Problem:
- FFT assumes the signal is periodic over the window length
- Real signals rarely satisfy this assumption
- Discontinuities at window boundaries create spurious frequencies
- Hamming window gradually reduces signal amplitude toward edges
- Window formula: w(n) = 0.54 - 0.46 × cos(2πn/N)
- Reduces side lobe levels by ~40 dB
- Reduces spectral leakage
- Slightly broadens the main lobe (reduces frequency resolution)
- For vital signs, this trade-off is favorable
Power Spectrum Calculation
src/evm/signal_analysis.py:69-86
The power spectrum represents the distribution of signal energy across frequencies. Peaks in the power spectrum indicate dominant periodicities.
Dominant Frequency Detection
src/evm/signal_analysis.py:88-125
Complete Pipeline
Thecalculate_frequency_fft() function orchestrates the complete analysis:
src/evm/signal_analysis.py:127-158
Processing Flow Diagram
Validation and Quality Control
Physiological Bounds
The system enforces strict physiological limits configured insrc/config.py:6-14:
Signal Quality Checks
Minimum Frame Count
Minimum Frame Count
Requires ≥30 frames for reliable frequency analysis:Reason: At 30 FPS, 30 frames = 1 second of data. Reliable spectral analysis requires multiple cycles of the target frequency.
Non-Zero Variance
Non-Zero Variance
Rejects constant or near-constant signals:Reason: Constant signals indicate ROI failure, static images, or sensor issues.
Valid Frequency Range
Valid Frequency Range
Ensures detected frequency falls within physiological and filter passband:Reason: Prevents reporting noise peaks as valid measurements.
Performance Considerations
Computational Complexity
| Operation | Complexity | Notes |
|---|---|---|
| Butterworth filter design | O(1) | Constant time for fixed order |
| filtfilt() application | O(N × M) | N frames, M pixels per frame |
| Spatial averaging | O(N × M) | Single pass through tensor |
| FFT | O(N log N) | N = signal length |
| Peak detection | O(N) | Linear scan of power spectrum |
Total complexity is dominated by filtering: O(N × M). For typical parameters (30 frames, 40×30 pixels at level 3), this is ~36,000 operations per band.
Optimization Strategies
- Pyramid-level processing: Operate on downsampled data
- Green channel extraction: Process 1 channel instead of 3
- Single-pass filtering: Process both bands from same pyramid
- Vectorized operations: NumPy/SciPy use optimized BLAS/LAPACK
Usage Example
Related Concepts
Eulerian Video Magnification
Learn about pyramid decomposition and amplification
Face Detection
Understand ROI extraction for signal processing
System Overview
See how signal processing fits in the pipeline
API Reference
Explore signal analysis API