

1 The trial routine of the emotion-word Stroop experiment. As such, our trial will take (500 + 1500 = ) 2000 milliseconds this is sometimes called the inter- trial interval (ITI), i.e., the time from the onset of one trial to the onset of the next trial.Figure 1 shows how this routine would have looked like in the Builder view.įig. Unlike our Builder experiment, let’s only present the stimulus for a fixed amount of time, let’s say 500 milliseconds, which is followed by a fixation cross (a simple “+” sign) for 1500 milliseconds. Like we did in the Builder experiment, let our trial routine include the emotion-word stimulus and a subsequent fixation target. But first, let’s discuss how we want to structure our trial. There are, however, two other and more precise methods, which we’ll call clock-based timing and frame-based timing.
#PSYCHOPY TEXTSTIM HOW TO#
So far, we only showed you how to use the wait function to control stimulus duration. This is often especially important for perception and psychophysics studies or neuroimaging studies in which you track stimulus processing at high temporal resolution (e.g., EEG/MEG and eyetracking studies). Often, you’d like to make sure your trials/stimuli are presented for a specific duration. This also provides us with a nice opportunity to talk about duration and timing again!

Check the previous tutorial if you forgot how to do this! Timing revisited #Īlright, now it’s time for the most important part of our experiments: the trial loop! Just like the color-word Stroop experiment we implemented in the Builder, we’d like to create a set of trials in our emotion-word Stroop experiment. Using the Keyboard class, make sure the experiment only advances when the participant presses the enter key. To do so, you’d need a TextStim which would need to be initialized as follows: Now, suppose you would like to welcome my participant by showing a short welcome message - “Welcome to this experiment!”. So, let’s recap: to initialize a component in the Coder interface, we need to (1) import the corresponding class and (2) initialize it with a Window object (in case of visual components) and optionally other arguments that modify the component’s behavior or display. Importantly, all visual stimulus classes (like TextStim, but not Sound) additionally need one (mandatory) argument: a Window object! This allows to TextStim to interact with the window. We won’t discuss all parameters from every component we discuss in this tutorial you can find all parameters and what they mean in the PsychoPy documentation! For example, to set the font of a text stim to Calibri and the text color to blue, initialize a TextStim object with font='Calibri' and color=(-1, -1, 1).

For example, the color and font properties from text components in the Builder are also available in the Coder interface as arguments (and attributes) of the corresponding component class.

Moreover, each component has largely the same properties in the Builder as in the Coder. For example, to add a text component, you can use the TextStim class from the psychopy.visual module and to add a sound component, you can use the Sound component from the psychopy.sound module.īasically, every component from the Builder has an equivalent in the psychopy package. In the coder, however, these components are implemented in different classes from the psychopy package. Like in the Builder, components are the “bread and butter” in the Coder interface as well. # END BODY OF EXPERIMENT # Finish experiment by closing window and quitting win. " ) # Initialize a fullscreen window with my monitor (HD format) size # and my monitor specification called "samsung" from the monitor center win = Window ( size = ( 1920, 1080 ), fullscr = False, monitor = 'samsung' ) # Also initialize a mouse, for later # We'll set it to invisible for now mouse = Mouse ( visible = False ) # Initialize a (global) clock clock = Clock () # Initialize Keyboard kb = Keyboard () # START BODY OF EXPERIMENT # This is where we'll add stuff from the second # Coder tutorial. From psychopy.gui import DlgFromDict from psychopy.visual import Window from re import Clock, quit, wait from psychopy.event import Mouse from import Keyboard # DIALOG BOX ROUTINE # exp_info =.
