|
| 1 | +# PyEyesWeb Feature Testing CLI |
| 2 | + |
| 3 | +**Purpose**: This CLI tool is a **playground for exploration**. It's designed to help you quickly understand how PyEyesWeb features work by testing them with synthetic signals. This is NOT meant for production testing or scientific validation. It is simply a hands on way to get familiar with the framework's capabilities. |
| 4 | + |
| 5 | +Command line tool for testing PyEyesWeb features with synthetic signals. |
| 6 | + |
| 7 | +## Quick Start |
| 8 | + |
| 9 | +```bash |
| 10 | +# Show all available commands and options |
| 11 | +python tests/feature_test_cli.py --help |
| 12 | + |
| 13 | +# List all features |
| 14 | +python tests/feature_test_cli.py list-features |
| 15 | + |
| 16 | +# List all available signal types |
| 17 | +python tests/feature_test_cli.py list-signals |
| 18 | +``` |
| 19 | + |
| 20 | +## Basic Usage |
| 21 | + |
| 22 | +```bash |
| 23 | +python tests/feature_test_cli.py <feature> --signal <signal_type> [options] |
| 24 | +``` |
| 25 | + |
| 26 | +## Available Features |
| 27 | + |
| 28 | +- **smoothness** - Analyze signal smoothness (SPARC, jerk metrics) |
| 29 | +- **bilateral-symmetry** - Left-right symmetry analysis |
| 30 | +- **equilibrium** - Balance and stability evaluation |
| 31 | +- **synchronization** - Multi-signal phase locking |
| 32 | +- **contraction-expansion** - Area expansion/contraction tracking |
| 33 | + |
| 34 | +## Common Examples |
| 35 | + |
| 36 | +### Test Smoothness |
| 37 | +```bash |
| 38 | +# Basic smoothness test with sine wave |
| 39 | +python tests/feature_test_cli.py smoothness --signal sine --length 1000 |
| 40 | + |
| 41 | +# Compare two signals (smooth vs noisy) |
| 42 | +python tests/feature_test_cli.py smoothness --signal sine --signal2 random --length 1000 |
| 43 | + |
| 44 | +# Save results with timestamp |
| 45 | +python tests/feature_test_cli.py smoothness --signal sine --save-results smoothness_test.json |
| 46 | +``` |
| 47 | + |
| 48 | +### Test Synchronization |
| 49 | +```bash |
| 50 | +# Test phase locking between two signals |
| 51 | +python tests/feature_test_cli.py synchronization --signal sine --freq 10 |
| 52 | + |
| 53 | +# Test with chirp signals |
| 54 | +python tests/feature_test_cli.py synchronization --signal chirp --freq-start 1 --freq-end 50 |
| 55 | +``` |
| 56 | + |
| 57 | +### Test Bilateral Symmetry |
| 58 | +```bash |
| 59 | +# Single signal (compares left/right from same signal) |
| 60 | +python tests/feature_test_cli.py bilateral-symmetry --signal sine |
| 61 | + |
| 62 | +# Two different signals (stroke patient simulation) |
| 63 | +python tests/feature_test_cli.py bilateral-symmetry --signal sine --signal2 random |
| 64 | +``` |
| 65 | + |
| 66 | +### Test Equilibrium |
| 67 | +```bash |
| 68 | +# Analyze balance/stability |
| 69 | +python tests/feature_test_cli.py equilibrium --signal gaussian --std 1.5 --drift 0.01 |
| 70 | +``` |
| 71 | + |
| 72 | +### Test Contraction-Expansion |
| 73 | +```bash |
| 74 | +# Analyze expansion patterns |
| 75 | +python tests/feature_test_cli.py contraction-expansion --signal square --freq 5 |
| 76 | +``` |
| 77 | + |
| 78 | +## Output Files |
| 79 | + |
| 80 | +Results are automatically saved to the `output/` directory with timestamps: |
| 81 | + |
| 82 | +```bash |
| 83 | +# Specify filename (timestamp added automatically) |
| 84 | +python tests/feature_test_cli.py smoothness --signal sine --save-results mytest.json |
| 85 | +# Creates: output/20251008_181335_mytest.json |
| 86 | + |
| 87 | +# Files are sorted chronologically (newest first) |
| 88 | +ls -lt output/ |
| 89 | +``` |
| 90 | + |
| 91 | +## Signal Types |
| 92 | + |
| 93 | +Use `list-signals` to see all 38+ available signal types organized by category: |
| 94 | +- Basic Waveforms (sine, cosine, square, triangle, sawtooth) |
| 95 | +- Noise Signals (random, gaussian, pink, brownian) |
| 96 | +- Chirp Signals (chirp, exponential_chirp, hyperbolic_chirp) |
| 97 | +- Modulated (am, fm, pm, tremor, ecg, emg) |
| 98 | +- And more... |
| 99 | + |
| 100 | +```bash |
| 101 | +python tests/feature_test_cli.py list-signals |
| 102 | +``` |
| 103 | + |
| 104 | +## Advanced Options |
| 105 | + |
| 106 | +```bash |
| 107 | +# Set signal parameters |
| 108 | +--length 1000 # Signal length (samples) |
| 109 | +--freq 10.0 # Frequency (Hz) |
| 110 | +--amplitude 1.0 # Signal amplitude |
| 111 | +--phase 0.0 # Phase offset |
| 112 | +--sampling-rate 100.0 # Sampling rate (Hz) |
| 113 | + |
| 114 | +# Add noise/modulation |
| 115 | +--noise-level 0.1 # Noise level |
| 116 | +--std 1.5 # Standard deviation |
| 117 | +--drift 0.01 # Drift amount |
| 118 | + |
| 119 | +# Chirp parameters |
| 120 | +--freq-start 1.0 # Start frequency |
| 121 | +--freq-end 50.0 # End frequency |
| 122 | + |
| 123 | +# Biological signals |
| 124 | +--heart-rate 80 # Heart rate (for ECG) |
| 125 | + |
| 126 | +# Output control |
| 127 | +--quiet # Minimal output |
| 128 | +--save-results file.json # Save with timestamp |
| 129 | +--seed 42 # Random seed for reproducibility |
| 130 | +``` |
| 131 | + |
| 132 | +## When to Use One Signal vs Two Signals |
| 133 | + |
| 134 | +### Smoothness |
| 135 | + |
| 136 | +**One Signal (`--signal`)**: Test how smooth a single movement is. Example: Analyzing a patient's arm movement to detect tremor or jerkiness. |
| 137 | + |
| 138 | +**Two Signals (`--signal` + `--signal2`)**: Compare smoothness between two different movements. Example: Testing if a patient's left arm (sine wave = smooth) moves more smoothly than their right arm (random = jerky), indicating a potential stroke. |
| 139 | + |
| 140 | +```bash |
| 141 | +# One signal: test if movement is smooth |
| 142 | +python tests/feature_test_cli.py smoothness --signal sine |
| 143 | + |
| 144 | +# Two signals: compare smooth vs jerky (stroke simulation) |
| 145 | +python tests/feature_test_cli.py smoothness --signal sine --signal2 random |
| 146 | +``` |
| 147 | + |
| 148 | +### Bilateral Symmetry |
| 149 | + |
| 150 | +**One Signal (`--signal`)**: Analyze symmetry within a single signal by comparing left/right halves. Example: Checking if a person's gait has symmetrical left-right stepping patterns. |
| 151 | + |
| 152 | +**Two Signals (`--signal` + `--signal2`)**: Compare symmetry between two separate signals representing left and right sides. Example: Testing if left arm movement (sine = healthy) is symmetrical to right arm movement (random = impaired), detecting asymmetry after injury. |
| 153 | + |
| 154 | +```bash |
| 155 | +# One signal: check internal left-right symmetry |
| 156 | +python tests/feature_test_cli.py bilateral-symmetry --signal sine |
| 157 | + |
| 158 | +# Two signals: compare left vs right movement (injury simulation) |
| 159 | +python tests/feature_test_cli.py bilateral-symmetry --signal sine --signal2 random |
| 160 | +``` |
| 161 | + |
| 162 | +### Synchronization |
| 163 | + |
| 164 | +**One Signal (`--signal`)**: Generate two slightly phase-shifted versions of the same signal to test phase locking. Example: Testing if two brain regions stay synchronized during a task. |
| 165 | + |
| 166 | +**Two Signals (`--signal` + `--signal2`)**: Test synchronization between two completely different signals. Example: Checking if breathing (slow sine) synchronizes with heart rate (fast ECG), which happens during meditation. |
| 167 | + |
| 168 | +```bash |
| 169 | +# One signal: test phase locking with automatic phase shift |
| 170 | +python tests/feature_test_cli.py synchronization --signal sine --freq 10 |
| 171 | + |
| 172 | +# Two signals: test if different rhythms synchronize (breathing vs heartbeat) |
| 173 | +python tests/feature_test_cli.py synchronization --signal sine --freq 0.3 --signal2 ecg --heart-rate 80 |
| 174 | +``` |
| 175 | + |
| 176 | +### Equilibrium |
| 177 | + |
| 178 | +**One Signal (`--signal`)**: Analyze balance stability from a single center-of-mass signal. Example: Testing how much a person sways while standing still on one foot. |
| 179 | + |
| 180 | +**Two Signals (`--signal` + `--signal2`)**: Compare stability between two different balance conditions. Example: Testing if a person sways more with eyes closed (high noise) vs eyes open (low noise). |
| 181 | + |
| 182 | +```bash |
| 183 | +# One signal: test balance stability |
| 184 | +python tests/feature_test_cli.py equilibrium --signal gaussian --std 0.5 |
| 185 | + |
| 186 | +# Two signals: compare eyes open vs eyes closed stability |
| 187 | +python tests/feature_test_cli.py equilibrium --signal gaussian --std 0.5 --signal2 gaussian --std 2.0 |
| 188 | +``` |
| 189 | + |
| 190 | +### Contraction-Expansion |
| 191 | + |
| 192 | +**One Signal (`--signal`)**: Measure how body area expands and contracts over time. Example: Analyzing breathing patterns to detect if someone breathes smoothly or irregularly. |
| 193 | + |
| 194 | +**Two Signals (`--signal` + `--signal2`)**: Compare contraction patterns between two conditions. Example: Testing if breathing is smooth during rest (sine) vs irregular during anxiety (noisy signal). |
| 195 | + |
| 196 | +```bash |
| 197 | +# One signal: analyze breathing pattern |
| 198 | +python tests/feature_test_cli.py contraction-expansion --signal sine --freq 0.3 |
| 199 | + |
| 200 | +# Two signals: compare calm vs anxious breathing |
| 201 | +python tests/feature_test_cli.py contraction-expansion --signal sine --freq 0.3 --signal2 gaussian |
| 202 | +``` |
| 203 | + |
| 204 | +## Reproducibility |
| 205 | + |
| 206 | +Set a random seed for consistent results: |
| 207 | + |
| 208 | +```bash |
| 209 | +python tests/feature_test_cli.py smoothness --signal random --seed 42 |
| 210 | +``` |
| 211 | + |
| 212 | +## Tips |
| 213 | + |
| 214 | +1. **Start Simple** - Use basic signals (sine, cosine) to understand features |
| 215 | +2. **List First** - Always check `list-signals` and `list-features` |
| 216 | +3. **Save Results** - Use `--save-results` to track experiments |
| 217 | +4. **Use Seeds** - Add `--seed` for reproducible random signals |
| 218 | +5. **Compare Signals** - Use `--signal2` to simulate real-world scenarios |
| 219 | + |
| 220 | +## Output Format |
| 221 | + |
| 222 | +JSON results include: |
| 223 | +- Feature-specific metrics |
| 224 | +- Metadata (timestamp, parameters, elapsed time) |
| 225 | +- Signal configuration |
| 226 | + |
| 227 | +Example output structure: |
| 228 | +```json |
| 229 | +{ |
| 230 | + "sparc": -2.456, |
| 231 | + "jerk_rms": 0.123, |
| 232 | + "metadata": { |
| 233 | + "feature": "smoothness", |
| 234 | + "signal_type": "sine", |
| 235 | + "timestamp": "2025-10-08T18:13:35", |
| 236 | + "elapsed_time": 0.045, |
| 237 | + "parameters": {...} |
| 238 | + } |
| 239 | +} |
| 240 | +``` |
0 commit comments