Experiment#
- class pymovements.Experiment(screen_width_px: int | None = None, screen_height_px: int | None = None, screen_width_cm: float | None = None, screen_height_cm: float | None = None, distance_cm: float | None = None, origin: str | None = None, sampling_rate: float | None = None, *, screen: Screen | None = None, eyetracker: EyeTracker | None = None)[source]#
Experiment class for holding experiment properties.
- Parameters:
screen_width_px (int | None) – Screen width in pixels. (default: None)
screen_height_px (int | None) – Screen height in pixels. (default: None)
screen_width_cm (float | None) – Screen width in centimeters. (default: None)
screen_height_cm (float | None) – Screen height in centimeters. (default: None)
distance_cm (float | None) – Eye-to-screen distance in centimeters. If None, a distance_column must be provided in the DatasetDefinition or Gaze, which contains the eye-to-screen distance for each sample in millimeters. (default: None)
origin (str | None) – Specifies the screen location of the origin of the pixel coordinate system. (default: None)
sampling_rate (float | None) – Sampling rate in Hz. (default: None)
screen (Screen | None) – Scree object for experiment. Mutually exclusive with explicit screen arguments. (default: None)
eyetracker (EyeTracker | None) – EyeTracker object for experiment. Mutually exclusive with sampling_rate. (default: None)
Examples
>>> experiment = Experiment( ... screen_width_px=1280, ... screen_height_px=1024, ... screen_width_cm=38.0, ... screen_height_cm=30.0, ... distance_cm=68.0, ... origin='upper left', ... sampling_rate=1000.0, ... ) >>> print(experiment) Experiment(screen=Screen(width_px=1280, height_px=1024, width_cm=38.0, height_cm=30.0, distance_cm=68.0, origin='upper left'), eyetracker=EyeTracker(sampling_rate=1000.0, left=None, right=None, model=None, version=None, vendor=None, mount=None))
We can also access the screen boundaries in degrees of visual angle via the
Screen
object. This only works if the distance_cm attribute is specified.>>> experiment.screen.x_min_dva -15.59... >>> experiment.screen.x_max_dva 15.59... >>> experiment.screen.y_min_dva -12.42... >>> experiment.screen.y_max_dva 12.42...
Methods
__init__
([screen_width_px, ...])from_dict
(dictionary)Create an Experiment instance from a dictionary.
pos2vel
(arr[, method])Compute velocity time series from 2-dimensional position time series.
to_dict
(*[, exclude_none])Convert the experiment instance into a dictionary.
to_yaml
(path, *[, exclude_none])Save an experiment to a YAML file.
Attributes
sampling_rate
Get sampling rate of experiment.