Howdy, Stranger!

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

Supported by

[solved] Trouble Creating Progressive Experiment using Run if

edited October 2012 in OpenSesame

I want to build a collection of phases in an experiment, in which each successive test sequence is only run if the response is below a certain threshold (2000 ms). I am finding the sequence never runs when I set the "run_if" panel for a successive sequence as [avg_rt]<2000 and always runs when I set [avg_rt]>2000.

I am not sure if this is a consequence of the way I am setting and getting avg_rt or if this a bug in the program. The feedback part seems to get the number right, but then the conditional logic part does not work.

Thanks,
George

Here is the code from the sequence in question.


reset_feedback "always"
run block_loop "always"
run loop "[avg_rt]<2000"
run feedback "always"

Here is the whole code:
[gist:3842684]

I also tried toying with the affect orientation experiment example, because I noticed the feedback loop would report using the [avg_rt] variable. However, I still could not get a follow-on sequence to trigger when run if [avg_rt]<2000 was specified.

[gist:3842650]

Any help or coaching of better approaches to make this work would be greatly appreciated.

--George

Comments

  • edited October 2012

    EDIT: The new variable should not be called "run", because a built-in variable named "run" already exists. (See posts below.)

    Hi George,

    Thanks for your post! You discovered a bug which Sebastiaan plans to fix for the next version of OpenSesame. The reason your experiment does not work as expected is that values that are entered in the interface are always interpreted as being a string. Therefore, comparisons like [avg_rt] > 2000 do not work (yet).

    For now, the best way to get around this issue is by using a bit of Python inline code to make a string variable to indicate whether or not to run a certain sequence. This can be achieved like so:

    if self.get("avg_rt") < 2000:
    exp.set("run","yes")
    else:
    exp.set("run", "no")

    If you place this piece of code in an inline_script item just before the loop where you need the information (i.e. your loop called "loop") you can get the desired result by setting the run-if statement to [run] = "yes". Note also that in the interface such statements should always have spaces in between the words (so [run]="yes", without spaces, won't work).

    I hope this helps! Please feel free to ask any further questions!!

    Best wishes,

    Lotje

    Did you like my answer? Feel free to Buy Me A Coffee :)

  • edited 2:26PM

    Thanks for the coaching. I tried it with the modifications you suggested, and still ran into the same problem. I also tried running the old code on the beta version (.27) , as I read that there had been some work to fix this bug.

    Here is the updated code:
    [gist: 3853813]

  • edited October 2012

    Hi George,

    Did you place the suggested Python code in the "Run phase" tab of your inline_script item? The variable avg_rt is calculated during the run phase of a sequence, so if the code is placed in the "Prepare phase" tab it won't work.

    Another possibility is that avg_rt itself isn't calculated correctly. You could easily check this by either printing its value to the debug window in your inline_script item:

    print exp.get("avg_rt")

    or by making a temporary feedback item to show the variable (simply use the text tool to show [avg_rt]).

    Please let us know if you still encounter the same problem. (It seems like something went wrong with uploading your experiment, but if you add the updated version we can have a closer look at the code if necessary.)

    Best wishes,

    Lotje

    Did you like my answer? Feel free to Buy Me A Coffee :)

  • edited October 2012

    Hi all!

    The problem might arise from the fact that the runif variable is called 'run'. I've tested it on OpenSesame Portable 0.26 (should be the same as running 0.26 from source on Windows) and using a variable called run just skips all of the elements, whereas a variable called runn (or anything similar to 'run' that isn't acutually 'run') does work. (I suspect there already is a variable called 'run', probably created somewhere during the running of a sequence, but I can't find the actual creating nor addressing this variable in the source code)

    On the spaces: do they really have to be in there? Since my previous experiments (0.25 and 0.26 on WinXP and Win7) all work without spaces in Run if statements (e.g. '[runn] = yes" works just as well as "[run]=yes]"). Is this something specific to 0.27 or to a different OS?

    Thanks!

    Edwin

  • edited 2:26PM

    Ah, right, of course...

    What exp.set() essentially does is add a variable as an attribute to self.experiment. Since self.experiment already has an attribute named run (namely the function that handles the running!) doing exp.set('run', ...) causes OpenSesame to malfunction. The user should be protected from this, so I created an issue:

    https://github.com/smathot/OpenSesame/issues/105

    Regarding the spaces in Run if statements: In some cases it may work, but sometimes it may not, so I would recommend using spaces for now. For 0.27, I plan to improve the parsing of the Run if statements (but in a way that is backwards-compatible, of course).

    Cheers!

  • edited 2:26PM

    Problem Kludged:

    I changed the variable to go, and now the code exhibits the intended conditional execution behavior.


    if self.get("avg_rt") < 2000:
    exp.set("go","yes")
    else:
    exp.set("go", "no")

    Thanks for the support!

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