experanto.interpolators.SequenceInterpolator
- class SequenceInterpolator(root_folder, cache_data=False, keep_nans=False, interpolation_mode='nearest_neighbor', normalize=False, normalize_subtract_mean=False, normalize_std_threshold=None, **kwargs)[source]
Bases:
InterpolatorInterpolator for time series data.
Handles regularly-sampled time series stored as memory-mapped or NumPy arrays. Supports nearest-neighbor and linear interpolation modes.
- Parameters:
root_folder (str) – Path to the modality directory containing
data.memordata.npy.cache_data (bool, default=False) – If True, loads memory-mapped data into RAM for faster access.
keep_nans (bool, default=False) – If False and
interpolation_mode='linear', replaces NaN values with column means during interpolation. For'nearest_neighbor', NaNs are left unchanged.interpolation_mode (str, default='nearest_neighbor') – Interpolation method:
'nearest_neighbor'or'linear'.normalize (bool, default=False) – If True, normalizes data using stored mean/std statistics.
normalize_subtract_mean (bool, default=False) – If True, subtracts mean during normalization.
normalize_std_threshold (float, optional) – Minimum std threshold to prevent division by near-zero values.
**kwargs – Additional keyword arguments (ignored).
Notes
For linear interpolation, values are computed as:
\[y(t) = y_0 \cdot \frac{t_1 - t}{t_1 - t_0} + y_1 \cdot \frac{t - t_0}{t_1 - t_0},\]where \(t_0\) and \(t_1\) are the surrounding sample times.
Methods
__init__(root_folder[, cache_data, ...])close()create(root_folder[, cache_data])Factory method to create the appropriate interpolator for a modality.
interpolate(times[, return_valid])Map an array of time points to interpolated data values.
normalize_data(data)valid_times(times)- __init__(root_folder, cache_data=False, keep_nans=False, interpolation_mode='nearest_neighbor', normalize=False, normalize_subtract_mean=False, normalize_std_threshold=None, **kwargs)[source]
- interpolate(times, return_valid=False)[source]
Map an array of time points to interpolated data values.
- static create(root_folder, cache_data=False, **kwargs)
Factory method to create the appropriate interpolator for a modality.
Reads the
meta.ymlfile in the folder to determine the modality type and instantiates the corresponding interpolator subclass.- Parameters:
- Returns:
An instance of the appropriate interpolator subclass.
- Return type:
- Raises:
ValueError – If the modality type is not supported.
- load_meta()
- valid_times(times)