pymovements.Experiment.from_dict#
- static Experiment.from_dict(dictionary: dict[str, Any]) Experiment [source]#
Create an Experiment instance from a dictionary.
- Parameters:
dictionary (dict[str, Any]) – A dictionary containing Experiment parameters.
Notes
The dictionary may contain nested dictionaries for ‘screen’ and ‘eyetracker’. These will be automatically converted into Screen and EyeTracker instances.
Examples
Passing a flat dictionary:
>>> experiment = Experiment.from_dict({ ... "screen_width_px": 1280, ... "screen_height_px": 1024, ... "screen_width_cm": 38.0, ... "screen_height_cm": 30.0, ... "distance_cm": 68.0, ... "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=None), eyetracker=EyeTracker(sampling_rate=1000.0, left=None, right=None, model=None, version=None, vendor=None, mount=None))
The same result using nested dictionaries for screen and eyetracker:
>>> experiment = Experiment.from_dict({ ... "screen": { ... "width_px": 1280, ... "height_px": 1024, ... "width_cm": 38.0, ... "height_cm": 30.0, ... "distance_cm": 68.0, ... "origin": "upper left" ... }, ... "eyetracker": { ... "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))
- Returns:
An initialized Experiment instance.
- Return type: