Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support screen and eyetracker being passed as dict in Experiment.__init__() #991

Open
SiQube opened this issue Mar 6, 2025 · 4 comments
Labels
enhancement New feature or request good first issue Good for newcomers nonessential nice to have

Comments

@SiQube
Copy link
Member

SiQube commented Mar 6, 2025

Description of the problem

It would be nice if the screen and eyetracker arguments in the experiment init could be overloaded to also support dictionaries.

Let's take this dict as an example:

dict_definition = {
    'screen': {
        'height_cm': 30.2,
        'height_px': 1024,
        'width_cm': 38.2,
        'width_px': 1280,
        'distance_cm': 60,
        'origin': 'center',
    },
    'eyetracker': {
        'sampling_rate': 2000,
        'model': 'EyeLink II',
        'vendor': EyeLink',
    },
}

Trying to initialize a DatasetDefinition with DatasetDefinition(**dict_definition) wont' work as screen and eyetracker are just dicts and not the initialized class objects.

#914 implemented a workaround in its DatsetDefinition.from_yaml() method but it would be more elegant to solve this in the Experiment.__init__() itself.

Description of a solution

The screen and eyetracker arguments in Experiment.__init__() should be overloaded to also support dictionaries.
If a dictionary is passed, a Screen or EyeTracker object should be initialized on the fly.

@SiQube SiQube added the enhancement New feature or request label Mar 6, 2025
@dkrako
Copy link
Contributor

dkrako commented Mar 6, 2025

Isn't the experiment key in the dictionary redundant?

@dkrako
Copy link
Contributor

dkrako commented Mar 6, 2025

If this is implemented, this has to be implemented for Screen and EyeTracker as well

EDIT: although probably self.screen = Screen(**kwargs['screen']) could work as well in the Experiment.__init__()

@dkrako dkrako changed the title for a dataset definition parse experiment given as dictionary for a dataset definition pass experiment as dictionary Mar 6, 2025
@SiQube
Copy link
Member Author

SiQube commented Mar 6, 2025

Isn't the experiment key in the dictionary redundant?

yes -- sorry -- this was just my "copy/paste" from a nested dictionary dataset definition.

@SiQube
Copy link
Member Author

SiQube commented Mar 7, 2025

this would also be in line with #914 because in #914 we write each experiment/screen/eyetracker etc. as a dictionary/yaml file. hence it would be great to have this kind of parsing

@dkrako dkrako changed the title for a dataset definition pass experiment as dictionary pass screen and eyetracker as dicts to experiment init Mar 7, 2025
@dkrako dkrako added good first issue Good for newcomers nonessential nice to have labels Mar 7, 2025
@dkrako dkrako changed the title pass screen and eyetracker as dicts to experiment init support screen and eyetracker being passed as dict in Experiment.__init__() Mar 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers nonessential nice to have
Projects
None yet
Development

No branches or pull requests

2 participants