Signal Processing
Signal processing utilities for PyEyesWeb.
This module provides signal processing functions including filtering, phase extraction, and smoothing operations used throughout the library.
apply_savgol_filter(signal, rate_hz=50.0)
Apply Savitzky-Golay filter if enough data is available.
Savitzky-Golay filtering smooths data while preserving features better than moving average filters. Uses polynomial order 3 and adaptive window length.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Notes
- Requires at least 5 samples for filtering
- Window length must exceed polynomial order (3)
- Returns original signal if filtering fails
Source code in pyeyesweb/utils/signal_processing.py
bandpass_filter(data, filter_params)
Apply a band-pass filter if filter_params is set.
Uses a 4th order Butterworth band-pass filter with zero-phase filtering (filtfilt) to avoid phase distortion.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Examples:
>>> data = np.random.randn(1000, 2) # 2 channels, 1000 samples
>>> filtered = bandpass_filter(data, (1.0, 10.0, 100.0)) # 1-10 Hz
Source code in pyeyesweb/utils/signal_processing.py
compute_hilbert_phases(sig)
Compute phase information from signals using Hilbert Transform.
The Hilbert transform creates an analytic signal from which instantaneous phase can be extracted. Assumes input has exactly 2 channels.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Notes
The Hilbert transform assumes the signal is narrowband or has been appropriately filtered for meaningful phase extraction.
Source code in pyeyesweb/utils/signal_processing.py
compute_phase_synchronization(signals, filter_params=None)
Compute phase synchronization between two signals.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in pyeyesweb/utils/signal_processing.py
validate_filter_params(lowcut, highcut, fs)
Validate filter frequency parameters.
Centralized validation for filter parameters used in bandpass_filter and Synchronization class.
| Parameters: |
|
|---|
| Returns: |
|
|---|
| Raises: |
|
|---|