Howdy, Stranger!

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

Supported by

Help with a script

Hi Opensesame people!

I am building a working memory task for my PhD work. The description of the task is as follows:

_ A black “+” symbol is displayed at the center of the screen for 500 ms as a reminder to the participants to pay attention. Subsequently, a blank screen is displayed for approximately 600 ms before a letter series appears. The letter series contains 4–12 uppercase letters that appear sequentially, with each letter being displayed for 750 ms. After the letter series disappears, three of the letters reappear at the center of the screen for approximately 1500 ms. Participants must determine whether these **three letters were the last three letters of the previously displayed series**_. 

I have attached the experiment file below.

I have the following variables:

Stimulus_set (4 to12) X Target (Present vs absent/"on" vs "off")

In order to present letters I have written the following inline code:

import random

import string

letters = list(string.ascii_uppercase)

stimlist = random.sample(letters, var.Stimulus_set)
canvas_letters = ['x']*13 ## creating an empty list

for i in range(0,len(stimlist)):
canvas_letters[i] = stimlist[i] ## filling the list with real letters

if var.Target == "On":
var.tar = canvas_letters[-3:] ## extracting last three items from the series of letters

if var.Target == "Off":
var.ntar = random.sample(letters, 3)

**The problem is that during the target condition the task sometimes displays Xs like ["x", "x", "x"]. **

Lastly, instead using the above code I could use for loop to loop through all the stimulus_set conditions and then make a list of letters to be displayed:

for in range(Stimulus_set):
stimlist = random.sample(letters, i)

But here I get a list out of range error.

Can anyone please guide me on this??

Thanks
Vatsal

PS: I had a similar task that had a list out of range error while using for loop which I had posted its solution gave me the code mentioned in the start of this post.

Comments

  • Hi Vatsal,

    The problem is the line:
    var.tar = canvas_letters[-3:]

    The code is designed is such a way to avoid the list index out of range error by making a filler list that looks something like this:

    ['B', 'J', 'P', 'T', 'W', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x']

    So, only the first items are the targets you would like to use, if you select the last three items and the stimulus set is not 12, you will end up with the three x's.

    This could be solved by:

    A = canvas_letters[:3]

    Selecting the first three items, but I am not sure if that is what you would like to happen when target is 'On' . The for loop you suggest leads us back to the first problem of creating a stimulus list that is not compatible with the code inside the sketchpads since it creates a list that is too short.

    Good luck,
    Roelof

    PS: for future reference try to keep the number of topics limited by posting in the same discussion, this keeps the forum tidier

  • Hey Roelof!

    Thanks for replying.

    Unfortunately I need to select the last three letters from the series not the first three.

    Apologies for posting a fresh topic. I will keep that in mind next time.

    Thanks

    Vatsal

  • edited August 2017

    Hey!

    Little heads up I solved the issue by adding a piece of code before the tar variable in the target on condition:

    if var.Target = "on":
    L = var.stimulus_set
    tar2 = canvs_letter[0:l]
    var.tar = tar2[-3:]

  • Hey Roelof!

    PS: I was not sure whether I should post it as a new discussion. Pardon me if I am wrong.

    In the same project I am developing a new task that is variant of stroop task. Here instead of colors and words I have to use numbers and their font size.

    The task is simple: two numbers are presented on the screen briefly (100ms). Thier font size is different one being a larger in font size another being lower. The participant has to press a key to decide which number is larger in value while ignoring the its font size.

    I have defined the variables as follows

    ISI (800, 900, 1000, 1100, 1200) X size1 (20) X size2 (36) X flip (yes vs no)

    The variable flip== "no" means the left digit is larger in size than the right one
    while flip == "yes" means the right digit is larger in size than the right one

    I am using the an inline script to generate numbers randomly. Also, I am using an inline script to create a variable called "correct_response" since the response key would be different in each case and i could not write it up in the loop item.

    if digit1 > digit2 and var.response_response1 == "z":
    var.correct == 1
    else:
    var.correct == 0

    if digit2 > digit1 and var.response_response2 == ".":
    var.correct == 1
    else:
    var.correct == 0

    Also, the analysis of the participant's response is that a person's response time or accuracy will vary in conditions were there is miss match between the digits size (incongruent condition) and its value versus the condition where there's match between the digit size and its value (congruent condition). For this purpose I have also written an inline code.

    if digit1 > digit2 and var.flip == "no":
    var.incog == "yes"
    else:
    var.cong == "yes"

    Coming to the issues I am facing:

    1.There seems to be a fewer trials in the incongruent condition

    2.The log file doesn't log the correct responses

    1. The incongurent column and congruent column are marked as "none" in the log file

    I would be grateful if you could look into it. Experiment file attached.

    Thanks
    Vatsal

  • HI vatsal,

    I changed your code a little. have a look here:

    It looked fine, just a couple of redundancies. Also, be careful not to confuse = with ==. This caused the issues with the congruencies.
    Finally, you should be aware that they way you sample numbers currently, does not exclude the possibility that you have twice the same number, which will also cause the congrueny/incongruent varaible to be skewed.

    Good luck,
    Eduard

    Buy Me A Coffee

  • Hey Eduard!

    Thanks for the reply and edition in the experiment. I am working on a more controlled way of sampling numbers which could creates a balanced number of congruent and incongruent conditions.

    Thanks again
    Vatsal
    :)

  • edited September 2017

    Hey Eduard!

    In reference to my previous problem where I was not able to balance the number congruent and incongruent trials in my experiment. I added a new piece of code:

    **if var.cong == "yes": ## congruent trials where there is match between the digit's value                      
                                          ## and size
        d2 = random.randint(d1 + 1, hi)
    else:
        var.cong == "yes" and var.flip == "no":    ## incongruent trials where there is a mismatch between      
                                                                             ## digit's value and size
        d2 = random.randint(lo, d1 - 1)**
    

    I have also made some changes in the sequence of loop. Where I have added two more sketchpads to incorporate the "incongruent" trails.

    However, running the experiment gives me an error:

    'int' object has no attribute 'getitem'

    I have come across this error previously also when I used the random.randint function.

    Would be grateful if you could look into it. Experiment attached

    Thanks
    Vatsal

  • Hey @eduard

    Still I am unable to find the solution for this.

  • Hi Vatsal,

    It has been some time, sorry. Can you please summarize what the goal is, what we accomplished so far and what outstanding issues we have?

    Thanks,

    eduard

    Buy Me A Coffee

  • Hey Edward !

    Thanks.

    It took me some time to reply but I could resolve the issue.

    Solution was to create a fresh experiment with little changes and instead picking up the items from the list I simply made seperate experimental variable in an inline script using var. command. That did the trick

    Thanks again

    Vatsal

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