Dear all
I have four images (image_1, image_2, image_3, image_4) on screen and one of them is target. I want the trial to if one of the four images is selected (using mouse). And if the response selected is correct (corrAns), it gives score of 1 or score of 0.
…
for stimulus in [image_1, image_2, image_3, image_4]:
# check if the mouse is pressed within the current one:
if mouse.isPressedIn(stimulus):
# Yes, so store the reaction time in the data:
thisExp.addData('RT', t)
# check if the stimulus' image filename matches the correct answer:
if stimulus.image == eval(corrAns):
thisExp.addData('correct_responses', 1)
else:
thisExp.addData('correct_responses', 0)
# end the trial once done here:
continueRoutine = False
# stop any further checking:
break
…
It runs but the problem is …
It skips through some items in my ‘condition’ file. For example I have 47 items/trials in my condition file but it plays only 15 or so items.I have a feeling that it skips through the items.
Interestingly:
Note the same experiment works perfectly, if I remove the code component and set the mouse click to ‘end routine’. So I understand that there is something wrong with the code that is causing this problem. I need the code so I can register the correct response.
Can anybody figure out what the problem is conditions.xlsx (11.5 KB) Routine1,Recall, Mouse.psyexp (13.2 KB)
I had a similar problem. I believe that when you click one of the images your mouse is recording like 5-10 responses (depending on how long your “click” is). To avoid this, I added a short pause at the end of each trial (e.g. core.wait(0.3)). I’m not sure it is the right way to proceed though…
Hi Michael
I had a look at the data file (added couple of them).
1.No, it is not the same ones that is always missed.
2. I am not able comment on if it is the correct or incorrect trials that is missed. I have responded for all the trials that was shown (say 15 out of 46). In the data sheet I see that all the correct ones are given score of ‘1’ which I wanted and the ones those were skipped are given the score of ‘0’.
Hi Matscmitz, yes it worked with (core.wait(0.3) inserted after every frame. Thanks for that. But seems to create a delay before it takes the mouse click. So I reduced it to (core.wait(0.01) which seem to have no effect, but (core wait.1) does seem to get the task to run every trial as I wanted, but still the delay is annoying.
It would be useful to have a more detailed explanation of what you mean by trials being “skipped”. The data seems to show that all trials are completed in order, and each actually gets a reaction time.
In the absence of a fuller explanation, I guess what you mean is that some trials have very short reaction times (between 7 and 50 ms). So probably the trial runs, but a very early response is detected and so it might not appear to have run at all.
My guess is that the participant might not have released the mouse button before the next check for the mouse press is made. What probably needs to happen is that the next trial doesn’t run until a check has been made that the mouse button has actually been released. You’d need to explain the sequence of your trial and how such a check period could be incorporated.
Hi Michael
Thanks for the clarifications. I tried the following first
Inserted mouse.clickReset() in the code component right at the top of every frame section, so the code component looked like this…
…
mouse.clickReset()
for stimulus in [image_1, image_2, image_3, image_4]:
# check if the mouse is pressed within the current one:
if mouse.isPressedIn(stimulus):
# Yes, so store the reaction time in the data:
thisExp.addData('RT', t)
# check if the stimulus' image filename matches the correct answer:
if stimulus.image == eval(corrAns):
thisExp.addData('correct_responses', 1)
else:
thisExp.addData('correct_responses', 0)
# end the trial once done here:
continueRoutine = False
# stop any further checking:
break
…
That didn’t seem to help. So I feel your first explanation is more suitable.
**'My guess is that the participant might not have released the mouse **
**button before the next check for the mouse press is made. What probably **
**needs to happen is that the next trial doesn’t run until a check has **
**been made that the mouse button has actually been released. You’d need **
**to explain the sequence of your trial and how such a check period could ** be incorporated.’
The sequence of my trial is as follows, (I hope this is what you are expecting)
Four pictures appear on the screen from time 0 to infinite.
After a 250ms a sound is played,
After the sound is completed playing, the mouse response has to start. The trial will end if mouse was clicked on one of the pictures.
A click on one of the pictures completes the trials.
So, I would assume that the check for the mouse button release should be made just before a new trial and it has to be set as ‘release’ by default?
You could listen to mouse release instead of mouse down. So insert a separate routine in the end of the trial with a code component that contains this:
# Waits until no mouse buttons are pressed
while any(mouse.getPressed()):
pass
This will continue immediately upon mouse release. If you need to have everything on screen until the release, you could also insert this into your stimulus routine, but then have another variable (say response_recorded) which is False on trial start but True when a response has been recorded to this trial and then:
while response_recorded and any(mouse.getPressed()):
pass
I tried what Michael suggested and it worked like how I wanted. I did not try Lindeloev’s method, though it looks reasonable. Thanks you two for your time.