Dear Michael
Brilliant. Everything worked perfectly and task is ready to go. Thank you very much for that.
Am also trying to adapt this method to another task, which is similar to this. Here a prime of ‘play’ (a picture) appears and a click response on the picture only should start the trial. I tried to achieve this by adding this code
if mouse.isPressedIn(‘next.jpg’):
continueRoutine = TRUE
else:
continueRoutine = FALSE
break
This doesn’t seem to work. Nor does it throw any error. This needs first fixing. This is only minor though, the major issues follow.
Major prob 1:
Here, on a trial, the screen shows four pictures (ignore the two extra Simpsons at the edges). There is an audio stimulus heard at the background and the participant has to click on one of the pictures to register the response based on the audio stimulus. I got the task running (but only if I remove the code component I added to record the response). The problem started when I tried to ‘score’-I pretty much used the code you gave which worked brilliantly for previous task. Unlike ‘1’ or ‘0’, this time I wanted different way of recording: if the click was made in ‘corrAns’ score it as ‘2’ , if clicked in ‘clCorrAns’ give score of ‘1’, otherwise, give score of ‘0’.
I tried to achieve this by adding this code
for stimulus in [pos_1, pos_2, pos_3, pos_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(‘score’, 2)**
** elif stimulus.image == eval(clCorrAns):**
** thisExp.addData(‘score’, 1)**
** else:**
** thisExp.addData(‘score’, 0)**
** # end the trial once done here:**
** continueRoutine = False**
** # stop any further checking:**
** break**
The problem is, it displays the first trial, but when I click the mouse on one of responses it either throws up the error shown below or the program stops working.
File “C:\Users\ksengottuvel\Desktop\GJT\GJT_lastrun.py”, line 225, in
_ if mouse.isPressedIn(stimulus):_
_ File “C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy-1.82.01-py2.7.egg\psychopy\event.py”, line 548, in isPressedIn_
_ return any(wanted & pressed) and shape.contains(self)_
AttributeError: ‘unicode’ object has no attribute ‘contains’
Exception TypeError: “‘NoneType’ object is not callable” in <bound method Server.del of <pyolib.server.Server object at 0x049EA690>> ignored
I tried changing the setting in mouse component, but it didnt help. The part ‘AttributeError: ‘unicode’ object has no attribute ‘contains’’ seems to really irritate me.
This time around I do not want the computer to print the responses, so I removed that part from your previous code.
Major Prob 2:
I have not tried doing this but I am sure I need help from you on this. I have added another button at the top (talk.jpg) for every trial, a click on that should repeat the same trial again -ie., I do not want it to run through the whole loop of a trail, i.e.,I dont want it to show the play button and needing a mouse click. i.e., if the mouse is clicked in ‘talk.jpg’-rerun that particular trial again.
_Is it possible to achieve this by slightly hacking the code?- I also want the response sheet to record how many times talk button was clicked (if it was clicked).
I have added everything with this for you to figure out what my prob exactly is. I am using v 1.82.01, as I though it was much better than newer ones. conditions.xlsx (8.9 KB)
GJT_lastrun.py (16.4 KB)
![](https://us1.discourse-cdn.com/flex020/uploads/psychopy/original/1X/186d058b90313f6413dc0a5b953889d3c6a218fd.jpg)
GJT.psyexp (21.5 KB)
![](https://us1.discourse-cdn.com/flex020/uploads/psychopy/original/1X/b652b4725c9660069ab28bf42e916ebfbc460e8f.png)
![](https://us1.discourse-cdn.com/flex020/uploads/psychopy/original/1X/cc910248d1710c975c5094dcf7fa7ace524d489b.png)
![](https://us1.discourse-cdn.com/flex020/uploads/psychopy/original/1X/ce66cb30dc80f39c7683bfa6d0300c0efbbccb02.png)
![](https://us1.discourse-cdn.com/flex020/uploads/psychopy/original/1X/630f9a243f747c6708c479828a6dcbd3f9ee93b0.jpg)
![](https://us1.discourse-cdn.com/flex020/uploads/psychopy/original/1X/dbbf2a74c4f0f2ae7d91f29576f47474f9e18ba5.png)
Looking forward to hearing from you. I have made good progress with your help. _
It would be great if you could suggest me a way to do it. You and the community deserve an applauding in my acknowledgement section .