Howdy, Stranger!

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

Supported by

[solved] sort logger vars

edited February 2014 in OpenSesame

hi! i hassle with the logger because i am not able to sort the variables for the logfile.

it would be nice if all variables from different loops would stand in the same column.

is there any way to do this? or is there another element to set the vars other than the logger, i.e.

log "cogPos_pic"
log "cogPos_age"
log "cogPos_gender"
log "cogPos_valence"
log "response_cogPos_keyboard_response"
log "response_time_cogPos_keyboard_response"
log "correct_cogPos_keyboard_response"

???

thanks a lot,

ben

Comments

  • edited 2:29PM

    ps: i don't understand why the logger sets the variable names for almost every new loop but for some loops not...

  • edited 2:29PM

    Hi Ben,

    The logger writes one row of data every time that it is executed. So you can never have data from two different loops, or more generally from two different calls to a logger, in the same row. But if you want you can write to the logfile using Python script, in which case you can use any kind of format you'd like. This is described here:

    ps: i don't understand why the logger sets the variable names for almost every new loop but for some loops not...

    Do you mean that you get a new row of column headers in the middle of your logfile? This happens if you have more than one different logger items in your experiment, which start cross-talking. Usually, you would have only a single logger in the experiment, although this single item can occur at multiple positions in the experiment (i.e. by re-using the same logger, rather than creating a new one).

    Cheers!
    Sebastiaan

  • edited 2:29PM

    sorry, i already edited my question before your answer. i ment "it would be nice if all variables from different loops would stand in the same COLUMN."

    the variables have different names (from different conditions) but contain the same kind of data. therefore it would be nice if the logger do not shuffle the order of variables (columns) by itself but keeps my specified order (see example above). i see no pattern in the "shuffle method".

    in the end i gues i will script my own logger but i have a certain compulsion to understand why things happen :) and maybe it helps another user aswell...

    thanks a lot!

    ben

  • edited February 2014

    hello again, i couldnt find a way to write variables with self.log().

    i have variables set in a "setup-script" like

    "here some array with pics"
    var1pic=array[0][0]
    exp.set("var1pic",var1pic)
    

    and the variable [num] in the loop which identifies a certain pic in the sketchpad ([var[num]pic]).

    how could i write the name of the pic into the log? and how can i catch key_reponses to be written in the log?

    i really try to fix problems by myself but somehow the docu and me are no good friends yet...

  • edited 2:29PM

    the variables have different names (from different conditions) but contain the same kind of data. therefore it would be nice if the logger do not shuffle the order of variables (columns) by itself but keeps my specified order (see example above). i see no pattern in the "shuffle method".

    The logger always arranges columns alphabetically, independently of the order of the log statements in the script. But different variables will never be written to the same column: One variable = one column. So if you want to have a particular 'kind of data' to always appear in the same column, you need to make sure that the data is stored in the same variable.

    how could i write the name of the pic into the log? and how can i catch key_reponses to be written in the log?

    In an inline_script you have to use self.get() to retrieve an experimental variable. So if you have defined some variable called my_var in a loop item, you would log it like so:

    self.log('my_var = %s' % self.get('my_var'))
    

    Or for the response variables that are set by a keyboard_response:

    self.log('response = %s' % self.get('response'))
    self.log('response_time = %s' % self.get('response_time'))
    self.log('correct = %s' % self.get('correct'))
    

    See also:

  • edited February 2014

    thank you so much! now everthing works fine!

    i just had to find out how to write more than 1 string to write all variables in one line:

    self.log('%s;%s;%s' % (self.get('var1'),self.get('var2'),self.get('var3')))
    

    thanks a lot again!

Sign In or Register to comment.