kpnl:psychopy
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
kpnl:psychopy [2015/03/02 12:07] – admin | kpnl:psychopy [2018/01/21 16:45] (current) – admin | ||
---|---|---|---|
Line 5: | Line 5: | ||
PsychoPy is an open-source application to allow the presentation of stimuli and collection of data for a wide range of neuroscience, | PsychoPy is an open-source application to allow the presentation of stimuli and collection of data for a wide range of neuroscience, | ||
- | ====== Notes on sending digital event codes ====== | + | I have chosen PsychoPy as the primary stimulus presentation software for the lab for a number of reasons: |
+ | - It is free | ||
+ | - It is open-source | ||
+ | - Experiments can be developed in two environments | ||
+ | - '' | ||
+ | - '' | ||
+ | - There is an active and friendly [[https:// | ||
- | | + | Below are notes and tips for building experiments for use in the EEG lab. Many of these tips include using a [[http:// |
+ | |||
+ | <WRAP center round important 80%> | ||
+ | Moving between '' | ||
+ | </ | ||
+ | |||
+ | ====== Tutorials ====== | ||
+ | |||
+ | [[https:// | ||
+ | |||
+ | ====== Miscellaneous Tips ====== | ||
+ | |||
+ | | ||
+ | * There are likely other variable names to avoid, but this is the first I've come across | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | ====== Sending digital event codes ====== | ||
+ | |||
+ | It is critical that we acquire stimulus-locked digital codes so that we can bin the data according to stimulus type during analysis. This is also essential for creating event-related averages of psychophysiological data (e.g. creating ERPs from EEG data) as it gives us the precise onset time of each stimulus. Below is a description of the hardware, software, and steps necessary for sending and acquiring such codes with PsychoPy | ||
+ | |||
+ | |||
+ | ===== Sending an entire byte at once ===== | ||
+ | |||
+ | //The following describes an issue and fix that is relevant for PsychoPy 1.83 and older. This fix will be included in version 1.84 and beyond. For a more detailed description of the issue and resolution see this PsychoPy [[https:// | ||
+ | |forum thread]]// | ||
+ | |||
+ | The code used in PsychoPy | ||
+ | |||
+ | To fix the problem, one needs to modify a little bit of code included in the OS X PsychoPy standalone package. | ||
+ | - Right click on the PsychoPy application and select | ||
+ | - Navigate | ||
+ | - Open the '' | ||
+ | - Replace the class U3 definition | ||
+ | |||
+ | Replace this code: | ||
<code python> | <code python> | ||
- | # The following is the default code created by Builder | + | class U3(u3.U3): |
- | win.callOnFlip(p_port.setData, int(1)) | + | def setData(self, byte, endian=' |
- | # We need to modify | + | """ |
- | win.callOnFlip(p_port.setData, int(1), address=6000) | + | |
+ | parameters: | ||
+ | |||
+ | - byte: the value to write (must be an integer 0:255) | ||
+ | - endian: [' | ||
+ | - address: the memory address | ||
+ | - 6008 = EIO (the DB15 connector) | ||
+ | """ | ||
+ | if endian==' | ||
+ | byteStr = ' | ||
+ | else: | ||
+ | byteStr = ' | ||
+ | [self.writeRegister(address+pin, int(entry)) for (pin, entry) in enumerate(byteStr)] | ||
</ | </ | ||
- | | + | with this code: |
+ | |||
+ | <code python> | ||
+ | class U3(u3.U3): | ||
+ | def setData(self, | ||
+ | |||
+ | """ | ||
+ | |||
+ | parameters: | ||
+ | |||
+ | - byte: the value to write (must be an integer 0:255) | ||
+ | - endian: [' | ||
+ | |||
+ | - address: the memory address to send the byte to | ||
+ | - 6700 = FIO | ||
+ | - 6701 (default) = EIO (the DB15 connector) | ||
+ | - 6702 = CIO | ||
+ | """ | ||
+ | #Upper byte is the writemask, and lower byte is the 8 lines/bits to set. Bit 0 = line 0, bit 1 = line 1, bit 2 = line 2, etc. | ||
+ | self.writeRegister(address, | ||
+ | </ | ||
+ | |||
+ | ==== LabJack Port Addresses ==== | ||
+ | https:// | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | ===== Setting the default LabJack address ===== | ||
+ | |||
+ | <note important> | ||
+ | **The information contained in this box is moot if you use the method above to change the port address** | ||
+ | |||
+ | PsychoPy has a built-in python library to drive the LabJack DAQ device. By default, PsychoPy uses the address for the " | ||
+ | |||
+ | <code python> | ||
+ | def mySetData(self, | ||
+ | if endian==' | ||
+ | byteStr = ' | ||
+ | else: | ||
+ | byteStr = ' | ||
+ | [self.writeRegister(address+pin, | ||
+ | labjacks.U3.setData = mySetData | ||
+ | </ | ||
+ | ===== Initializing the LabJack ===== | ||
+ | |||
+ | ==== Status attribute ==== | ||
+ | | ||
<code python> | <code python> | ||
Line 32: | Line 134: | ||
<code python> | <code python> | ||
p_port.status = [] | p_port.status = [] | ||
- | </ | + | </ |
+ | |||
+ | |||
* The LabJacks will initialize with all bits set to hight (i.e. sending a '' | * The LabJacks will initialize with all bits set to hight (i.e. sending a '' | ||
Line 39: | Line 144: | ||
win.callOnFlip(p_port.setData, | win.callOnFlip(p_port.setData, | ||
</ | </ | ||
- |
kpnl/psychopy.1425316065.txt.gz · Last modified: 2015/03/02 12:07 by admin