experanto.interpolators.TimeIntervalInterpolator

class TimeIntervalInterpolator(root_folder, cache_data=False, **kwargs)[source]

Bases: Interpolator

Interpolator 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.yml file under the labels key. Each label points to a .npy file 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 where start > end are treated as invalid and trigger a warning.

Parameters:
  • root_folder (str) – Path to the modality directory containing meta.yml and the .npy interval files referenced by its labels mapping.

  • cache_data (bool, default=False) – If True, loads all interval arrays into memory at init time.

  • **kwargs – Additional keyword arguments (ignored).

meta_labels

Mapping from label names to .npy filenames.

Type:

dict

Notes

  • Only time points within the valid interval (as defined by start_time and end_time in meta.yml) are considered; others are filtered out.

  • The interpolate method returns an array of shape (n_valid_times, n_labels) where out[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.

load_meta()

valid_times(times)

__init__(root_folder, cache_data=False, **kwargs)[source]
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.yml file in the folder to determine the modality type and instantiates the corresponding interpolator subclass.

Parameters:
  • root_folder (str) – Path to the modality directory.

  • cache_data (bool, default=False) – If True, loads all data into memory for faster access.

  • **kwargs – Additional arguments passed to the interpolator constructor.

Returns:

An instance of the appropriate interpolator subclass.

Return type:

Interpolator

Raises:

ValueError – If the modality type is not supported.

load_meta()
valid_times(times)