Howdy, Stranger!

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

Supported by

[open] Randomly presenting auditory stimuli with multiple variations

edited April 2016 in OpenSesame

Hi all,

I am working on an experiment in which a participant will hear a carrier sentence (that has been manipulated in two different ways) followed by a target word. There are six different carrier sentences, but because we do not hypothesize an effect of different carrier sentences, a participant could be presented with any one of the six. The important thing is that they're exposed to two manipulations done to the sentence.

For example, our naming system for the files goes like this: "car1_ENV1_DUR1". The initial "carX" portion indicates which of the six carrier sentences it is, and the "ENVX" and "DURX" portion indicate the steps of the manipulations. Essentially, it does not matter whether a participant is presented with "car1_ENV1_DUR1" or "car5_ENV1_DUR1", as they are functionally the same in this experiment.

My question is, what is the best way to go about picking a random carrier sentence while still presenting the participant with equal amounts of the two manipulations?

Our idea right now is to use a MATLAB program to generate a list of stimuli with equal distributions of the "ENV" and "DUR" manipulation, but attached to random carrier sentences. Then we would import this list using a python code.

  1. Is this the best or easiest way to go about this?
  2. And if so, what would the coding look like?

I found this python code on the forum that I think we could use as a base:

path_list = exp.get_file("stimuli_list.txt")

import numpy as np
stimlist = np.loadtxt(path_list, dtype = str)

import random
random.shuffle(stimlist)

global stimlist

word = stimlist.pop()

exp.set("word", word)

If we did go about it using this method, I would also need to add a variable to the filename that reads the current subject number, so that it finds the list that corresponds to them.

I am very appreciative of your help!

Comments

  • edited 2:34AM

    Hi,

    Is this the best or easiest way to go about this?

    Well no, the best (maybe not best, but certainly easiest) way is to do everything in Python, that is Opensesame altogether.

    And if so, what would the coding look like?

    For one, you need to define the variables that you want to manipulate in the loop table of a loop item. For example, you could have two variables there: ENV and DUR and each of them contains all possible values. In the sequence of that loop you can place an inline_script, in which you can use plain python code. What you would need to do is creating the filename of the files that fit the values of your variables ENV and DUR. Something like that will do:


    import random # pick a random carrier sentence carrier = random.choice([1,2,3,4,5,6] filename = 'car%s_ENV%s_DUR%s'%(carrier,var.ENV,var.DUR) # then load the file and do the presenting operations

    As I understood, all the sentences and words are already saved somewhere in files. With the method I briefly described, you select which files contain the information that are needed for a particular trial, read this single file into Opensesame and its content during a trial. However, if this is not the case (e.g. everything is stored in one variable, or the sentences are freely cominable and currently not stored anywhere), you can also do the counterbalancing and randomization steps in the beginning of your experiment (from within an inline_script, which is basically python scripting). If you like to do that, let us know and we can give more info on how to do it.

    I hope this makes sense.

    Good luck,

    Eduard

    Buy Me A Coffee

  • edited April 2016

    Update: I've gotten part of it working, but now I'm stuck on how I take this filename I've generated and present the audio file it matches to. I know how to make the sample use variables from the Loop window, but I don't know how to take the filename from the python code and use it.

  • edited April 2016

    Hi,

    It depends on the structure of your experiment (will you do everything in inline_scripts or are you only using them to prepare everything and then rely on other items like sketchpads and samplers).

    In python code is basically two things that you have to do:

    1) Load the image : sound = exp.pool['example.ogg']

    2) Create the sampler: my_sampler = sampler(sound, volume=.5)

    (the third step would be to actually play the sound: my_sampler.play() )

    Does this make sense?

    Good luck,

    eduard

    Buy Me A Coffee

  • edited April 2016

    Thank you so much, I got that working!

    I have ran into another issue: I'm trying to make an individualized sketchpad appear with response options depending upon the the word presented. There are six words, so I've created six sketchpads. The six words are: slab, lab, gab, clog, league, and tend.

    Currently, I'm trying to do this by using a Python script that reads the filename (like "car1_ENV2_DUR3+sla_VL3.wav" and checks to see if any of the six words are in it. If it is present, I want it to change a variable to a different number, and then the appropriate sketchpad runs based on that variable's value.

    This is what I have so far:

    In the first sequence, I have a an inline script that sets the variable to zero:

    exp.set('responseSP','0')
    

    Then in the experimental loop I have this:

    file = self.get('fname')
    print self.get('fname')
    
    if 'lea' in file == 'true':
        exp.set('responseSP','1')
    elif 'lab' in file == 'true':
        exp.set('responseSP','2')
    elif 'sla' in file == 'true':
        exp.set('responseSP','3')
    elif 'ten' in file == 'true':
        exp.set('responseSP','4')
    elif 'clo' in file == 'true':
        exp.set('responseSP','5')
    elif 'gab' in file == 'true':
        exp.set('responseSP','6')
    
    print self.get('responseSP')
    

    Unfortunately, 'responseSP' doesn't seem to be changing as it prints "0" both before and after the series of "if" statements. I'm sure this is very easy to do, but I can't seem to get it to work.

  • edited 2:34AM

    Hi,

    two things I'd like to point you to.

    First, if you want to check whether something is true, you can't use the string "true", but have to use it plainly true (or simply 1 or 0).

    Second, if you test whether something is in something else, you don't to add a true comparison.

    So, if 'lea' in file: will be sufficient.

    Does this make sense?

    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