experanto.interpolators.TimeIntervalInterpolator
- class TimeIntervalInterpolator(root_folder, cache_data=False, **kwargs)[source]
Bases:
InterpolatorInterpolator for labeled time intervals.
Maps time points to boolean membership in labeled intervals. Given a set of time points, returns a boolean array indicating whether each point falls within any interval for each label.
Labels and their intervals are defined in the
meta.ymlfile under thelabelskey. Each label points to a.npyfile containing an array of shape(n, 2), where each row is a[start, end)half-open time interval. Typical labels include'train','validation','test','saccade','gaze', or'target'.The half-open convention means a timestamp t is considered inside an interval when
start <= t < end. Intervals wherestart > endare treated as invalid and trigger a warning.- Parameters:
Notes
Only time points within the valid interval (as defined by
start_timeandend_timeinmeta.yml) are considered; others are filtered out.The
interpolatemethod returns an array of shape(n_valid_times, n_labels)whereout[i, j]is True if the i-th valid time falls within any interval for the j-th label.
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.
valid_times(times)- interpolate(times, return_valid=False)[source]
Map an array of time points to interpolated data values.
- close()
- 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)