Hello,
I’m working with PsychoPy 1.90.2 Standalone in Builder mode on Windows 7 and have a newbie question regarding the assignment of responses across trials.
In my experiment (screenshot), each trial (lasting 1.5 s) includes 5 beep sounds, one of which has a higher pitch. Participants’ task is to press a key whenever this oddball occurs.
Simultaneously, a word is presented acoustically (0.5-1 s duration) with a random onset within each 1.5 s trial period. That is why I can’t make each beep a trial of its own.
My problem is now that if the oddball has a late onset in the trial, participants will respond during the following trial. In my current paradigm, this would erroneously be recorded as a miss during the first trial and a false positive during the second trial. Also, I cannot measure their response time here because the clock is set back to zero in each trial.
My question is therefore: How can I assign a response to a component in the preceding trial and how can I record the respective response time and response correctness?
My first idea would be to take the absolute time and substract the oddball onset from the following response onset. If the difference would be, say, less than 0.5 s, I would count it as correct. The clock functions in psychopy.core sound promising in this regard, but being a newbie I don’t know how to implement this in Builder.
Any help would be greatly appreciated. 
Best regards
Torge
Hi, here is an example of what you can do in Builder using a code component. This idea uses clocks that reset every time the oddball is shown, and they do not reset until the next oddball is shown. Set your wav file using the Builder as normal (in this example its called wavSound). Note, make sure you have a blank image stim or other component that runs longer than the sound i.e., 1.5 seconds because otherwise the trial will end and crash as the sounds are still being processed. Regardless, the trial ends after the presentation of the sounds:
In code component, you could add the following to relevant tabs:
####### Begin Experiment #######
beep = sound.Sound('A', secs=.1) # Your sound stim
beep.setVolume(1)
oddBallTimer = core.Clock() # The oddball clock
####### Begin routine #######
playTimes = [.2, .5, .8, 1.1, 1.4] # Times to present stim
tones = ['A','A','A','A','C'] # stim tones, where 'C' is oddball
playTimeCount = 0 # Counter for playing tones
shuffle(tones) # List of randomized tones - randomized every trial
beep.status = NOT_STARTED
wavSound.status = STARTED # wavSound is your acoustically presented word
####### Every Frame #######
keys = event.getKeys() # Get key presses
if t >= playTimes[playTimeCount] and not beep.status == STARTED: # Start tone
if tones[playTimeCount] == 'C': # If tone is oddball, reset clock
oddBallTimer.reset()
beep.setSound(tones[playTimeCount]) # set tone from tone list, indexed by playTimeCount
beep.play()
beep.status = STARTED
elif t >= playTimes[playTimeCount] + .1 and beep.status == STARTED: # Stop tone after .1 seconds
beep.stop()
beep.status = STOPPED
playTimeCount += 1
if playTimeCount == len(playTimes): # End trial after 5 consecutive tones
continueRoutine = False
if t >= 1 and wavSound.status == STARTED: # End wav file after 1 second - you will need to account for onset
wavSound.status = STOPPED
wavSound.stop()
# Register key presses
if 'escape' in keys:
core.quit()
elif 'space' in keys:
RT = oddBallTimer.getTime() # Get time in relation to oddball if 'space' is pressed
Note, you will have to add the RT to the datafile yourself, and it may not match the relevant trial if the participant was moved on to next trial:
thisExp.addData("OddBallRT", RT)
1 Like
Wow, thank you so much for your response! I really didn’t expect to get an exhaustive solution to the problem right away. It works like a charm. 
Best regards
Torge