Howdy, Stranger!

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

Supported by

Creating Variables dependent on other variables

edited September 2017 in OpenSesame

Hello everyone :smile:

I am currently designing an eye-tracking experiment for emotion recognition with OpenSesame 3.1.9b1.
To collect the answers, I used the built-in form for multiple choice answers.
According to my what I read on here, there is no way to indicate the correct response in the forms, right?
And also, there is no easy way to let the 'form_response' give out numbers instead of the respective strings, right?

I am very new to programming, and just started learning python to accomplish what I want.
So I tried to define a new variable with an inline_script-item after the form and before the logger.
I managed to create the variable, and it also prints some values to the log-file.
I want the variable to print 1 if "correct_response" and "response" are the same (strings) and 0 if otherwise.

(The definition for the correct response was done in the loop table with the variable correct_response, in case you wondered.)

But:
While testing, it only prints a 0 to the file, with an occasional 1 now and then.
The 1, however, does not turn up when the answer was right, but seems to appear randomly, also with wrong answers.
So I suppose there is something wrong with my code, or the code cannot access the variables in the way I want it to...

The code I used is the following:
def emotion_recognized (): print self.get('emotion_recognized') emotion_recognized = () if var.get('response') == var.get('correct_response'): emotion_recognized = 1 else: emotion_recognized = 0 var.set('emotion_recognized', emotion_recognized)

I would be really happy if anyone could help me resolve this, somehow!
Have a good start into the new week.

Best wishes from Switzerland and thank you very much in advance
Tim

Comments

  • Nevermind.
    When I put the code in the run, not the prepare window of the inline_script, it seems to work just fine now!

    But another question came up:
    How can I sum the values in the variable emotion_recognized to a variable called sum_correct?
    I get an iteration error when I try to do so. It would be great to just do the same procedure, the correct response Item of the feedback does...

    Any help appreciated!
    Thanks and best wishes
    Tim

  • Hi Tim,

    Initialize sum_correct somewhere in the beginning of your experiment (or your block). Then every time you want to update it you just add emotion_recognized to it: sum_correct += emotion_recognized. If you want to use them in the feedback item, you should use var.sum_correct instead.

    Good luck,

    Eduard

    Buy Me A Coffee

  • edited September 2017

    Dear Eduard

    Thank you so much for your answer!
    If I put the var.sum_correct += emotion_recognized it simply gives the same values as in emotion_recognized, not the sum of correct trials.
    I inserted the code in the Script right after the Multiple Choice Form that gives the value to emotion_recognized.
    The sum_correct is initialized at the beginning of the experiment (right after the welcome page).

    Where's my mistake? :/
    Best wishes
    Tim

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