Howdy, Stranger!

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

Supported by

Text input response variable

edited October 2018 in OpenSesame

Hey all!

I am trying to develop a standard version of operation span task for my classroom practical. Currently, I have managed to develop a crude form right now. The number of letters presented varies from 3-7.
I am using custom form to take inputs on recall phase of letters presented and I am also using custom forms to present mathematical problem.
The following code describes the procedure of presenting letters on the screen

import random
import string

        letters = list(string.ascii_uppercase)

        var.isi = 495

        var.letter_dur = 495

        stim = random.sample(letters, var.length)

        letter_canvas_list = []

        letter_canvas = []
        for i, stim in enumerate(stim):
            letter_canvas = canvas()
            letter_canvas.text(stim)
            letter_canvas_list.append(letter_canvas)

        blank_canvas = canvas()

This code describes the presentation of math problem which precedes the recall phase

n2 = random.randint(0,9)
n3 = random.randint(0,9)

n4 = (n1*n2) + n3

r = [n1,n2,n3,n4]

form1 = Form(
    cols=[1,1], rows=[1,2,1],
    margins=(50,100,50,100), spacing=25
)

labelTitle = Label(text=u'Question')
labelQuestion = Label(
    text=u'Is this correct ({}*{})+{}={}?'.format(*r), center = False

)

buttonYes = Button(text=u'Yes')
buttonNo = Button(text=u'No')
form1.set_widget(labelTitle, (0,0), colspan=2)
form1.set_widget(labelQuestion, (0,1), colspan=2)
form1.set_widget(buttonYes, (0,2))
form1.set_widget(buttonNo, (1,2))

This code describes creating a form with input text option to take response in the recall phase for letters presented earlier.

form2 = Form(
    cols=[1,1, 1], rows=[1,1],
    margins=(50,100,50,100), spacing=25
)


button_ok = Button(text=u'Ok')
input_first = TextInput(stub=u'1st', var=u'first_letter')
input_second = TextInput(stub=u'2nd', var=u'second_letter')
input_third = TextInput(stub=u'3rd', var=u'third_letter')

form2.set_widget(input_first, (0,0))
form2.set_widget(input_second, (1,0))
form2.set_widget(input_third, (2,0))
form2.set_widget(button_ok, (1,1), colspan=2)

input = [input_first, input_second, input_third]

Now coming to the problem I am facing I am not able to understand what variable from the input text form just mentioned above stores the responses from the subject. Assuming that it is input_first, input_second, input_third variable I coded the following:

for i in range(len(input)): 
    if input[i]==letter_canvas_list[i]:
        var.cor = 1
    else:
        var.cor = 0

The above code runs through letter_canvas_list and input list and compare if same item is placed on the same index position. The problem I am facing is two fold:

  1. Is this the correct way?
  2. I am getting an empty log file with no variables in it

I would be grateful if anyone could help me in this.

Thanks
Vatsal

PS: @sebastiaan can we simulate an experiment before running it. Can we do that using debug window? I tried running canvas commands in the debug window but opensesame kept crashing.

Comments

  • Hi,

    Is this the correct way?

    Not quite. Don't use input_<number> as variable, but the string you assigned to var, so in your case first_letter, etc.

    I am getting an empty log file with no variables in it

    Completely empty? Then you probably don't have a logger item. In your experiment, your logger is not in side the sequence, but comes after. I don't think this is what you intended. Maybe put it inside the sequence? Alternatively, you can also do it in an inline_script via. var.log_vars()

    Eduard

    Buy Me A Coffee

  • edited October 2018

    Hey @eduard

    Thanks for your reply. Yes indeed I had noticed this input mistake but did not updated it on the forum, my fault.

    I have now made few changes in the python inline script. For collecting responses I have created 7 forms which are executed when the length set in the experimental loop matches a specific value. Thus, for length 4 I have a form with 4 text input boxes which is executed when var.length == 4

    Now that I know that the text input response is store in var variable I have also created a separate variable called text what concatenates all the vars in a given text input forms. For example:

    form3 = Form( cols=[1,1,1,1], rows=[1,1,1], margins=(50,100,50,100), spacing=25 )

    button_ok = Button(text=u'Ok')
    input_first = TextInput(stub=u'1st', var=u'first_letter')
    input_second = TextInput(stub=u'2nd', var=u'second_letter')
    input_third = TextInput(stub=u'3rd', var=u'third_letter')

    form3.set_widget(input_first, (0,0))
    form3.set_widget(input_second, (1,0))
    form3.set_widget(input_third, (2,0))
    form3.set_widget(button_ok, (0,2), colspan=2)

    concatenating response if the length variable is set to 3. That means 3 letter are presented and then asked to recall those letters by entering them in a text input box.

    text = var.first_letter + var.second_letter + var.third_letter

    this code then capitalizes all the letters since the letter present in the canvas object are in uppercase.

    cap_text = [i.upper() for i in text]

    In order to code the correct response I have this for loop to loop through cap_text variable and match it with letter_canvas_list which stores the actual sequence of letters presented. The match is done letter wise and index wise where it is ensured that the same letter is in cap_letter as it is in letter_canvas_list on the same index position in letter_canvas_list.

    for i in range(len(cap_text)):
    if cap_text[i]==letter_canvas_list[i]:
    var.cor = 1
    else:
    var.cor = 0

    I have now inserted the log file in the loop sequence with only the relevant variables to log for.

    Coming to the problem I am getting an "NA" on the 'cor' column. I am not sure what is causing this? Any view??

    Also I am getting timing issues. After pressing the spacebar or any key on the instruction slide the slid stays there for a while and then the fixation dot appears. Also, the timing of the fixation dot is also delayed in excess of 495 ms. Any ideas as to what this might be causing??

    I have attached the updated experiment file.

    Thanks
    Vatsal

  • HI Vatsal,

    There are a couple of problems with your code. The primary reason the variable cor is not defined is that the loop it is located in is being skipped because cap_text is empty.

    Your logic makes sense in principle, the problem is that the variables text, and cap_text are defined before the form is actually executed. I'm actually a bit surprised that the experiment didn't crash.

    A better way to make this experiment work is to only create a single form, but make its parameters flexible. For example, depending on the number of letters, create lists with the number of columns, rows, and whatever else you need to define the form. And then use these variable to initialize the form. Similarly, you can then add elements to that form, depending on the number of letters. Importantly, once executed, you can collect the responses and define the correct response.

    Another thing that yo should keep in mind is that defining a variable in a loop does basically overwrite for as many iterations that you have and the variable (var.cor in your case) will have the value that was assigned to it on the last iteration. IF you want var.cor to be correct only if all letters were recalled correctly, you have to obtain a correct value for each letter separately, and combine the outcome (e.g. with all()).

    Hope this helps,

    Eduard

    Buy Me A Coffee

  • @eduard

    I just want to check I have understood your answer above... If so it has highlighted a major flaw in my current experimental design! You say:

    "defining a variable in a loop does basically overwrite for as many iterations that you have and the variable (var.cor in your case) will have the value that was assigned to it on the last iteration."

    I am presenting nouns in a loop and asking participants to respond with 3 adjectives. Their responses are [adj_1] [adj_2] and [adj_3]. The [noun] displayed comes from the loop for the sequence. Does this mean that the log will only have values for those variables as provided on the final iteration of the loop?

    I plan to present a selection of the adjectives back to the participant at the end. Is there a way to have each iteration of the loop save the variable under a different "sub-variable" to be recalled later?

    Thank you

    Ali

  • Hi Ali,

    If you have placed a logger at the end of the sequence that you loop over, than the values of your variables will be nicely logged for each iteration. They will be overwritten in OpenSesame internally at the next iteration, but not in your log files.

    Buy Me A Coffee

  • Hi @Daniel thanks so much for clarifying. It would have been a catastrophe if I hadn't realised this before! The second part of my experiments recalls the answers initially given and asks the participants to make a second judgement on them, so I need them saved as separate variables. Thanks again

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