from with display block
I intended to represent 3 stimuli at the same time in each trial on the screen. In the next step, we will ask from participant to choose between one of two options and select the most relevant words to the target. In each trial, stimuli display on the screen for 6 sec and within this 6 sec participant has to answer the question and then we go to next trial. The code is as below: ( I removed not important lines)
## display each stimuli
def disply_block(stim1,stim2,stim3):
canvas = expyriment.stimuli.Canvas(size=(600, 600))
canvas.present()
fixcross.present()
exp.clock.wait(500)
stim1.present(update=False)
stim2.present(clear=False, update=False)
stim3.present(clear=False)
exp.clock.wait(6000)
button, rt = exp.keyboard.wait(keys=response_keys,duration=6000)_
block = design.Block()
## initialize experiment
exp = expyriment.design.Experiment(name="task")
expyriment.control.initialize(exp)
# Define and preload standard stimuli
blank = stimuli.BlankScreen()
blank.preload()
# left and right arrow keys for responses
response_keys = [misc.constants.K_LEFT, misc.constants.K_RIGHT]
# display triangle stimulus for block cf
block_one= expyriment.design.Block(name="block1")
#trial 1
trial1, stim1,stim2,stim3=draw_stimuli(trials['Trial0'][0],trials['Trial0'][1],trials['Trial0'][2])
trial2, stim4,stim5,stim6=draw_stimuli(trials['Trial1'][0],trials['Trial2'][1],trials['Trial2'][2])
add_trial_block(trial1,trial2)
expyriment.control.start()
#
disply_block(stim1,stim2,stim3)
disply_block(stim3,stim4,stim5)
blank_page(10000)
expyriment.control.end()
I have few question regarding this code and I would appreciate if you provide me a solution: it seems each trial display for 12 sec instead of 6 sec. It seems it is relevant to this part of code:
exp.clock.wait(6000)
button, rt = exp.keyboard.wait(keys=response_keys,duration=6000)
Question1: how can I give the time to the participant to answer the question only within that 6 sec that stimuli display on the screen?
Question 2: how can record exact response time?
Question2: how can I be sure that only first attempt of the participant to answer the question will be recorded?
Question3: how can I be sure that even if the participant answer after 6 sec, no response will be recorded anymore?
Question4: as my participants are French speaker, how can I initialize experiment ( cut down timer/ read) in French?
Your help is highly appreciated in advance.
Comments
Hi,
exp.clock.wait(6000)
If you want to show the stimulus always 6000ms, irrespective of whether the participant answered earlier, just wait the remaining time after the
exp.keyboard.wait
line:exp.clock.wait(6000-rt)
rt
not be exact?I hope that helped. Let me know if you have any further questions.
Hi Flad, thank you very much for your informative reply. After I changed it as below:
I got this error:
I try to understand what this error means.
It's always a pleasure to exchange with you. Thank you very much and I appreciate your comments.
Oh sorry, I forgot the case that the participant does not respond within 6000ms. In this case the return value is
None, None
.So the correct code should be:
Thank you very much. The problem is fully solved.
To explain the error message a bit: It means that you were trying to use the
-
operator on two things that were of different types. The6000
is an integer, while thert
apparently wasNone
, which is an instance of theNoneType
. Python does not know how to use the-
operator on these two items (as subtraction is only defined on two numerical types), and it hence threw the error you say. But with the code in my last reply this should not happen anymore, asexp.clock.wait(6000-rt)
will only be called when rt is notNone
(which it only is when no button has been pressed; if a button has been pressed it will be an integer, that can be subtracted from the 6000ms without an error). I hope this explanation clarifies things a bit more.Thank you. Your explanations are very clear to me. I appreciate your favor to explain it fully.