experanto.interpolators.ScreenInterpolator

class ScreenInterpolator(root_folder, cache_data=False, rescale=False, rescale_size=None, normalize=False, use_stimuli_names=False, **kwargs)[source]

Bases: Interpolator

Interpolator 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, and meta/ 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_name from metadata to locate data files instead of trial keys.

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

timestamps

Array of frame timestamps.

Type:

numpy.ndarray

trials

List of trial objects containing frame data.

Type:

list of ScreenTrial

See also

ImageTrial

Single-frame stimuli.

VideoTrial

Multi-frame video stimuli.

BlankTrial

Blank/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.

load_meta()

normalize_data(data)

normalize_init()

read_combined_meta()

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]
normalize_init()[source]
normalize_data(data)[source]
read_combined_meta()[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

close()[source]
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)