Using OpenSesame to create a label file to import in VU-DAMS

User avatar
Posts: 35
Joined: 06 Jan 2012, 12:41

Using OpenSesame to create a label file to import in VU-DAMS

Postby JarikdenHartog » 28 Jul 2016, 17:59

For those who want to try and use OpenSesame to build an experiment and create a label file straight from OpenSesame, you can use the code below.
Use the code in an inline script item in OpenSesame and a [subject_nr]_icg.lbl file will be created for every participant. That file can be imported into VU-DAMS to automatically create labels as long as a label.cfg file containing the right Label Codes exists. For the example below the label.cfg file could look like:

#Experimental condition
10 Baseline


Code: Select all
from datetime import datetime

# This code will create a [subject_nr]_icg.lbl file that can be imported into
#  VU-DAMS to create labels. The VU-AMS device and clock of the PC running this
#  have to be in sync for this method to work!

filepath = var.experiment_path + '/' + str(var.subject_nr) + '_icg.lbl'
f = open(filepath, 'w')

# The label file must start with one line which could hold the subject ID for example.
f.write(str(var.subject_nr)+'\n')
# From the second line there will be labels in the following layout:
# SPACE date-time start SPACE SPACE date-time end SPACE SPACE SPACE label code (label could should also exist in label.cfg file)
# date-time  is in format dd-MM-yy/hh:mm:ss

labelstarttime = datetime.now().strftime('%d-%m-%y/%H:%M:%S')

# Now do the stuff you want to do within the label (in this example "clock.sleep(2000)")
clock.sleep(2000)

# You can copy the code below to another in line script to put everything in
#  between this inline script and the next in the label 10
f.write(' '+ labelstarttime + '  ' + datetime.now().strftime('%d-%m-%y/%H:%M:%S') + '  10\n' )

# Optionally repeat steps above to create more labels

# Label file ends with 4 empty lines.
f.write(u'\n')
f.write(u'\n')
f.write(u'\n')
f.write(u'\n')


This method is less precise than sending markers via the AMSi USB infrared cable (using the plug-in ), but it could be handy when a subject has to move around freely during an experiment.

Return to Software

Who is online

Users browsing this forum: No registered users and 1 guest