This is an old revision of the document!
PsychoPy is an open-source application to allow the presentation of stimuli and collection of data for a wide range of neuroscience, psychology and psychophysics experiments. It’s a free, powerful alternative to Presentation™ or e-Prime™, written in Python (a free alternative to Matlab™ ).
Notes on sending digital event codes
- PsychoPy has a built-in python library to drive the LabJack DAQ device. By default, PsychoPy uses the address for the “EI0” DB15 pins (address = 6008). We use the “FIO” terminal blocks so we need to specify the correct address (
6000
). I hope to figure out how to change this default but, in the meantime, see the following code:
# The following is the default code created by Builder win.callOnFlip(p_port.setData, int(1)) # We need to modify the code as follows win.callOnFlip(p_port.setData, int(1), address=6000)
- There seems to be a bug in Builder that results in an attribute of the p_port not being initialized. Running an experiment with LabJack digital codes that was built in Builder will give the following error.
AttributeError:'U3' object has no attribute 'status'
This can be fixed by adding the following code to the start of the script (anywhere after the code that imports the LabJacks module)
p_port.status = NOT_STARTED
Alternatively, you should be able to fix this problem by using the custom code
component, selecting the Begin Routine
tab, and adding the following“
p_port.status = []
We are able to convert a Builder script into a Coder script, but not vice versa. For this reason, we would use the custom code
component for all of these modifications.
- The LabJacks will initialize with all bits set to hight (i.e. sending a
255
code). So you should also add the following code to your script (it can be added right after the code shown above).
win.callOnFlip(p_port.setData, int(1), address=6000)