Skip to content

Filters

filters

AbsoluteValueFilter

Bases: BaseFilter

Rectifies the signal by taking the magnitude of every sample.

enabled class-attribute instance-attribute

Python
enabled: bool = True

Whether this filter step is active.

type class-attribute instance-attribute

Python
type: Literal[ABSOLUTE_VALUE] = ABSOLUTE_VALUE

The discriminator type for Pydantic.

apply_with_context

Python
apply_with_context(
    series: Series, df: DataFrame
) -> Series | None

Override for filters that need access to other columns. Receives the current (already-transformed) series and the original dataframe. Return None to fall back to apply(expr).

Source code in src/mujoco_mojo/utils/filters/filters.py
Python
def apply_with_context(
    self, series: pl.Series, df: pl.DataFrame
) -> pl.Series | None:
    """
    Override for filters that need access to other columns.
    Receives the current (already-transformed) series and the original dataframe.
    Return None to fall back to apply(expr).
    """
    return None

ClipFilter

Bases: BaseFilter

Clamps the signal values within a specified range.

enabled class-attribute instance-attribute

Python
enabled: bool = True

Whether this filter step is active.

type class-attribute instance-attribute

Python
type: Literal[CLIP] = CLIP

The discriminator type for Pydantic.

min class-attribute instance-attribute

Python
min: float | None = None

Optional lower bound; values below this will be set to min.

max class-attribute instance-attribute

Python
max: float | None = None

Optional upper bound; values above this will be set to max.

apply_with_context

Python
apply_with_context(
    series: Series, df: DataFrame
) -> Series | None

Override for filters that need access to other columns. Receives the current (already-transformed) series and the original dataframe. Return None to fall back to apply(expr).

Source code in src/mujoco_mojo/utils/filters/filters.py
Python
def apply_with_context(
    self, series: pl.Series, df: pl.DataFrame
) -> pl.Series | None:
    """
    Override for filters that need access to other columns.
    Receives the current (already-transformed) series and the original dataframe.
    Return None to fall back to apply(expr).
    """
    return None

ComparisonFilter

Bases: BaseFilter

Compares each sample against a threshold, returning 1.0 (true) or 0.0 (false).

enabled class-attribute instance-attribute

Python
enabled: bool = True

Whether this filter step is active.

type class-attribute instance-attribute

Python
type: Literal[COMPARISON] = COMPARISON

The discriminator type for Pydantic.

operator class-attribute instance-attribute

Python
operator: _COMPARISON_OPS = Field(
    default="gt", json_schema_extra={"ui_type": "select"}
)

Comparison operator: gt (>), gte (>=), lt (<), lte (<=), eq (==), neq (!=).

threshold class-attribute instance-attribute

Python
threshold: float = 0.0

The value to compare each sample against.

apply_with_context

Python
apply_with_context(
    series: Series, df: DataFrame
) -> Series | None

Override for filters that need access to other columns. Receives the current (already-transformed) series and the original dataframe. Return None to fall back to apply(expr).

Source code in src/mujoco_mojo/utils/filters/filters.py
Python
def apply_with_context(
    self, series: pl.Series, df: pl.DataFrame
) -> pl.Series | None:
    """
    Override for filters that need access to other columns.
    Receives the current (already-transformed) series and the original dataframe.
    Return None to fall back to apply(expr).
    """
    return None

DeadbandFilter

Bases: BaseFilter

Suppresses noise around zero by forcing values below a threshold to zero.

enabled class-attribute instance-attribute

Python
enabled: bool = True

Whether this filter step is active.

type class-attribute instance-attribute

Python
type: Literal[DEADBAND] = DEADBAND

The discriminator type for Pydantic.

threshold class-attribute instance-attribute

Python
threshold: float = Field(default=0.01, ge=0)

Magnitude threshold; values where abs(x) <= threshold are set to 0.

apply_with_context

Python
apply_with_context(
    series: Series, df: DataFrame
) -> Series | None

Override for filters that need access to other columns. Receives the current (already-transformed) series and the original dataframe. Return None to fall back to apply(expr).

Source code in src/mujoco_mojo/utils/filters/filters.py
Python
def apply_with_context(
    self, series: pl.Series, df: pl.DataFrame
) -> pl.Series | None:
    """
    Override for filters that need access to other columns.
    Receives the current (already-transformed) series and the original dataframe.
    Return None to fall back to apply(expr).
    """
    return None

DerivativeFilter

Bases: BaseFilter

Computes the numerical rate of change using backward difference. Useful for deriving velocity from position or acceleration from velocity.

enabled class-attribute instance-attribute

Python
enabled: bool = True

Whether this filter step is active.

type class-attribute instance-attribute

Python
type: Literal[DERIVATIVE] = DERIVATIVE

The discriminator type for Pydantic.

dt class-attribute instance-attribute

Python
dt: float = Field(default=0.001, gt=0)

The time step between samples in seconds. Ignored when wrt_col is set.

wrt_col class-attribute instance-attribute

Python
wrt_col: str | None = Field(
    default=None, json_schema_extra={"ui_type": "col"}
)

Optional column to differentiate with respect to instead of a fixed dt.

ExpFilter

Bases: BaseFilter

Raises a base to the power of each signal sample. Defaults to e^x.

enabled class-attribute instance-attribute

Python
enabled: bool = True

Whether this filter step is active.

type class-attribute instance-attribute

Python
type: Literal[EXP] = EXP

The discriminator type for Pydantic.

base class-attribute instance-attribute

Python
base: float = Field(default=e, gt=0)

The base to exponentiate. Use e (2.718...) for the natural exponential.

apply_with_context

Python
apply_with_context(
    series: Series, df: DataFrame
) -> Series | None

Override for filters that need access to other columns. Receives the current (already-transformed) series and the original dataframe. Return None to fall back to apply(expr).

Source code in src/mujoco_mojo/utils/filters/filters.py
Python
def apply_with_context(
    self, series: pl.Series, df: pl.DataFrame
) -> pl.Series | None:
    """
    Override for filters that need access to other columns.
    Receives the current (already-transformed) series and the original dataframe.
    Return None to fall back to apply(expr).
    """
    return None

FirstFilter

Bases: BaseFilter

Reduces the signal to its first value, broadcast across every sample.

enabled class-attribute instance-attribute

Python
enabled: bool = True

Whether this filter step is active.

type class-attribute instance-attribute

Python
type: Literal[STAT_FIRST] = STAT_FIRST

The discriminator type for Pydantic.

apply_with_context

Python
apply_with_context(
    series: Series, df: DataFrame
) -> Series | None

Override for filters that need access to other columns. Receives the current (already-transformed) series and the original dataframe. Return None to fall back to apply(expr).

Source code in src/mujoco_mojo/utils/filters/filters.py
Python
def apply_with_context(
    self, series: pl.Series, df: pl.DataFrame
) -> pl.Series | None:
    """
    Override for filters that need access to other columns.
    Receives the current (already-transformed) series and the original dataframe.
    Return None to fall back to apply(expr).
    """
    return None

HighPassFilter

Bases: BaseFilter

Removes low-frequency drift or steady-state offsets. Implemented as the complement of the Exponential Moving Average.

enabled class-attribute instance-attribute

Python
enabled: bool = True

Whether this filter step is active.

type class-attribute instance-attribute

Python
type: Literal[HIGH_PASS] = HIGH_PASS

The discriminator type for Pydantic.

alpha class-attribute instance-attribute

Python
alpha: float = Field(default=0.1, gt=0, le=1)

Smoothing factor used for the underlying low-pass component.

apply_with_context

Python
apply_with_context(
    series: Series, df: DataFrame
) -> Series | None

Override for filters that need access to other columns. Receives the current (already-transformed) series and the original dataframe. Return None to fall back to apply(expr).

Source code in src/mujoco_mojo/utils/filters/filters.py
Python
def apply_with_context(
    self, series: pl.Series, df: pl.DataFrame
) -> pl.Series | None:
    """
    Override for filters that need access to other columns.
    Receives the current (already-transformed) series and the original dataframe.
    Return None to fall back to apply(expr).
    """
    return None

IntegralFilter

Bases: BaseFilter

Computes the cumulative sum of the signal multiplied by the time step. Useful for deriving position from velocity or calculating energy.

enabled class-attribute instance-attribute

Python
enabled: bool = True

Whether this filter step is active.

type class-attribute instance-attribute

Python
type: Literal[INTEGRAL] = INTEGRAL

The discriminator type for Pydantic.

dt class-attribute instance-attribute

Python
dt: float = Field(default=0.001, gt=0)

The time step between samples in seconds. Ignored when wrt_col is set.

wrt_col class-attribute instance-attribute

Python
wrt_col: str | None = Field(
    default=None, json_schema_extra={"ui_type": "col"}
)

Optional column to integrate with respect to instead of a fixed dt.

LastFilter

Bases: BaseFilter

Reduces the signal to its last value, broadcast across every sample.

enabled class-attribute instance-attribute

Python
enabled: bool = True

Whether this filter step is active.

type class-attribute instance-attribute

Python
type: Literal[STAT_LAST] = STAT_LAST

The discriminator type for Pydantic.

apply_with_context

Python
apply_with_context(
    series: Series, df: DataFrame
) -> Series | None

Override for filters that need access to other columns. Receives the current (already-transformed) series and the original dataframe. Return None to fall back to apply(expr).

Source code in src/mujoco_mojo/utils/filters/filters.py
Python
def apply_with_context(
    self, series: pl.Series, df: pl.DataFrame
) -> pl.Series | None:
    """
    Override for filters that need access to other columns.
    Receives the current (already-transformed) series and the original dataframe.
    Return None to fall back to apply(expr).
    """
    return None

LogFilter

Bases: BaseFilter

Applies a logarithm to the signal. Defaults to natural log (base e).

enabled class-attribute instance-attribute

Python
enabled: bool = True

Whether this filter step is active.

type class-attribute instance-attribute

Python
type: Literal[LOG] = LOG

The discriminator type for Pydantic.

base class-attribute instance-attribute

Python
base: float = Field(default=e, gt=0)

Logarithm base. Use e (2.718...) for natural log, 2 for log2, 10 for log10.

apply_with_context

Python
apply_with_context(
    series: Series, df: DataFrame
) -> Series | None

Override for filters that need access to other columns. Receives the current (already-transformed) series and the original dataframe. Return None to fall back to apply(expr).

Source code in src/mujoco_mojo/utils/filters/filters.py
Python
def apply_with_context(
    self, series: pl.Series, df: pl.DataFrame
) -> pl.Series | None:
    """
    Override for filters that need access to other columns.
    Receives the current (already-transformed) series and the original dataframe.
    Return None to fall back to apply(expr).
    """
    return None

LowPassFilter

Bases: BaseFilter

Applies a 1st-order Exponential Moving Average (EMA) to smooth the signal. Effective for removing high-frequency noise while introducing slight phase lag.

enabled class-attribute instance-attribute

Python
enabled: bool = True

Whether this filter step is active.

type class-attribute instance-attribute

Python
type: Literal[LOW_PASS] = LOW_PASS

The discriminator type for Pydantic.

alpha class-attribute instance-attribute

Python
alpha: float = Field(default=0.1, gt=0, le=1)

Smoothing factor (0 < alpha <= 1). Lower values result in heavier smoothing.

apply_with_context

Python
apply_with_context(
    series: Series, df: DataFrame
) -> Series | None

Override for filters that need access to other columns. Receives the current (already-transformed) series and the original dataframe. Return None to fall back to apply(expr).

Source code in src/mujoco_mojo/utils/filters/filters.py
Python
def apply_with_context(
    self, series: pl.Series, df: pl.DataFrame
) -> pl.Series | None:
    """
    Override for filters that need access to other columns.
    Receives the current (already-transformed) series and the original dataframe.
    Return None to fall back to apply(expr).
    """
    return None

MaxFilter

Bases: BaseFilter

Reduces the signal to its maximum value, broadcast across every sample.

enabled class-attribute instance-attribute

Python
enabled: bool = True

Whether this filter step is active.

type class-attribute instance-attribute

Python
type: Literal[STAT_MAX] = STAT_MAX

The discriminator type for Pydantic.

apply_with_context

Python
apply_with_context(
    series: Series, df: DataFrame
) -> Series | None

Override for filters that need access to other columns. Receives the current (already-transformed) series and the original dataframe. Return None to fall back to apply(expr).

Source code in src/mujoco_mojo/utils/filters/filters.py
Python
def apply_with_context(
    self, series: pl.Series, df: pl.DataFrame
) -> pl.Series | None:
    """
    Override for filters that need access to other columns.
    Receives the current (already-transformed) series and the original dataframe.
    Return None to fall back to apply(expr).
    """
    return None

MeanFilter

Bases: BaseFilter

Reduces the signal to its mean value, broadcast across every sample.

enabled class-attribute instance-attribute

Python
enabled: bool = True

Whether this filter step is active.

type class-attribute instance-attribute

Python
type: Literal[STAT_MEAN] = STAT_MEAN

The discriminator type for Pydantic.

apply_with_context

Python
apply_with_context(
    series: Series, df: DataFrame
) -> Series | None

Override for filters that need access to other columns. Receives the current (already-transformed) series and the original dataframe. Return None to fall back to apply(expr).

Source code in src/mujoco_mojo/utils/filters/filters.py
Python
def apply_with_context(
    self, series: pl.Series, df: pl.DataFrame
) -> pl.Series | None:
    """
    Override for filters that need access to other columns.
    Receives the current (already-transformed) series and the original dataframe.
    Return None to fall back to apply(expr).
    """
    return None

MedianFilter

Bases: BaseFilter

Reduces the signal to its median value, broadcast across every sample.

enabled class-attribute instance-attribute

Python
enabled: bool = True

Whether this filter step is active.

type class-attribute instance-attribute

Python
type: Literal[STAT_MEDIAN] = STAT_MEDIAN

The discriminator type for Pydantic.

apply_with_context

Python
apply_with_context(
    series: Series, df: DataFrame
) -> Series | None

Override for filters that need access to other columns. Receives the current (already-transformed) series and the original dataframe. Return None to fall back to apply(expr).

Source code in src/mujoco_mojo/utils/filters/filters.py
Python
def apply_with_context(
    self, series: pl.Series, df: pl.DataFrame
) -> pl.Series | None:
    """
    Override for filters that need access to other columns.
    Receives the current (already-transformed) series and the original dataframe.
    Return None to fall back to apply(expr).
    """
    return None

MinFilter

Bases: BaseFilter

Reduces the signal to its minimum value, broadcast across every sample.

enabled class-attribute instance-attribute

Python
enabled: bool = True

Whether this filter step is active.

type class-attribute instance-attribute

Python
type: Literal[STAT_MIN] = STAT_MIN

The discriminator type for Pydantic.

apply_with_context

Python
apply_with_context(
    series: Series, df: DataFrame
) -> Series | None

Override for filters that need access to other columns. Receives the current (already-transformed) series and the original dataframe. Return None to fall back to apply(expr).

Source code in src/mujoco_mojo/utils/filters/filters.py
Python
def apply_with_context(
    self, series: pl.Series, df: pl.DataFrame
) -> pl.Series | None:
    """
    Override for filters that need access to other columns.
    Receives the current (already-transformed) series and the original dataframe.
    Return None to fall back to apply(expr).
    """
    return None

ModeFilter

Bases: BaseFilter

Reduces the signal to its most frequent value, broadcast across every sample.

enabled class-attribute instance-attribute

Python
enabled: bool = True

Whether this filter step is active.

type class-attribute instance-attribute

Python
type: Literal[STAT_MODE] = STAT_MODE

The discriminator type for Pydantic.

apply_with_context

Python
apply_with_context(
    series: Series, df: DataFrame
) -> Series | None

Override for filters that need access to other columns. Receives the current (already-transformed) series and the original dataframe. Return None to fall back to apply(expr).

Source code in src/mujoco_mojo/utils/filters/filters.py
Python
def apply_with_context(
    self, series: pl.Series, df: pl.DataFrame
) -> pl.Series | None:
    """
    Override for filters that need access to other columns.
    Receives the current (already-transformed) series and the original dataframe.
    Return None to fall back to apply(expr).
    """
    return None

NormalizeFilter

Bases: BaseFilter

Rescales the signal to the range [0, 1].

enabled class-attribute instance-attribute

Python
enabled: bool = True

Whether this filter step is active.

type class-attribute instance-attribute

Python
type: Literal[NORMALIZE] = NORMALIZE

The discriminator type for Pydantic.

apply_with_context

Python
apply_with_context(
    series: Series, df: DataFrame
) -> Series | None

Override for filters that need access to other columns. Receives the current (already-transformed) series and the original dataframe. Return None to fall back to apply(expr).

Source code in src/mujoco_mojo/utils/filters/filters.py
Python
def apply_with_context(
    self, series: pl.Series, df: pl.DataFrame
) -> pl.Series | None:
    """
    Override for filters that need access to other columns.
    Receives the current (already-transformed) series and the original dataframe.
    Return None to fall back to apply(expr).
    """
    return None

PowerFilter

Bases: BaseFilter

Raises each signal sample to a fixed exponent. Supports fractional exponents (e.g. 0.5 for sqrt).

enabled class-attribute instance-attribute

Python
enabled: bool = True

Whether this filter step is active.

type class-attribute instance-attribute

Python
type: Literal[POWER] = POWER

The discriminator type for Pydantic.

exponent class-attribute instance-attribute

Python
exponent: float = Field(default=2.0)

The power to raise each sample to. Use 0.5 for square root, 1/3 for cube root.

apply_with_context

Python
apply_with_context(
    series: Series, df: DataFrame
) -> Series | None

Override for filters that need access to other columns. Receives the current (already-transformed) series and the original dataframe. Return None to fall back to apply(expr).

Source code in src/mujoco_mojo/utils/filters/filters.py
Python
def apply_with_context(
    self, series: pl.Series, df: pl.DataFrame
) -> pl.Series | None:
    """
    Override for filters that need access to other columns.
    Receives the current (already-transformed) series and the original dataframe.
    Return None to fall back to apply(expr).
    """
    return None

ReverseFilter

Bases: BaseFilter

Reverses the order of the signal's values without changing their order of occurrence in time.

enabled class-attribute instance-attribute

Python
enabled: bool = True

Whether this filter step is active.

type class-attribute instance-attribute

Python
type: Literal[REVERSE] = REVERSE

The discriminator type for Pydantic.

apply_with_context

Python
apply_with_context(
    series: Series, df: DataFrame
) -> Series | None

Override for filters that need access to other columns. Receives the current (already-transformed) series and the original dataframe. Return None to fall back to apply(expr).

Source code in src/mujoco_mojo/utils/filters/filters.py
Python
def apply_with_context(
    self, series: pl.Series, df: pl.DataFrame
) -> pl.Series | None:
    """
    Override for filters that need access to other columns.
    Receives the current (already-transformed) series and the original dataframe.
    Return None to fall back to apply(expr).
    """
    return None

RollingMeanFilter

Bases: BaseFilter

Applies a sliding window average to the signal.

enabled class-attribute instance-attribute

Python
enabled: bool = True

Whether this filter step is active.

type class-attribute instance-attribute

Python
type: Literal[ROLLING_MEAN] = ROLLING_MEAN

The discriminator type for Pydantic.

window class-attribute instance-attribute

Python
window: int = Field(default=10, gt=0)

Size of the sliding window in samples.

center class-attribute instance-attribute

Python
center: bool = True

If True, centers the window on the current sample to minimize phase lag.

apply_with_context

Python
apply_with_context(
    series: Series, df: DataFrame
) -> Series | None

Override for filters that need access to other columns. Receives the current (already-transformed) series and the original dataframe. Return None to fall back to apply(expr).

Source code in src/mujoco_mojo/utils/filters/filters.py
Python
def apply_with_context(
    self, series: pl.Series, df: pl.DataFrame
) -> pl.Series | None:
    """
    Override for filters that need access to other columns.
    Receives the current (already-transformed) series and the original dataframe.
    Return None to fall back to apply(expr).
    """
    return None

RollingMedianFilter

Bases: BaseFilter

Applies a sliding window median filter. Highly effective for removing impulse noise (spikes) without blurring edges.

enabled class-attribute instance-attribute

Python
enabled: bool = True

Whether this filter step is active.

type class-attribute instance-attribute

Python
type: Literal[MEDIAN] = MEDIAN

The discriminator type for Pydantic.

window class-attribute instance-attribute

Python
window: int = Field(default=10, gt=0)

Size of the sliding window in samples.

apply_with_context

Python
apply_with_context(
    series: Series, df: DataFrame
) -> Series | None

Override for filters that need access to other columns. Receives the current (already-transformed) series and the original dataframe. Return None to fall back to apply(expr).

Source code in src/mujoco_mojo/utils/filters/filters.py
Python
def apply_with_context(
    self, series: pl.Series, df: pl.DataFrame
) -> pl.Series | None:
    """
    Override for filters that need access to other columns.
    Receives the current (already-transformed) series and the original dataframe.
    Return None to fall back to apply(expr).
    """
    return None

RotationFilter

Bases: BaseFilter

Rotates a 3D vector component into a reference frame using a quaternion column.

enabled class-attribute instance-attribute

Python
enabled: bool = True

Whether this filter step is active.

type class-attribute instance-attribute

Python
type: Literal[ROTATION] = ROTATION

The discriminator type for Pydantic.

quat_col class-attribute instance-attribute

Python
quat_col: str = Field(
    "", json_schema_extra={"ui_type": "quat_col"}
)

Base name of the quaternion column group (e.g. 'Bodies/hand/xquat').

invert class-attribute instance-attribute

Python
invert: bool = True

If True, transforms world-to-local (invert the quaternion rotation).

apply_to_frame

Python
apply_to_frame(
    df: DataFrame, vector_bases: set[str]
) -> DataFrame

Rotate all xyz vector families in vector_bases in one pass. Used by MojoDataFrame.with_rotation and any write path that needs the full-frame transform.

Source code in src/mujoco_mojo/utils/filters/filters.py
Python
def apply_to_frame(self, df: pl.DataFrame, vector_bases: set[str]) -> pl.DataFrame:
    """Rotate all xyz vector families in `vector_bases` in one pass. Used by `MojoDataFrame.with_rotation` and any write path that needs the full-frame transform."""
    q_cols = [f"{self.quat_col}:{k}" for k in "xyzw"]
    if not all(c in df.columns for c in q_cols):
        return df
    qs = df.select(q_cols).to_numpy()
    new_columns: list[pl.Series] = []
    for base in vector_bases:
        v_cols = [f"{base}:x", f"{base}:y", f"{base}:z"]
        if not all(c in df.columns for c in v_cols):
            continue
        v_rot = self._rotate(df.select(v_cols).to_numpy(), qs.copy())
        new_columns.extend(
            [
                pl.Series(name=f"{base}:x", values=v_rot[:, 0]),
                pl.Series(name=f"{base}:y", values=v_rot[:, 1]),
                pl.Series(name=f"{base}:z", values=v_rot[:, 2]),
            ]
        )
    return df.with_columns(new_columns) if new_columns else df

RoundFilter

Bases: BaseFilter

Quantizes the signal to a fixed number of decimal places.

enabled class-attribute instance-attribute

Python
enabled: bool = True

Whether this filter step is active.

type class-attribute instance-attribute

Python
type: Literal[ROUND] = ROUND

The discriminator type for Pydantic.

method class-attribute instance-attribute

Python
method: Literal["round", "floor", "ceil"] = Field(
    default="round", json_schema_extra={"ui_type": "select"}
)

Rounding method: round (nearest), floor (toward -inf), or ceil (toward +inf).

decimals class-attribute instance-attribute

Python
decimals: int = Field(default=0, ge=0)

Number of decimal places to round to (only used when method is 'round').

apply_with_context

Python
apply_with_context(
    series: Series, df: DataFrame
) -> Series | None

Override for filters that need access to other columns. Receives the current (already-transformed) series and the original dataframe. Return None to fall back to apply(expr).

Source code in src/mujoco_mojo/utils/filters/filters.py
Python
def apply_with_context(
    self, series: pl.Series, df: pl.DataFrame
) -> pl.Series | None:
    """
    Override for filters that need access to other columns.
    Receives the current (already-transformed) series and the original dataframe.
    Return None to fall back to apply(expr).
    """
    return None

SavitzkyGolayFilter

Bases: BaseFilter

Applies a Savitzky-Golay smoothing filter by fitting a polynomial to the data. Preserves signal features (like peaks and transients) better than a simple moving average.

enabled class-attribute instance-attribute

Python
enabled: bool = True

Whether this filter step is active.

type class-attribute instance-attribute

Python
type: Literal[SAVITZKY_GOLAY] = SAVITZKY_GOLAY

The discriminator type for Pydantic.

window class-attribute instance-attribute

Python
window: int = Field(default=11, gt=1)

Number of samples in the sliding window; must be an odd integer.

order class-attribute instance-attribute

Python
order: int = Field(default=2, ge=0)

The order of the polynomial used to fit the samples.

apply_with_context

Python
apply_with_context(
    series: Series, df: DataFrame
) -> Series | None

Override for filters that need access to other columns. Receives the current (already-transformed) series and the original dataframe. Return None to fall back to apply(expr).

Source code in src/mujoco_mojo/utils/filters/filters.py
Python
def apply_with_context(
    self, series: pl.Series, df: pl.DataFrame
) -> pl.Series | None:
    """
    Override for filters that need access to other columns.
    Receives the current (already-transformed) series and the original dataframe.
    Return None to fall back to apply(expr).
    """
    return None

ScaleFilter

Bases: BaseFilter

Applies a linear transformation: (value * factor) + offset.

enabled class-attribute instance-attribute

Python
enabled: bool = True

Whether this filter step is active.

type class-attribute instance-attribute

Python
type: Literal[SCALE] = SCALE

The discriminator type for Pydantic.

factor class-attribute instance-attribute

Python
factor: float = 1.0

Multiplicative gain applied to the signal.

offset class-attribute instance-attribute

Python
offset: float = 0.0

Additive constant applied after scaling.

apply_with_context

Python
apply_with_context(
    series: Series, df: DataFrame
) -> Series | None

Override for filters that need access to other columns. Receives the current (already-transformed) series and the original dataframe. Return None to fall back to apply(expr).

Source code in src/mujoco_mojo/utils/filters/filters.py
Python
def apply_with_context(
    self, series: pl.Series, df: pl.DataFrame
) -> pl.Series | None:
    """
    Override for filters that need access to other columns.
    Receives the current (already-transformed) series and the original dataframe.
    Return None to fall back to apply(expr).
    """
    return None

SignFilter

Bases: BaseFilter

Returns the sign of each sample: 1 for positive, -1 for negative, 0 for zero.

enabled class-attribute instance-attribute

Python
enabled: bool = True

Whether this filter step is active.

type class-attribute instance-attribute

Python
type: Literal[SIGN] = SIGN

The discriminator type for Pydantic.

apply_with_context

Python
apply_with_context(
    series: Series, df: DataFrame
) -> Series | None

Override for filters that need access to other columns. Receives the current (already-transformed) series and the original dataframe. Return None to fall back to apply(expr).

Source code in src/mujoco_mojo/utils/filters/filters.py
Python
def apply_with_context(
    self, series: pl.Series, df: pl.DataFrame
) -> pl.Series | None:
    """
    Override for filters that need access to other columns.
    Receives the current (already-transformed) series and the original dataframe.
    Return None to fall back to apply(expr).
    """
    return None

SortFilter

Bases: BaseFilter

Sorts the signal's values in ascending or descending order.

enabled class-attribute instance-attribute

Python
enabled: bool = True

Whether this filter step is active.

type class-attribute instance-attribute

Python
type: Literal[SORT] = SORT

The discriminator type for Pydantic.

descending class-attribute instance-attribute

Python
descending: bool = False

Whether to sort in descending order.

apply_with_context

Python
apply_with_context(
    series: Series, df: DataFrame
) -> Series | None

Override for filters that need access to other columns. Receives the current (already-transformed) series and the original dataframe. Return None to fall back to apply(expr).

Source code in src/mujoco_mojo/utils/filters/filters.py
Python
def apply_with_context(
    self, series: pl.Series, df: pl.DataFrame
) -> pl.Series | None:
    """
    Override for filters that need access to other columns.
    Receives the current (already-transformed) series and the original dataframe.
    Return None to fall back to apply(expr).
    """
    return None

StandardDeviationFilter

Bases: BaseFilter

Reduces the signal to its standard deviation, broadcast across every sample.

enabled class-attribute instance-attribute

Python
enabled: bool = True

Whether this filter step is active.

type class-attribute instance-attribute

Python
type: Literal[STAT_STANDARD_DEVIATION] = (
    STAT_STANDARD_DEVIATION
)

The discriminator type for Pydantic.

apply_with_context

Python
apply_with_context(
    series: Series, df: DataFrame
) -> Series | None

Override for filters that need access to other columns. Receives the current (already-transformed) series and the original dataframe. Return None to fall back to apply(expr).

Source code in src/mujoco_mojo/utils/filters/filters.py
Python
def apply_with_context(
    self, series: pl.Series, df: pl.DataFrame
) -> pl.Series | None:
    """
    Override for filters that need access to other columns.
    Receives the current (already-transformed) series and the original dataframe.
    Return None to fall back to apply(expr).
    """
    return None

TaringFilter

Bases: BaseFilter

Offsets the entire signal so that the first sample is zero.

enabled class-attribute instance-attribute

Python
enabled: bool = True

Whether this filter step is active.

type class-attribute instance-attribute

Python
type: Literal[TARING] = TARING

The discriminator type for Pydantic.

apply_with_context

Python
apply_with_context(
    series: Series, df: DataFrame
) -> Series | None

Override for filters that need access to other columns. Receives the current (already-transformed) series and the original dataframe. Return None to fall back to apply(expr).

Source code in src/mujoco_mojo/utils/filters/filters.py
Python
def apply_with_context(
    self, series: pl.Series, df: pl.DataFrame
) -> pl.Series | None:
    """
    Override for filters that need access to other columns.
    Receives the current (already-transformed) series and the original dataframe.
    Return None to fall back to apply(expr).
    """
    return None

TrigFilter

Bases: BaseFilter

Applies a trigonometric or angle-conversion function to the signal.

enabled class-attribute instance-attribute

Python
enabled: bool = True

Whether this filter step is active.

type class-attribute instance-attribute

Python
type: Literal[TRIG] = TRIG

The discriminator type for Pydantic.

func class-attribute instance-attribute

Python
func: _TRIG_FUNCS = Field(
    default="sin", json_schema_extra={"ui_type": "select"}
)

The trig function to apply.

apply_with_context

Python
apply_with_context(
    series: Series, df: DataFrame
) -> Series | None

Override for filters that need access to other columns. Receives the current (already-transformed) series and the original dataframe. Return None to fall back to apply(expr).

Source code in src/mujoco_mojo/utils/filters/filters.py
Python
def apply_with_context(
    self, series: pl.Series, df: pl.DataFrame
) -> pl.Series | None:
    """
    Override for filters that need access to other columns.
    Receives the current (already-transformed) series and the original dataframe.
    Return None to fall back to apply(expr).
    """
    return None

UnitFilter

Bases: BaseFilter

Unit conversion using Pint. Ensures dimensional consistency and applies necessary scaling/offsets.

enabled class-attribute instance-attribute

Python
enabled: bool = True

Whether this filter step is active.

type class-attribute instance-attribute

Python
type: Literal[UNIT] = UNIT

The discriminator type for Pydantic.

from_unit instance-attribute

Python
from_unit: SignalUnit

The original unit of the telemetry data (e.g., 'rad').

to_unit instance-attribute

Python
to_unit: SignalUnit

The target unit for analysis/display (e.g., 'deg').

apply_with_context

Python
apply_with_context(
    series: Series, df: DataFrame
) -> Series | None

Override for filters that need access to other columns. Receives the current (already-transformed) series and the original dataframe. Return None to fall back to apply(expr).

Source code in src/mujoco_mojo/utils/filters/filters.py
Python
def apply_with_context(
    self, series: pl.Series, df: pl.DataFrame
) -> pl.Series | None:
    """
    Override for filters that need access to other columns.
    Receives the current (already-transformed) series and the original dataframe.
    Return None to fall back to apply(expr).
    """
    return None

WrapFilter

Bases: BaseFilter

Keeps circular data (like Euler angles or radians) within a specific range. Ensures continuity when a signal crosses the upper or lower boundary.

enabled class-attribute instance-attribute

Python
enabled: bool = True

Whether this filter step is active.

type class-attribute instance-attribute

Python
type: Literal[WRAP] = WRAP

The discriminator type for Pydantic.

lb class-attribute instance-attribute

Python
lb: float = -pi

Lower boundary for the wrap operation.

ub class-attribute instance-attribute

Python
ub: float = pi

Upper boundary for the wrap operation.

apply_with_context

Python
apply_with_context(
    series: Series, df: DataFrame
) -> Series | None

Override for filters that need access to other columns. Receives the current (already-transformed) series and the original dataframe. Return None to fall back to apply(expr).

Source code in src/mujoco_mojo/utils/filters/filters.py
Python
def apply_with_context(
    self, series: pl.Series, df: pl.DataFrame
) -> pl.Series | None:
    """
    Override for filters that need access to other columns.
    Receives the current (already-transformed) series and the original dataframe.
    Return None to fall back to apply(expr).
    """
    return None