vista.algorithms.tracks.interpolation.TrackInterpolation¶
- class vista.algorithms.tracks.interpolation.TrackInterpolation(track, method='linear')[source]¶
Interpolates missing frames in a track trajectory.
Takes a Track object that may have gaps in frame coverage and returns a new Track with interpolated positions for all missing frames between the first and last tracked frames.
- Parameters:
track (Track) – Input track that may have missing frames
method (str, optional) – Interpolation method for scipy.interp1d. Options include: - ‘linear’: Linear interpolation (default) - ‘nearest’: Nearest-neighbor interpolation - ‘zero’: Zero-order spline (piecewise constant) - ‘slinear’: First-order spline - ‘quadratic’: Second-order spline - ‘cubic’: Third-order spline By default ‘linear’
Examples
>>> interpolator = TrackInterpolation(track, method='linear') >>> results = interpolator() >>> interpolated_track = results['interpolated_track']
Methods
__init__(track[, method])Initialize the track interpolation algorithm.
- __call__()[source]¶
Execute interpolation on the track.
- Returns:
Dictionary containing: - ‘interpolated_track’: Track object with all frames filled - ‘original_frames’: Array of frame numbers that existed in original track - ‘interpolated_frames’: Array of frame numbers that were interpolated - ‘n_interpolated’: Number of frames that were interpolated
- Return type:
- Raises:
ValueError – If track has fewer than 2 points (cannot interpolate)