Howdy, Stranger!

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

Supported by

setting experiment variables

Hi all,
I'm running into a very basic problem. I'm sure I've done this successfully in the past but I just can't figure it out this time. Getting older? I dunno :)

What I want to do is set the duration of a sketchpad in an inline script. So, I added an inline script on a sequence and includes the following code in the Run tab:

import random
fix_durations = range(400,1700,100)
fix1duration = random.choice(fix_durations)
exp.set('fix1dur', fix1duration)

Then on a sketchpad that comes right after I use [fix1dur] in the duration field.
When I run the experiment, I get an error that the fix1dur variable does not exist. What am I doing wrong here??

Thanks,
marios

Comments

  • edited February 2018

    Hey!

    Looks like you're using an older version of opensesame. As for opensesame 3.0 we use var. Function in opensesame 3 to create an experimental variable in python

    import random

    var.fixdurations = range(400, 1700, 100)

    var.fixduration1 = random.sample(var.fixduration, 1)

    If this doesn't work add another inline script at the very start of the
    experiment.

    And add this code:

    var.fixduration = []

    Alternatively you could add this variable into the loop that way you won't need any python scripting.

    Hope this helps

    Vatsal

  • Thanks Vatsal. I'll give it a shot. But I think the problem is with the last step of setting the experiment, variable, ie., this part: exp.set('fix1dur', fix1duration)
    Up to that point, everything works well. That is, if I print fix1duration I correctly get one of the values from the list. But, I can't set these values to the sketchpad duration.
    Even if I delete all the code and just say exp.set('fix1dur', 200), I can't use [fix1dur] in the sketchpad duration field.
    marios

  • Hi Marios,

    Put the code in the prepare phase and you should be set :)

    Eduard

    Buy Me A Coffee

  • You're right, it works! Thanks Eduard!
    m

  • Eduard, I still can't get my head around this and why the code doesn't work in the Run phase. I can see a situation where putting the code in the Prepare phase wouldn't work for me. For example, let's say I have a mouse_response item and I want to set the duration of a sketchpad based on the response RT. I would use this code on an inline after the mouse_response item but before the sketchpad:
    ** fixduration = 5000 - exp.get('response_time')
    exp.set('fixdur', fixduration) **
    and then use [fixdur] in the duration of the sketchpad.
    Obviously I cannot prepare the inline as I don't have a value for 'response time' at the start. And it wouldn't work in the run phase either! My questions then are: 1) why doesn't it work in the Run phase 2) what do I do to make this work??
    Cheers,
    marios

  • Hi,

    Here a link to an explanation why this is. Basically, preparing things improves the timing of your stimuli.

    Sketchpads are always created in the prepare phase. That is, they are first called before all other items' run phases are called. So, if you need to present anything that depends on participants responses, you wouldn't use sketchpads, but feedback items. They are created in the run-phase of sequence, so that you can use responses to draw onto them.

    Hope this makes sense.

    Eduard

    Buy Me A Coffee

  • Ok, I get it now! Thanks!!

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