Sending out a marker on key-press
in Expyriment
Hi!
I have the following snippet of code:
experiment.clock.reset_stopwatch()
key, rt = experiment.keyboard.wait(keys=[left_resp,
right_resp],
duration=duration_stimulus)
experiment.clock.wait(duration_stimulus - interval_tone - experiment.clock.stopwatch_time)
What I want is to send out a marker, at the time that a response (keypress) is made. However, the duration of the stimulus is fixed (1000ms), so sending a marker after the keyboard.wait function is not possible! Do you have an idea how to do this?
Comments
I think the easiest way to do this is to simply reduce your waiting time for the response by 1 or 2 ms:
experiment.clock.reset_stopwatch() key, rt = experiment.keyboard.wait(keys=[left_resp, right_resp], duration=duration_stimulus - 2) marker.send(1) experiment.clock.wait(duration_stimulus - experiment.clock.stopwatch_time)If this is not an option, you could also create your own wait loop that uses the keyboard check method continuously:
rt = None experiment.clock.reset_stopwatch() while experiment.clock.stopwatch_time < duration_stimulus: key = experiment.keyboard.check(keys=[left_resp, right_resp]) if rt is None and key is not None: rt = experiment.clock.stopwatch_timeHi,
Thanks, eventually it worked out even without the "duration_stimulus - 2". It sends a marker on key-press automatically. The following is the code now?
experiment.clock.reset_stopwatch() key, rt = experiment.keyboard.wait(keys=[left_resp, right_resp], duration=duration_stimulus) if key is not None: marker.send(36, duration=5) # Key press marker