How to use ROI to get a right 'good' response
Hi all,
New with you since few days. Coming from Java world, Python is somehow tricky for me !
Here is my problem (question)
I have a sketchpad with 2 named fields ('Diff' and 'Ident') on which the participant clicks depending he have distinguished two identical or different Phonemes (here is the e and the è, in french)
I have an inline script running before "mouse response" to set the correct response (son1 and son2 are the 2 variables containing the name of the ogg files to be heard)
if (var.son1 == var.son2):
var.roi_correct_response = "Ident"
else:
var.roi_correct_response = "Diff"
And then the following inline script after "mouse response"
if var.roi_correct_response == var.cursor_roi:
var.correct = var.correct + 1
It gives TypeError: coercing to Unicode: need string or buffer, int found
Any clue ? And another question, is it the right thing to do to calculate the acc value, because I think I should work with correct_response and response, too, shouldn't I ? Or any simpliest solution !
Important remark : there is no feedback inside the loop
Thanks a lot
Comments
Hi,
If you get an error like that, you always get a 'stacktrace', which tells you exactly which line in your code the error comes from. So in the future make sure you include that in your question. In your case, I'm guessing this line is the culprit:
There are two things wrong with this:
First, this will crash if
var.correctis not a number (intorfloat), and in some cases it won't be. For examplevar.correctcan be 'undefined', i.e. astrobject. So that's probably what's happening here.Second, the consensus is that
var.correctis 1 after a correct response, and 0 after an incorrect response. Whereas you appear to want to use it as an incremental variable that keeps track of the total number of correct responses.The following would make more sense to me (in the process illustrating the concept of an
ifexpression):Cheers!
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Thank you Sebastian,
That's fine. I do not have the problem anymore (I was thinking that initializing correct in a previous inline script was OK but I understand your code)
Can you confirm that :
And another recurrent question I have : how can I restrict the click on only the ROI (ignoring a click on "nothing") ?
Thanks another time for your great work. It will help me (as a french teacher for foreign people wit phonetics complexity) and my wife ( as a Orthophonist)
Greetings Christophe
how can I restrict the click on only the ROI (ignoring a click on "nothing") ... was quite obvious using 'repeat cycle' with ''[cursor_roi] != 'Diff' and [cursor_roi] != 'Ident'' ..
That's right. The correct response refers to the mouse button, and not to the ROI.
Good to hear that you got things working!
Check out SigmundAI.eu for our OpenSesame AI assistant!
Thanks a lot! Going further how to have a full experience available for my Adults Students working on phonetics complexity with French !
Building dynamic content for table in loop block is very powerfull .. when understood !
I really like openSesame (usability, open to advanced programming, and availability of the team).
Thanks
This is the way I did
to initialize the counters
var.myAcc = None
var.totalCorrect = 0
var.totalNoTrials = 0
to calculate the needed info for feedback (var.cursor_roi contains the roi cliked on, and var.roi_correct_response contains the correct ROI) :
if var.roi_correct_response == var.cursor_roi:
var.totalCorrect += 1
else:
var.totalCorrect
if var.cursor_roi != '':
var.totalNoTrials += 1
var.myAcc = (float(var.totalCorrect)/var.totalNoTrials)*100
I do not know if this is the best choice ... At least it works !!!
@cleroux1998
Hey there.
I'm new to OS and have a similar problem. I have 9 ROI on my Sketchpad, of which one ist the target. I want the variable totalCorrect (as you defined it) count the correct responses what does not seem to work. Only if all 5 responses in my practice set are correct, the variable counts 1. If one is false it counts 0. Same with totalNoTrials. This is my inline script (run after mouse_response) I copied from here using your variables as well except correct_cursor_roi:
if var.correct_cursor_roi == var.cursor_roi:
var.totalCorrect += 1
else:
var.totalCorrect
if var.cursor_roi != '':
var.totalNoTrials += 1
I don't get any Error Messages with that.
I managed the counting problem now.
@cleroux1998
I too want nothing to happen if subjects miss the ROI, meaning my target and distractors. How did you manage that? I couldn’t figure it out through your comment.
Hi,
I think this part of Cleroux's response is relevant:
how can I restrict the click on only the ROI (ignoring a click on "nothing") ... was quite obvious using 'repeat cycle' with ''[cursor_roi] != 'Diff' and [cursor_roi] != 'Ident'' ..So, basically in the repeat_cycle field of the loop, specify conditions that will repeat the loops unless the response has been one of the buttons. Does that make sense?
Eudard
I tried to implement this solution but it is not really perfect for me. is there any way to restrict mouse clicks completely if not on predefined ROI?
Thanks a lot!
I don't know whether and how this would be possible. Can you maybe elaborate in how far this would be a problem?
Thanks,
Eduard