I use the Coder in Psychopy v1.90.3 to implement a simple tapping task.
During the task, participants are required to tap a key synchronous to a visual stimulus (60 trials; Inter-Stimulus-Interval:1.8 sec; stimulus-duration: 0.2 sec). I want to analyse asynchronies between stimulus-onset and tapping-onset afterwards.
So at the start of every trial I set a timer that corresponds to the trial duration (1.8 sec). Then I present the stimulus after 0.3 sec (because I also want to assess early responses, prior to stimulus onset, as well) and I flip the window after 0.2 sec, corresponding to stimulus-duration. During the entire trial duration, I want to collect the keyPress, thats why I implemented the getKeys() function in the while-loop that is true until the timer is 0. In my output I now see that the program won’t collect keypresses prior stimulus onset.
Has anyone an idea how I could recode my trial loop?
trial_clock = core.Clock()
timer = core.CountdownTimer()
for x in range(len(stimuli_per_block)): event.clearEvents() trial_clock.reset() timer.add(1.8) core.wait(.2) stimuli_per_block[x].draw() win.flip() stim_time = trial_clock.getTime() core.wait(.2) win.flip() while timer.getTime() > 0: for key in event.getKeys(): if key == 'space': tap_time=trial_clock.getTime() stim_tap_deviation = tap_time - stim_time '''