Psychopy
Why PsychoPy?
PsychoPy is an open-source, python-based stimulus presentation software package that can be used as an alternative to PsychToolBox (PTB). It does not have a reliance on Matlab as PTB does, and it has the flexibility to control stimulus presentation by frames based on the screen refresh rate, reducing variability in timing making it much better suited to experiments that rely on timing accuracy (e.g. EEG).
Ease of Use
In Psychopy you can either use the Builder or the Coder Interface to write your stim presentation scripts.
Builder Interface
As their name suggests the Builder Interface is for the user who does not like to write scripts from scratch. It is completely GUI driven and very user friendly. Builder makes it easy to visualize the structure of your experiment, create trial loops, integrate code components, add keyboard responses, present visual stimuli, etc. You can compile the code from Builder (a .psyexp file) and use Coder to view and edit it (.py file).
Coder Interface
This is for the user who loves to write hiss/her own scripts. Coder view is far more powerful since you can use various python modules (such as NumPy, a mathematical module comparable to Matlab) to customize your code and go beyond the limitations of the Builder.
NOTE: When you are satisfied with the experiment you have built in the Builder you can view its script or code in the coder and make changes there and fine tune your experiment. However YOU CANNOT GO BACK to the Builder view from a code view... :( That is the only drawback! I think!
RECOMMENDATION: It is recommended to always build your experiment in the Builder and then "compile", so you have a foundation to work on or tweak in the coder interface.
Tips
Auditory Stimuli
Import the sound package from psychopy before beginning. If possible build your basic Experiment using the Psychopy Builder, compile it as a script and then work from there.
You can set a Frequency of a sound/tone you want to play or provide a link to the sound you want to play.
sound_1 = sound.SoundPygame(value = u'/home/custine/Desktop/Experiments/tones/tone_400Hz.wav')
or
highA = sound.Sound('A',octave=3, sampleRate=44100, secs=0.8, bits=8) highA.setVolume(0.8) tick = sound.Sound(800,secs=0.01,sampleRate=44100, bits=8)#sample rate ignored because already set tick.play()
or
ding = sound.Sound('ding') ding.play()
Visual Stimuli
Using Images as Stimuli
Always save your images as .bmp. JPEGs and PNGs also work though.
Writing trial by trial info into a text file
You may not find the output that psychopy automatically outputs that helpful (with version 1.73, aside from the log file, the other output files were only written when the experiment concluded. If you quit in the middle of a running experiment, you would not have any saved data.) You can instruct Psychopy to write a text output file for your data after each trial shown, so that when you quit midway you have data saved up to that point.
To open a new text file and write header at the beginning:
datFile=open('Data'+os.path.sep+'%s_part%s_subj%s_dat_%s.txt'%(expInfo['expName'],expInfo['session'],expInfo['participant'],expInfo['date']),'w') #customize your output filename datFile.write('participant\tTrialNumber\tdescrip\tIAPS\n') #this is your customizable, tab-delimited header row
Then, at the end of the loop containing your repeating trial (don't forget any indents)!!
#push to dat File datFile.write('%s\t%s\t%s\t%s \n'%(expInfo['participant'],trials.thisTrialN+1,thisTrial.descrip,thisTrial.IAPS))