Howdy, Stranger!

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

Supported by

log.write_vars() does not log experimental variables from inline_scripts

I can see all variables in the variable inspector.

However, the experimental variables from the script do not appear in the logfile. Seems like a bug to me. I still could not find a nice workaround for this. Probably, it needs to be fixed.

Here some example code:

from random import shuffle

fixdot = canvas()

fixdot.image(pool['fixdot.tif'])


empty_screen = canvas()


A = canvas()

A.image(pool['Bild1.tif'])

B = canvas()

B.image(pool['Bild2.tif'])

C = canvas()

C.image(pool['Bild3.tif'])

D = canvas()

D.image(pool['Bild4.tif'])


stim_lst = [A,B,C,D]*20

shuffle(stim_lst)

targets = keyboard(keylist = ['x','m'])


for i in range(80):

var.TrialNr=i+1

var.RT=None

var.Resp=None

var.Correct=None

fixdot.show()

leer.flush() #workaround on mac

clock.sleep(400)

stim_time = stim_lst[i].show()

var.Correct = 1

var.Resp=0


while True: #collect responses that were actually not required/allowed

if clock.time() - stim_time > 750:

break

#elif var.Resp!=0:

# var.Correct = 0

# break

key, time = targets.get_key(timeout=10)

var.RT = time - stim_time

if key != None:

var.Resp=key

if stim_lst[i] == A:

if key != 'x':

var.Correct = 0

elif stim_lst[i] == B:

if key != 'm':

var.Correct = 0

elif stim_lst[i] in [C,D]:

if key != None:

var.Correct = 0

# break

log.write_vars()

empty_screen.show()

clock.sleep(1000)




I do get i and key. But I do net get e.g., RT and Resp in the logfile.

Comments

  • I am using 'automatically log all variables' in the logger to make sure that I am not missing anything.

  • Hi @DahmSF,

    Could you directly provide the experiment file you are using? Without the indentation, your code is hard to read/use.

    Thanks,

    Claire

  • Hi Claire,

    help would be greatly appreciated.

    Please find the experiment file here: https://fileshare.uibk.ac.at/d/752c3c1b78664b6c8948/

    Actually, there is one such variable that is logged in the logfile which is var.Phase.

    However, all the others are not.

    The VMIQ part worked in previous version, but does not work anymore. There should be some variables like IVI, EVI, KIN, modality in the logfile. They all appear in the variable inspector, but not in the logfile.

    Best,

    Stephan

  • edited January 23

    Hi @DahmSF,

    Thanks for providing your script. Is the var.title also logged in the logfile? If that's the case, I suspect this may be because all your other variables are not being initialized early enough in the experiment. Even though you use log.write_vars() in your inline scripts, these statements might not capture variables for the LOGGER item unless they were initialized early on.

    Therefore, you could try adding an inline_script at the very beginning of the experiment (before all the other ones in your sequence) and have something like:

    Also, it seems like you create the copy of the logfile, which I assume is the one you are using, before the LOGGER item. Maybe also try putting the LOGGER item first, and see if one or both of these two suggestions solve the issue?


    Let me know if it changes anything or if we should look for another solution!

    Claire

  • Placing the variables into the first inline_script worked.

    Thank you for this workaround!


    Still, I need to be careful that it logs everything which is not the idea of log.vars() , i.e., simply logging all variables. @sebastiaan : I guess this should be fixed in the next version :)

Sign In or Register to comment.