kpnl:psychopy
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
kpnl:psychopy [2014/11/04 18:19] – 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, | ||
+ | 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 ====== | ||
+ | |||
+ | * Do not use " | ||
+ | * 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 and the BioSemi ActiveTwo system. | ||
+ | |||
+ | |||
+ | ===== 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 send digital codes via the LabJack device sets each bit sequentially, | ||
+ | |||
+ | 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 to / | ||
+ | - Open the '' | ||
+ | - Replace the class U3 definition | ||
+ | |||
+ | Replace 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 | ||
+ | - 6008 = EIO (the DB15 connector) | ||
+ | """ | ||
+ | if endian==' | ||
+ | byteStr = ' | ||
+ | else: | ||
+ | byteStr = ' | ||
+ | [self.writeRegister(address+pin, | ||
+ | </ | ||
+ | |||
+ | 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 ==== | ||
+ | * There seems to be a bug in Builder that results in an attribute of the p_port not being initialized (see psychopy users [[https:// | ||
+ | |||
+ | <code python> | ||
+ | AttributeError:' | ||
+ | </ | ||
+ | |||
+ | This can be fixed by adding the following code to the start of the script (anywhere //after// the code that imports the LabJacks module) | ||
+ | |||
+ | <code python> | ||
+ | p_port.status = NOT_STARTED | ||
+ | </ | ||
+ | |||
+ | Alternatively, | ||
+ | |||
+ | <code python> | ||
+ | p_port.status = [] | ||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | * The LabJacks will initialize with all bits set to hight (i.e. sending a '' | ||
+ | |||
+ | <code python> | ||
+ | win.callOnFlip(p_port.setData, | ||
+ | </ |
kpnl/psychopy.1415143180.txt.gz · Last modified: 2014/11/04 18:19 by admin