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 .txt file to assign order to stimuli presentation?

Hello!

I am a beginner at Python. I am trying to create an experiment with a training/priming phase, and then a forced choice testing phase.

For the training phase, I have a .txt file that contains a "template" (a list of 700+ items) for the ordering of my stimuli. During the training phase, the participants will see a sequence of eight (8) randomised words individually, but over 700 times within a fixed order as laid out by the template.

The template is kind of like so:
[a0]
[a1]
[a2]....

What I need to do is randomise the word list and reassign the corresponding template items for each participant. For example, with the words orange, green, and blue; participant 1 one would have [a0] = orange, [a1] = green, [a2] = blue, participant 2 would have [a0] = blue, [a1] = orange, and [a2] = green.

So far in the prepare phase of an inline_script I have to import my .txt file:
import numpy as np
nonword_train = np.loadtxt(exp.get_file("training_template.txt"), dtype=str)

I apologise if this is not very clear. I would appreciate any help as I am quite lost.

Comments

  • Hi,

    I am not sure whether I entirely understand what you want to accomplish. So you have eight different words in total, and present them in a random order for 700 times in total. Is this correct? Or what information do you get from the template?

    Generally, if you want to control stuff happening across participants, you can use the variable var.subject_nr. So here a little example how to go about that:

    # this code assigns three different orders of stimuli over all subjects
    # the '%' is the modulo operator and returns the rest of a division. e.g. 1%3 returns 1, 2%3 returns 2, and 3%3 returns 0
    
    if var.subject_nr%3 == 0:
        stim_order == ['red','blue','green']
    elif var.subject_nr%3 == 1: 
        stim_order == ['red','green','blue']
    elif var.subject_nr%3 == 2: 
        stim_order == ['blue','green','red']
    
    # depending on the participant number another order of items is being used. 
    

    Btw. If you are new to Python, I can only recommend that you spend some extra time now to learn Python before you proceed programming experiments. Even if it slows you down now a little, you will see that you'll be much quicker and better solving problems in the future. Here a link to some resources.

    Eduard

    Buy Me A Coffee

  • edited January 2019

    Hi Eduard,

    Thank you so much for taking the time to respond. I will definitely have a look at the Python resources.

    The .txt template is the order in which the stimuli should be presented in the training phase. It provides a fixed order for the presentation of 700 trials. So I have eight different words, that should be presented in the fixed order as defined by the .txt file. Here is a segment of the .txt file: So e.g. [a0] will always = apple for participant 1, but banana for participant 2. [b1] = watermelon for participant 1, but kumquat for participant 2. I hope this clarifies things a little.

    Is there a way for me to import/load the .txtfile to fix the order of presentation, but randomise the stimuli for each participant? Additionally, would I be able to carry over the values of [a0], [a1], [b0] etc, for each participant into the testing phase (e.g. have [a0] be banana for participant 1 in both the training phase and the testing phase) ?

  • I think probably the easiest would be to define the mapping in the beginning of the experiment, and then replace the items. For example:

    import random
    # load the text file
    # as I dont have the text file I just create an example list
    example_txt = ["[a0]","[a1]","[b0]"]*20
    random.shuffle(example_txt)
    
    # define how the txt content maps on words, depending on participant number
    if var.subject_nr%3 == 0:
        mapping = {'[a0]':'apple','[a1]':'banana', '[b0]':'peach'}
    elif var.subject_nr%3 == 1:
        mapping = {'[a1]':'apple','[a0]':'banana', '[b0]':'peach'}
    
    # make a new list and add one by one the mapped labels to it
    replaced_list = []
    for item in example_txt:
         replaced_list.append(mapping[item])
    

    Hope this helps.
    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