Howdy, Stranger!

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

Supported by

[solved] Skip subject number and log path dialogs

edited June 2015 in OpenSesame

Hi,

We are going to do field testing with Nexus 7 (Android 5.1.1) at festivals this summer and to improve the efficiency i am wondering if it is possible to omit the dialog screens at the beginning of the experiment. Ideally the experiment will automatically 'up' the subject number by one from the previous run and then use the new number as as subject number and log paths for the new run.

Secondly, we will use multiple tablets with the same experiment. To avoid having multiple subject-x.csv files is there a way to ID the individual tablet and write this to the log file?

Any suggestions are appreciated!

Comments

  • edited June 2015

    Hi,

    You can bypass the startup menu of the OpenSesame runtime for Android by creating an opensesame-autorun.yml file as described here (new in 2.9.5):

    This will always start the experiment with the same logfile, but you can reopen a new logfile at the start of the experiment as described here:

    Does that help at all?

    Cheers,
    Sebastiaan

  • edited June 2015

    Hi Sebastiaan,

    Thank you for the answer, bypassing the menu works like a charm with the .yml file. If anyone else wants to use it: it only works if the experiment is saved as a .opensesame file and not as .opensesame.tar

    The second part, incrementing the file name by one and use this as a new log file, has not worked for me yet. This is what i want to use in the beginning of the experiment:

    import codecs
    import os
    
    exp._log.close()
    
    i = 1
    while os.sdcard\Data.exists("subject-%s.csv" % i):
        i += 1
    
    exp._log = codecs.open('subject-%s.csv', 'w', encoding='utf-8')
    

    So it opens the latest log file that has been created. Unfortunately, this does not work. I wish i could copy the debug-file but for some reason the windows explorer crashes whenever i try to open/copy/delete a .txt file from the Nexus 7 (is this a known problem?).

    EDIT: This is the same debug file but generated from my laptop:

    Starting experiment as ExperimentProcess-6
    openexp.sampler._legacy.init_sound(): sampling freq = 48000, buffer size = 1024
    openexp.sampler._legacy.init_sound(): mixer already initialized, closing
    experiment.init_log(): using 'C:/Users/Laurent/Documents/Psychology/MajorThesis/Experiment/subject-0.csv' as logfile (utf-8)
    experiment.run(): experiment started at Tue Jun 02 17:16:48 2015
    
    Failed to compile inline script
    
    code: while os.C:\Users\Laurent\Documents\Psychology\MajorThesis\Experiment.exists("subject-%s.csv" % i):
    
    exception type: SyntaxError
    exception message: 
    item: rename_log
    phase: run
    line: 7
    
    Traceback:
      File "dist\libopensesame\inline_script.py", line 144, in prepare
      File "dist\libopensesame\python_workspace.py", line 97, in _compile
      File "<string>", line 8
        while os.C:\Users\Laurent\Documents\Psychology\MajorThesis\Experiment.exists("subject-%s.csv" % i):
                                                                                                          ^
    SyntaxError: unexpected character after line continuation character
    
  • edited 10:41AM

    The error message is gone now but log file does not work properly since it does not update the new file. When i run OpenSesame on the tablet it automatically starts the experiment. This is what is have at the start of the experiment to close and re-open the current logfile with a newly assigned subject number.

    import codecs
    import os
    
    # Close current log file
    exp._log.close()
    
    # Define the first log
    i = 1
    while os.path.exists("subject-%s.csv" % i):
        i += 1
    
    # Open the new log file with up to date participant number
    exp._log = codecs.open('subject-%s.csv' % i, 'w', encoding='utf-8')
    

    During the experiment is use the default logger with two variables. But there is no new .csv file written nor any error. Can anyone see what i'm doing wrong here? Could it be that the logger item does not acknowledge the new log file?

  • edited 10:41AM

    Hi,

    You don't specify a folder, so the logfile is created in the working directory. To be honest, I don't know what that is for an Android app, but it's probably some internal, hidden folder.

    Does it work if you explicitly specify the logfile folder? Here I used /sdcard/:

    import codecs
    import os
    
    # Close current log file
    exp._log.close()
    
    # Define the first log
    i = 1
    while os.path.exists("/sdcard/subject-%s.csv" % i):
        i += 1
    
    # Open the new log file with up to date participant number
    exp._log = codecs.open('/sdcard/subject-%s.csv' % i, 'w', encoding='utf-8')
    

    Cheers,
    Sebastiaan

  • edited 10:41AM

    Hi Sesbastiaan,

    Thank you for the reply. I managed to get it to work now by specifying the folder and changing the input from string to decimal. I also created a manual logger instead of the standard item because the files were starting to get messy.

    I guess the earlier log files are written to /data/data/nl.cogsci.opensesame which is indeed a hidden folder.

    Anyway, the workaround allows for much more efficient data gathering, so thank you for the help!

    Cheers,

    Laurent

  • Hi Sebastiaan and Laurent,

    I would love to find a way to bypass the "Enter subject number" dialogue box (so participants don't have to input a subject number manually), change the text the dialogue box contains (so I can replace with my own more specific instructions), or apply default subject numbers that are not 0 for each run. I use the regular OpenSesame (not runtime) on a PC. Do you know of any ways to do any of these things?

    Thank you so much,

    Jessica

  • Hi Jessica,

    With the regular desktop application this is not possible, but opensesamerun allows you to specify the subject number and log file on the command line, like so:

    opensesamerun my_experiment.osexp -s 0 -l logfile.tsv
    

    Cheers!

    Sebastiaan

Sign In or Register to comment.