Filters¶
Output-side smoothing filters for prediction-output control vectors. Custom filters implement the VectorFilter protocol below. See Post-process predictions for tuning guidance.
The protocol¶
Built-in filters¶
OneEuroFilter ¶
OneEuroFilter(freq: float = 50.0, min_cutoff: float = 1.0, beta: float = 0.02, d_cutoff: float = 1.0)
1€ Filter — adaptive low-pass for noisy interactive signals.
Trades latency for smoothness based on instantaneous velocity: fast motion → high cutoff (responsive), slow motion → low cutoff (smooth). Standard for hand tracking, controllers, gesture cursors.
Reference: https://gery.casiez.net/1euro/
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
freq
|
float
|
Expected sample rate (Hz). Used as a fallback dt when no
timestamp is passed to |
50.0
|
min_cutoff
|
float
|
Cutoff (Hz) at zero velocity — controls baseline smoothing. |
1.0
|
beta
|
float
|
Velocity-to-cutoff gain. Larger → more responsive on fast moves. |
0.02
|
d_cutoff
|
float
|
Cutoff (Hz) for the velocity smoother. |
1.0
|
Source code in myogestic/filters.py
GaussianFilter ¶
Rolling temporal smoothing for 1-D vectors.
Keeps the last window vectors and returns their Gaussian-weighted
mean (weights peak at the most recent sample). During warmup (buffer
not yet full), weights are renormalized over the available history —
no zero-padding bias.
Inputs must be 1-D arrays of consistent length (raises on first dimension mismatch).
Source code in myogestic/filters.py
IdentityFilter ¶
Passthrough — useful as a baseline or "off" toggle.
Factory¶
make_filter ¶
make_filter(name: str, hz: float = 50.0, **kwargs: Any) -> VectorFilter
Construct a filter by name. Swap filters in an experiment by changing one string; pass extra kwargs to tune without instantiating the class directly.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
|
required |
hz
|
float
|
Expected sample rate. Forwarded as |
50.0
|
**kwargs
|
Any
|
Forwarded to the filter constructor — e.g.
|
{}
|
Raises:
| Type | Description |
|---|---|
ValueError
|
if the name isn't recognized. |
TypeError
|
if a kwarg is unknown for the chosen filter. |