Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

How to use ROI to get a right 'good' response

edited April 2018 in OpenSesame

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:

    var.correct = var.correct + 1
    

    There are two things wrong with this:

    First, this will crash if var.correct is not a number (int or float), and in some cases it won't be. For example var.correct can be 'undefined', i.e. a str object. So that's probably what's happening here.

    Second, the consensus is that var.correct is 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 if expression):

    var.correct = 1 if var.roi_correct_response == var.cursor_roi else 0
    

    Cheers!
    Sebastiaan

    Buy Me A Coffee

  • 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 :

    • we can not directly use the ROI in the mouse response definition (saying that a correct response is a name of a field in the linked sketchpad)
      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'' ..

  • we can not directly use the ROI in the mouse response definition (saying that a correct response is a name of a field in the linked sketchpad)

    That's right. The correct response refers to the mouse button, and not to the ROI.

    Good to hear that you got things working!

    Buy Me A Coffee

  • 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

    Buy Me A Coffee

  • 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

    Buy Me A Coffee

Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu http://45.77.173.118/ Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games