This experiment is designed to identify the "odd one out" among a set of stimuli. It is implemented using PsychoPy and translated into JavaScript for use in online experiments via PsychoJS.
- odd_one_out_experiment.js: Main JavaScript file generated by PsychoPy Builder.
- odd_one_out_experiment.js: Main Python file generated by PsychoPy Builder.
- odd_one_out_experiment.psyexp: PsychoPy Builder project.
- index.html: HTML file to run the experiment in a browser. Also generated automatically by the PsychoPy builder.
- clean_datafile.py: This file should be used to clean the datafile as generated by the PsychoPy builder or when hosted online.
- data/: Output folder for local use. Online data will be collected through Pavlovia.
- datasets/: Folder containing a .csv-file with all possible triplet combinations. The experiment uses a random sample from this dataset.
- informed_consent/: Folder containing the informed consent image, KUL logo image, and a .doc file for text storage/adjustment.
- instructions/: folder containing an image of an example trial.
- lib/: Directory containing PsychoJS library files.
- stimuli/: Directory containing all stimuli.
- Server Setup: Ensure you have a web server set up, like Pavlovia, to host the experiment files. It can also be done locally using the PsychoPy builder.
- Create a standalone root folder and put all files and directories here. Make sure there are no .git directories present here or in the parent folders.
- Make sure to include any images or datasets you want to use with your project. You can include these in the "Additional Resources" using the PsychoPy Builder (Settings > Online tab > Additional Resources. Include files by pressing + button)
- Using the 'Sync with web project' button in the PsychoPy builder you can log on to your Pavlovia account and create a repository. Once you are happy with your adjustments, you can push the complete directory for use in Pavlovia.
- Alternatively, you can click 'run the study in PsychoJS on a local browser' to run the experiment locally in your browser.
- It should also be able to run with Python using the regular PsychoPy execution button. This has not been tested well yet though.
The experiment includes several adjustable parameters which can be modified to suit different experimental needs:
- nPractice: The number of practice trials to be conducted before the main experiment begins. This helps participants familiarize themselves with the experiment format. The default value is 5.
- nMain: The number of main trials to be conducted in the experiment. This represents the core of the experiment where actual data is collected. The default value is 50.
- current_trial_type: A variable used to store the type of the current trial. It helps in categorizing the trials for data analysis. For example, it could be "practice" or "main".
- current_event: A variable used to store the current event happening in the experiment. This is useful for detailed data logging and understanding participant behavior. For example, it could be "loading" or "click_response".
In the routine "start" you can find the first two parameters. The other ones are in the code blocks of each routine.
The code includes several key custom functions that handle specific tasks within the experiment:
This function logs detailed information about each trial, including the trial type, event, reaction time, and time elapsed.
Parameters:
- trial_type: The type of the current trial (e.g., "practice" or "main").
- event: The current event happening in the trial (e.g., "loading", "click_response").
- rt: Reaction time, measured in seconds.
- time_elapsed: Time elapsed since the start of the experiment, measured in seconds.
- index_count: The current trial index.
This function checks if the mouse is hovering over a specific stimulus. It is used to detect mouse interactions with stimuli.
Parameters:
- stim: The stimulus object to check.
- mouse: The mouse object.
This function logs the response when the mouse clicks on a stimulus. It records details such as reaction time and the stimulus clicked.
Parameters:
- mouseObject: The mouse object used to detect clicks.
- trial_type: The type of the current trial.
- trial_num: The current trial number.
- time_elapsed: Time elapsed since the start of the experiment, measured in seconds.
- trial_index: The current trial index.
The informed consent is created manually by creating an image and displaying it during the start of the experiment. This is because the PsychoPy builder cannot handle formatted text in a text component. One way to create an image is to adjust and copy the text in the .doc file and paste it on a grey background using a program like Microsoft Paint. Please also include a KU Leuven logo. Then export it to either .png or .jpg files.
- Informed consent: Displays the informed consent form. Participant can accept by pressing the space bar, or exit the experiment using the escape key.
- Welcome Screen: Displays an introduction to the experiment and waits for the participant to press the spacebar to continue.
- Example Trial: Shows an example of the task, instructing the participant on how to select the "odd one out".
- Practice Trials: Provides a set of practice trials to familiarize the participant with the task.
- Main Experiment: Conducts the main set of trials where participants perform the actual task.
- Exit Screen: Thanks the participants for their time and concludes the experiment.
When regenerating the JavaScript file from the PsychoPy Builder, it is essential to manually remove the line "var counter" (line 266) which the Builder automatically inserts. Not removing this line will cause double declaration errors in the experiment.
The experiment logs various data points including trial type, events, reaction times, and mouse interactions. To make the data suitable for analysis, please clean the file first using the clean_datafile.py file. Since the datafile is generated using the PsychoPy Builder, there are some built-in datapoints that are redundant and hard to bypass. Cleaning the file will get rid of this. Make sure to put your datafile in a "data/" folder in the same root directory as the clean_datafile.py file. You can then run the script.
For more detailed information on how the experiment code works and to customize it further, refer to the full code and PsychoPy/PsychoJS documentation.