experanto.interpolators.ScreenInterpolator
- class ScreenInterpolator(root_folder, cache_data=False, rescale=False, rescale_size=None, normalize=False, use_stimuli_names=False, **kwargs)[source]
Bases:
InterpolatorInterpolator for visual stimuli (images and videos).
Handles frame-based visual data organized as trials. Each trial can be a single image, a video sequence, or a blank screen. Frames are indexed by timestamp and retrieved on demand.
- Parameters:
root_folder (str) – Path to the screen modality directory containing
timestamps.npy,data/folder with trial files, andmeta/folder with metadata.cache_data (bool, default=False) – If True, loads all trial data into memory for faster access.
rescale (bool, default=False) – If True, rescales frames to
rescale_size.rescale_size (tuple of int, optional) – Target size
(height, width)for rescaling. If None, uses the native image size from metadata.normalize (bool, default=False) – If True, normalizes frames using stored mean/std statistics.
use_stimuli_names (bool, default=False) – If True, uses
stimulus_namefrom metadata to locate data files instead of trial keys.**kwargs – Additional keyword arguments (ignored).
- timestamps
Array of frame timestamps.
- Type:
- trials
List of trial objects containing frame data.
- Type:
list of ScreenTrial
See also
ImageTrialSingle-frame stimuli.
VideoTrialMulti-frame video stimuli.
BlankTrialBlank/gray screen stimuli.
Methods
__init__(root_folder[, cache_data, rescale, ...])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)rescale_frame(frame)Rescale frame to the configured image size.
valid_times(times)- __init__(root_folder, cache_data=False, rescale=False, rescale_size=None, normalize=False, use_stimuli_names=False, **kwargs)[source]
- interpolate(times, return_valid=False)[source]
Map an array of time points to interpolated data values.
- rescale_frame(frame)[source]
Rescale frame to the configured image size.
- Parameters:
frame (np.ndarray) – Input image frame.
- Returns:
Rescaled image as float32.
- Return type:
np.ndarray
- 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)