Howdy, Stranger!

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

Supported by

[open] Logger info to generate the variable for the next trial run

edited May 2014 in OpenSesame

Hello, thank you so much for this wonderful free-source program! I must admit I am extremely new to coding and have very limited knowledge of using Python. Just wanted to hedge with that, so please excuse me if this seems intuitive!

I am constructing a design that will track how a language evolves over the course of 40 participants. To do so, I need to be able to use one person's responses to constitute as the input, or new stimuli, for the next participant and repeat. I am sure this is a manipulation I need to specify in the logger file, but I am unsure how to execute this task. Any help would be tremendously appreciated. Many thanks!

Comments

  • edited 1:02AM

    Hi!

    This is doable, but will require some inline (Python) scripting, as it will not be possible to do it using standard OpenSesame plug-ins.

    In general, what you will need to do, is to read the CSV output from the previous participants. This is quite straightforward in Python, but I would advise you to read up on the language. An example snippet is provided below:

    # open a text file
    textfile = open("example.csv", 'r') # the 'r' stands for 'read mode'
    
    # read the contents
    data = textfile.readlines()
    
    # close the textfile again (the contents will still be
    # available, as we stored it in the "data" variable)
    textfile.close()
    
    # parse the lines
    for i in range(len(data)):
        # remove some clutter from the line
        data[i] = data[i].replace("\n","").replace("\r","").replace("\t","").replace("'","").replace('"',"")
        # turn the line (a string) into a list, by splitting
        # it on the commas
        data[i] = data[i].split(",")
    
    # the first line of an OpenSesame output file is
    # always a header
    header = data.pop(0)
    

    After this, you end up with two lists:

    # the header looks like this:
    header = ['var_a', 'var_b', 'var_c']
    
    # the data looks like this:
    data = [[1, 2, 3], [4,5,6], [7,8,9]]
    

    After learning a bit of Python, you will probably be able to understand the snippet above, and perhaps even to use it in an experiment. If not, please do post any further specific questions on the implementation.

    Good luck!

    Edwin

Sign In or Register to comment.