We expect the reaction time might be slightly longer when an image of a dog is shown but the sound of a cat is played, so we will record the participant's reaction time. This picture is irrelevant to what key they need to press, however it will try to distract them a little. The participant will be instructed to press the left key on the keyboard if they hear a cat sound, and the right key on the keyboard if they hear a dog sound.Īt the same time the experiment will show the participant a picture of either a dog or cat. The participant will hear a sounds play of either a cat or dog. In the experiment we will test whether image stimuli can distract audio perception. To understand how you can further implement audio files into your experiment, we will create an experiment using audio files. Experiment example using audio files and image files Now Psychopy thinks you have 6 different audio files that each will play after the participant presses a key on the keyboard. #Shuffle psychopy updateThen update your stimuli object, by timing it with your repetition object, REP: Then create your stimuli object containing your audio files, like we did before: If you have two sound files, but you want them to be played more than once during the experiment you can add the following code.įirst create a variable that contains the amount of times you want each sound wave to be repeated. Then before you run the loop, specify that you want to randomize the stimuli, using the random.shuffle() function. If you want to randomize the order in which the audio files are played, import the module for randomization: Notice that the sound waves play in the order that you specified them to be in when you created the "stimuli" object. #Shuffle psychopy codeIf you run your code now, it should play the two audio files each one after you press a key on the keyboard. We also specify that we want the next sound file to be played after we have pressed a key on the keyboard, using the event.waitKeys() and the win.flip() functions, that you should be familiar with by now. Inside the loop we use the sound.Sound() function to specify that we are dealing with sound files. Then we create a loop to loop through our stimuli and play them. Make sure the sound waves are located in the folder that your code is saved in. I have used three sound waves, one that makes dog noises, another that makes cat noises and a third that makes chicken noises. Then we create and object for our sound waves. Next we create a window, just like we did for the visual stimuli. First we import the sound module and the other necessary modules.įrom psychopy import sound, visual, event Playing audio files in an experiment window is simple. Note: remember to cut your sound files so they are in the right time length you need for your experiment. There is a website here that can convert other types of audio files into the. #Shuffle psychopy how toWe will specifically be focusing on how to add. This section focuses on implementing audio files into your Psychopy2 script. For some experiments you will need to play an audio file for the participant.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |