πŸ“Š Biomarker Extraction Technical Guide

Comprehensive Documentation of Camera-Based Vital Signs Detection

πŸ“š Table of Contents

visibility Overview & Scientific Basis

This guide provides comprehensive technical documentation on how biomarkers are extracted from facial video using remote photoplethysmography (rPPG) and computer vision techniques. The system analyzes subtle color changes in facial skin caused by blood circulation to derive vital signs without physical contact.

Core Scientific Principle

When the heart pumps blood through the cardiovascular system, it creates periodic changes in blood volume in the facial capillaries. These changes affect how light is absorbed and reflected by the skin, creating measurable variations in skin color that are invisible to the naked eye but detectable through video analysis.

Beer-Lambert Law: I = Iβ‚€ Γ— e^(-Ξ΅ Γ— c Γ— l) Where: - I = Transmitted light intensity - Iβ‚€ = Incident light intensity - Ξ΅ = Molar extinction coefficient - c = Concentration of chromophore (hemoglobin) - l = Path length through tissue

Why Green Channel?

Red Channel: Less sensitive to blood volume (more affected by lighting) Green Channel: Most sensitive to blood volume changes βœ“ Blue Channel: Too noisy, affected by shadows

Hemoglobin in blood absorbs green light (around 550nm wavelength) more strongly than red or blue, making it ideal for detecting blood volume changes.

favorite Heart Rate Detection

Signal Extraction Process

Step 1: Define Regions of Interest (ROI)

We extract signals from three facial regions with weighted averaging:

Forehead Region (50% weight)

Landmark indices: [9, 10, 151, 337, 299, 333, 298, 301]

The forehead provides the strongest PPG signal due to:

  • Minimal motion during normal activities
  • Large flat surface area
  • Rich superficial temporal artery perfusion
  • Thin skin with good light penetration

Left Cheek (25% weight)

Landmark indices: [116, 117, 118, 123, 205, 206, 207, 213]

Secondary signal source providing:

  • Facial artery perfusion
  • Redundancy for signal validation
  • Different vascular bed for averaging

Right Cheek (25% weight)

Landmark indices: [345, 346, 347, 352, 425, 426, 427, 436]

Tertiary signal for:

  • Bilateral averaging to reduce noise
  • Motion artifact detection
  • Signal quality assessment

Processing Pipeline

Step 2: Extract Green Channel Values

// For each ROI, extract average green channel value for (let i = 0; i < pixels.length; i += 4) { greenSum += pixels[i + 1]; // Green channel at index 1 pixelCount++; } averageGreen = greenSum / pixelCount; // Weight and combine signals from all ROIs weightedSignal = forehead * 0.5 + leftCheek * 0.25 + rightCheek * 0.25;

Step 3: Signal Detrending

Remove slow baseline drift caused by lighting changes or movement:

y_detrended(t) = y(t) - (a Γ— t + b) Where a (slope) and b (intercept) are computed using least squares: a = Ξ£((t - tΜ„)(y - Θ³)) / Ξ£((t - tΜ„)Β²) b = Θ³ - a Γ— tΜ„

Step 4: Bandpass Filtering

Apply Butterworth filter to isolate heart rate frequencies:

// Butterworth bandpass filter Passband: 0.5 Hz to 3.0 Hz Why: Human heart rate is typically 30-180 BPM (0.5-3.0 Hz) - Removes high-frequency noise - Removes low-frequency drift - Isolates cardiac frequency range

Step 5: FFT Analysis

Convert time-domain signal to frequency domain to identify heart rate:

X(k) = Ξ£(n=0 to N-1) x(n) Γ— e^(-j2Ο€kn/N) // Find dominant frequency in HR range peakFrequency = findPeakInRange(powerSpectrum, 0.5, 3.0) // Convert to BPM heartRate = peakFrequency Γ— 60

Signal Quality Metrics

SNR = 10 Γ— log₁₀(P_signal / P_noise) Where: - P_signal = Power at peak frequency - P_noise = Average power in high frequencies (> 4 Hz) Confidence Score Components: - SNR > 3 dB: +25% - Peak prominence > 0.5: +25% - Valid RR count > 10: +25% - Motion score < 0.3: +25%

timeline Heart Rate Variability (HRV)

What is HRV?

HRV measures the variation in time between heartbeats. Higher HRV generally indicates:

RMSSD Calculation

Root Mean Square of Successive Differences (RMSSD) is the most common time-domain HRV metric:

RMSSD = √(1/(N-1) Γ— Ξ£(RRα΅’β‚Šβ‚ - RRα΅’)Β²) Where: - RRα΅’ = Time interval between successive R-peaks (in ms) - N = Number of RR intervals

Peak Detection Algorithm

// 1. Calculate R-R intervals (time between peaks) rrIntervals = [] for (i = 1; i < peaks.length; i++) { interval = peaks[i].time - peaks[i-1].time rrIntervals.push(interval * 1000) // Convert to milliseconds } // 2. Filter outliers (physiologically invalid intervals) validIntervals = rrIntervals.filter(rr => rr > 300 && rr < 2000 // 30-200 BPM range ) // 3. Calculate successive differences differences = [] for (i = 1; i < validIntervals.length; i++) { diff = validIntervals[i] - validIntervals[i-1] differences.push(diff) } // 4. Calculate RMSSD squaredDiffs = differences.map(d => d * d) meanSquaredDiff = average(squaredDiffs) RMSSD = Math.sqrt(meanSquaredDiff) // 5. Clamp to reasonable range HRV = clamp(RMSSD, 15, 100) // milliseconds

Normal HRV Ranges (RMSSD)

Population Typical Range Notes
Healthy Adults 20-80 ms Varies with age and fitness
Athletes 50-100 ms Higher is better
Stressed/Unfit 10-30 ms Lower indicates strain
Age Factor -3-5% per decade Natural decline with age

air Respiratory Rate Detection

Respiratory Signal Sources

1. Respiratory Sinus Arrhythmia (RSA)

Heart rate naturally increases during inhalation and decreases during exhalation. This modulation appears as a low-frequency component (0.15-0.4 Hz) in the HRV signal.

2. Baseline Wandering

Breathing causes thoracic pressure changes that affect venous return, creating slow oscillations in the PPG baseline.

Extraction Method

// Extract respiratory rate from PPG or HRV signal function extractRespiratoryRate(signal) { // Apply bandpass filter (0.15-0.4 Hz for 9-24 breaths/min) filtered = bandpassFilter(signal, 0.15, 0.4); // Compute FFT spectrum = FFT(filtered); // Find peak in respiratory frequency range peak_freq = findMaxPower(spectrum, 0.15, 0.4); // Convert to breaths per minute respiratory_rate = peak_freq * 60; return respiratory_rate; }

Normal Respiratory Rates

Category Rate (breaths/min)
Resting Adult 12-20
During Exercise 20-30+
Meditation/Sleep 8-12

psychology Stress Level Assessment

Physiological Basis

Stress activates the sympathetic nervous system, causing measurable changes in:

Stress Indicators

Metric Low Stress Medium Stress High Stress
HRV (RMSSD) > 50 ms 30-50 ms < 30 ms
Heart Rate 60-70 BPM 70-85 BPM > 85 BPM
Respiratory Rate 12-16 br/min 16-20 br/min > 20 br/min

face Demographics & Skin Tone Analysis

Face Detection: MediaPipe Face Mesh

Using Google's MediaPipe to detect 468 3D facial landmarks in real-time:

// MediaPipe configuration const faceMesh = new FaceMesh({ maxNumFaces: 1, refineLandmarks: true, // Enhanced accuracy for iris minDetectionConfidence: 0.5, minTrackingConfidence: 0.5 });

Age & Gender Estimation

Using Face-API.js (Vladimir Mandic fork) with pre-trained neural networks:

Age Estimation

  • Architecture: ResNet-50 backbone
  • Training data: IMDB-WIKI dataset (500k+ faces)
  • Accuracy: Mean Absolute Error Β±3.5 years

Gender Classification

  • Architecture: MobileNetV2
  • Binary classification (male/female)
  • Training accuracy: 96.8%

Skin Tone Analysis (ITA Method)

ITA Calculation

ITAΒ° = [Arc Tangent((L* - 50) / b*)] Γ— (180 / Ο€) Where: - L* = Lightness in CIELAB color space (0-100) - b* = Yellow-blue axis (-128 to +127) Classification: Very Light: ITA > 55Β° Light: 41Β° < ITA ≀ 55Β° Intermediate: 28Β° < ITA ≀ 41Β° Tan: 10Β° < ITA ≀ 28Β° Brown: -30Β° < ITA ≀ 10Β° Dark: ITA ≀ -30Β°

Fitzpatrick Scale Mapping

function itaToFitzpatrick(ita) { if (ita > 55) return "Type I"; // Always burns, never tans if (ita > 41) return "Type II"; // Usually burns, tans minimally if (ita > 28) return "Type III"; // Sometimes burns, tans uniformly if (ita > 10) return "Type IV"; // Burns minimally, tans well if (ita > -30) return "Type V"; // Rarely burns, tans deeply return "Type VI"; // Never burns, deeply pigmented }

code Technical Implementation Details

System Architecture

Class: BiomarkerAnalyzer β”œβ”€β”€ Camera Management β”‚ β”œβ”€β”€ getUserMedia() - Access camera stream β”‚ └── setupCamera() - Configure video parameters β”‚ β”œβ”€β”€ Face Detection Pipeline β”‚ β”œβ”€β”€ MediaPipe Face Mesh - 468 landmarks @ 30 FPS β”‚ β”œβ”€β”€ Face-API.js - Demographics @ 0.5 FPS β”‚ └── Landmark smoothing - 5-frame weighted average β”‚ β”œβ”€β”€ Signal Processing β”‚ β”œβ”€β”€ ROI extraction - Green channel averaging β”‚ β”œβ”€β”€ Detrending - Linear regression removal β”‚ β”œβ”€β”€ Filtering - Butterworth bandpass (0.5-3.0 Hz) β”‚ └── FFT analysis - Frequency domain conversion β”‚ └── Visualization β”œβ”€β”€ Canvas overlay - Real-time face mesh └── Chart.js - Signal plots

Buffer Management

// Circular buffer for PPG signal // Typical: 150 frames (5 seconds at 30 FPS) ppgBuffer = new Float32Array(150); // Store green channel values over time ppgBuffer[index] = weightedGreenValue; index = (index + 1) % bufferSize;

Performance Optimizations

analytics Accuracy & Limitations

Typical Accuracy (compared to medical devices)

Biomarker Accuracy Requirements
Heart Rate Β±2-3 BPM Good lighting, minimal movement, 5+ seconds
HRV (RMSSD) Β±5-10 ms Good lighting, minimal movement, 5+ seconds
Respiratory Rate Β±2-3 br/min Good lighting, 10+ seconds

Factors Affecting Accuracy

Environmental Factors

  • Lighting: Consistent, bright lighting (200-500 lux)
  • Distance: 30-100cm from camera optimal
  • Camera quality: Minimum 720p @ 30 FPS
  • Motion: Head movement reduces accuracy

Subject Factors

  • Skin tone: Works across all skin tones
  • Facial hair: May reduce signal in cheek regions
  • Makeup: Heavy foundation can attenuate signal
  • Age: Elderly may have weaker signals

warning Important Limitations

  • Not suitable for medical diagnosis or treatment decisions
  • Cannot detect arrhythmias or structural heart conditions
  • Accuracy decreases during exercise or movement
  • Should not replace professional medical monitoring
  • For educational and wellness purposes only

library_books Scientific References & Open Source

Classic Foundations

Recent Research (2023-2025)

  • Deep Learning Review (2024): "Deep learning and remote photoplethysmography powered advancements in contactless physiological measurement"
    Frontiers in Bioengineering
  • Comprehensive Review (2024): "A comprehensive review of heart rate measurement using remote photoplethysmography and deep learning"
    PMC12181896
  • Face Regions Study (2025): "The role of face regions in remote photoplethysmography for contactless heart rate monitoring"
    Nature npj Digital Medicine
    Key Finding: Forehead and cheeks provide best accuracy (MAE < 1.0 BPM with ML)
  • Phase-Shifted Method (2024): "Phase-shifted remote photoplethysmography for estimating heart rate and blood pressure"
    ArXiv 2401.04560
  • HRV from Facial Video (2023): "Robust Heart Rate Variability Measurement from Facial Videos"
    MDPI Bioengineering
  • Transformer Architecture (2024): "Remote physiological signal recovery with efficient spatio-temporal modeling"
    Frontiers in Physiology

Open Source Libraries

  • MediaPipe Face Mesh - Apache License 2.0
    468 3D face landmarks with iris tracking
    Official Docs | GitHub | NPM
  • Face-API.js (Vladimir Mandic) - MIT License
    Age, gender, emotion, and expression detection
    GitHub | NPM
  • Chart.js - MIT License
    Data visualization for PPG signals and trends
    Official Docs | GitHub

info Additional Resources

For complete methodology details, see: