Summary
Implement a Savitzky-Golay filter to reduce positional jitter in pedestrian trajectories. The filter should smooth each pedestrian's x/y coordinates independently while preserving trajectory metadata and frame alignment.
Background / Context
Trajectory data from recordings and simulations can contain small frame-to-frame position fluctuations. Unlike a simple moving average, a Savitzky-Golay filter fits local polynomials to preserve trajectory curvature and peak shape better while still suppressing noise.
Providing a built-in smoothing utility lets users reduce this noise consistently before computing derived quantities such as speed and acceleration, without manually manipulating the underlying DataFrame.
Technical Details
- Add the filtering functionality in the preprocessing API.
- Use
scipy.signal.savgol_filter (or equivalent) as the underlying implementation; add scipy usage in line with the existing scipy~=1.15,<2.0 dependency (no new dependency needed).
- Accept configurable window length (frames) and polynomial order parameters.
- Smooth
X_COL and Y_COL independently for each ID_COL, ordered by FRAME_COL.
- Preserve the original pedestrian IDs, frame numbers, and
TrajectoryData frame rate.
- Validate that window length is odd, positive, greater than the polynomial order, and does not exceed the number of frames available for a given pedestrian; raise an appropriate PedPy custom exception otherwise.
- Define and document boundary behavior for trajectories shorter than the window length.
- Export the public API from
pedpy/__init__.py and add it to __all__ if applicable.
- Add unit tests under
tests/unit_tests/ for normal operation, multiple pedestrians, boundary/short trajectories, and invalid parameter combinations.
Acceptance Criteria
Summary
Implement a Savitzky-Golay filter to reduce positional jitter in pedestrian trajectories. The filter should smooth each pedestrian's x/y coordinates independently while preserving trajectory metadata and frame alignment.
Background / Context
Trajectory data from recordings and simulations can contain small frame-to-frame position fluctuations. Unlike a simple moving average, a Savitzky-Golay filter fits local polynomials to preserve trajectory curvature and peak shape better while still suppressing noise.
Providing a built-in smoothing utility lets users reduce this noise consistently before computing derived quantities such as speed and acceleration, without manually manipulating the underlying DataFrame.
Technical Details
scipy.signal.savgol_filter(or equivalent) as the underlying implementation; addscipyusage in line with the existingscipy~=1.15,<2.0dependency (no new dependency needed).X_COLandY_COLindependently for eachID_COL, ordered byFRAME_COL.TrajectoryDataframe rate.pedpy/__init__.pyand add it to__all__if applicable.tests/unit_tests/for normal operation, multiple pedestrians, boundary/short trajectories, and invalid parameter combinations.Acceptance Criteria
TrajectoryDatainstance or the trajectory of a specific pedestrian(s) (by ID)