This is an old revision of the document!
Table of Contents
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
Setting the default LabJack address
- 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
). In order to use the “FIO” terminal we need to add the following custom code component to the beginning our Builder experiment. PsychoPy users thread.
def mySetData(self, byte, endian='big', address=6000): if endian=='big': byteStr = '{0:08b}'.format(byte)[-1::-1] else: byteStr = '{0:08b}'.format(byte) [self.writeRegister(address+pin, int(entry)) for (pin, entry) in enumerate(byteStr)] labjacks.U3.setData = mySetData
Initializing the LabJack
Status attribute
- 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)