Howdy, Stranger!

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

Supported by

[open] OpenSesame and R: works together?

edited July 2012 in OpenSesame

Hello,

Can I use a script in OpenSesame where I

a.) run an expernal script between each item presentation

b.) which uses the last data point from a saved file

c) and import the output of that external script to define the new itemset?

Or in short: Can I export and import csv-data between each trail in order to manipulate my itemset?

I have no experience with python, but I think its nice. I heavily rely on R, this is why I ask.

I already found the rpy-extension for python. Would this do the trick?
Has anyone expierence using R during running experiments in OpenSesame?

Best

Comments

  • edited 8:57PM
    a.) run an expernal script between each item presentation

    You mean that you want to alternate between presenting stimuli using the OpenSesame sketchpad and running Python code? Sure.

    Or in short: Can I export and import csv-data between each trail in order to manipulate my itemset?

    Yes, working with text data is trivial in Python, see e.g., http://docs.scipy.org/doc/numpy/reference/generated/numpy.loadtxt.html

    I already found the rpy-extension for python. Would this do the trick? Has anyone expierence using R during running experiments in OpenSesame?

    As I understand it rpy is for executing R code in a Python script. If you just want to use R for working with text data, it's probably easier to just use native Python functions for that.

    Cheers!

  • edited August 2012

    hi sebastiaan,

    after playing a little around and finishing the tutorial, I think it is very cool.

    One more question(s ;-) ): Can you give me an example how I can precisely address and change the variable set I defined via the GUI? What data structure uses it?

    Or in general, how do I address such items?

    As I understand so far I can easily address a variable "item" - if I created it - which can just give me the row line in the variable spread sheet. If I want to have some of those rows deleted based on the subjects response data, how do I do that?

    Can I also see the complete code at once? Is the opensesame-code pre-compiled into python or any other language?

    greets
    the plastic

  • edited August 2012
    after playing a little around and finishing the tutorial, I think it is very cool.

    Glad you like it!

    Can you give me an example how I can precisely address and change the variable set I defined via the GUI?

    In an inline_script item, you set variables using

    exp.set('my_var_name', 'my_value')
    self.experiment.set('my_var_name', 'my_value') # for 0.25 and before

    and get variables using

    my_value = self.get('my_var_name')

    See also

    As I understand so far I can easily address a variable "item" - if I created it - which can just give me the row line in the variable spread sheet. If I want to have some of those rows deleted based on the subjects response data, how do I do that?

    I'm not sure I fully understand the question. You want to change the loop table while the experiment is running, is that correct? That's currently not possible. The easiest way to do something similar is probably by using the "Run if" statement of the sequence item to skip particular trials under some conditions. But I would need to know more details before I can say something specific.

    Perhaps this thread is useful:

    Can I also see the complete code at once? Is the opensesame-code pre-compiled into python or any other language?

    Yes, the script, which uses a simple custom syntax, can be viewed and edited by clicking on 'Show script editor' in the general tab of the experiment. For more information, see

    Cheers!

  • Okay, thank you very much for your help.

    I think, I will be able to dodge this problem of not being able to change the trial table by simply building me a copy of it as an python object. In this I will hopefully be able to do my calculations. Then I want to copy it in every trial back to the variables of opensesame before it is presented to a participant and get my conditions then, to decide ether to skip presentation of that trial or not .

    Sounds like a plan?

    Best.

  • edited 8:57PM

    Yes, if I understand correctly, that would be a feasible approach.

    Basically, you just insert an inline_script at the start of each trial to initialize the trial variables (using exp.set() statements). You will want to do this initialization in the prepare phase of the inline_script, so that it takes place as early as possible.

    Cheers!

  • Great, thanks!

  • Ah, yeah, I can use ScyPy for that, right? Is it build in and simply available by "import SciPy" or whatever casing?

  • edited 8:57PM

    Yep, if you need SciPy (which you might), you can just:

    import scipy
  • edited September 2012

    Hello,

    I found some bugs:

    1. I often get this error:
    Could not save file, because the script could not be generated. The following error occured:
    Error: Script error
    Description: Failed to instantiate module 'inline_script' as 'copy_table_inline_script': Error: Script error
    Description: Error parsing ' set _prepare "print self.get('noi')' in item 'copy_table_inline_script': No closing quotation

    It seems to have something to do with the indent of lines, bit the error does not disappear even when the inline script is empty.

    1. If you name you variables with numbers like "0", "1" etc. there is some kind of problem in setting up the table...
  • edited 8:57PM
    It seems to have something to do with the indent of lines, bit the error does not disappear even when the inline script is empty.

    I see. What operating system and version of OpenSesame are you using?

    If you name you variables with numbers like "0", "1" etc. there is some kind of problem in setting up the table...

    Right, variable names cannot not start with a digit (that's not valid Python), but OpenSesame doesn't check for this and gives an ugly error. In 0.27 (currently under development) you will get a more intelligible error message.

    Cheers!

  • edited September 2012

    Mointain Lion and 0.26

    I think it maybe has something to do with the script. it behave strange because when I start inserting some code, it first turns out as expected:


    _run
    print "hey"
    end
    ___prepare__
    print "ho"
    end

    but sometime it changes to


    set _run ""
    set _prepare "m = [[99]*3] *3"

    especially if I only define the prepare-phase.

    But as I said, I do not know if this is that, because even when I clear all the code in the script, the error still prevents me from saving my project....

    note: the "_" are not displayed correctlty here, but it is correct in the code...

  • edited 8:57PM

    I think that you are correct: It probably has something to do with the way that end-of-lines are encoded on Mac OS. There was trouble with that before. I thought we fixed it, but apparently not!

    I forwarded this discussion to a colleague who can test it on Mac OS, as I don't have a mac myself. For now, maybe it's convenient to know that you can use the external script plug-in, which has this icon:

    image

    This plug-in allows you to run external .py files, so you can probably get around this bug.

    Thanks for bringing this to our attention!

  • Thanks.

    Another easy workaround is not to leave any of the run or prepare phase empty, e.g. by writing something like

     print "can't touch this" 

    into these.

  • edited 8:57PM

    Right, I think this probleem is indeed partly caused by incorrect processing of newline characters. We'll have to look into a fix for this.

    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