Holcombe:Programming: Difference between revisions

From OpenWetWare
Jump to navigationJump to search
No edit summary
(48 intermediate revisions by 3 users not shown)
Line 1: Line 1:
To understand Dani's programs, there are two steps.  First, you must learn Spanish. Second, you must learn Python.
{{Template:Holcombe}}


let's try uploading something
==Psychopy==
[[Image:methods.doc]],
Mostly the lab uses [http://www.psychopy.org PsychoPy]. Some are still using VisionEgg. Both are libraries to help python code draw stuff.


Python programming
Some [http://sapir.psych.wisc.edu/wiki/index.php/Psych711 nice easy programming exercises] for Psychopy available from Gary Lupyan, developed for his postgrad psych class.
Dr. Python is good because it checks indentation. Instead of using {} to delimit code blocks, it uses indentation like so:
Get your Psychopy programming questions answered at the [http://groups.google.com/group/psychopy-users mailing list].
if X
  asdf
  asdf


dddd
If you're moving to Psychopy/Python from Matlab, SciPy has a good introduction to [http://www.scipy.org/NumPy_for_Matlab_Users/ Python for Matlab Users], with a big list of equivalent expressions in the two languages.
---Each line needs to be offset by the same number of spaces/tabs. Dr. Python checks to make sure this is true so you're not tripped up by invisible characters like tabs masquerading as spaces


Our [[Holcombe:Psychopy| psychopy and visionegg installation notes]] .
To understand Dani's programs, there are two steps.  First, you must learn Spanish.
==Python programming (outside of the Psychopy editor, as is required for VisionEgg)==
Running python interactively from the Terminal alone is frustrating because you can't use arrow keys for history, no auto-complete, etc. You will probably want to use some [[Holcombe:PythonIDEs| IDE]].
never have your data file overwritten again!  include the following lines in your python code:
<code>
<code>
if X
from time import localtime,strftime
  asdf
timeAndDateStr = strftime("%d_%b_%Y_%H:%M", localtime())
  asdf
filename = 'aBindingExpData_'    #include here whatever you want
filename = filename + timeAndDateStr  #filename will now have date time and year tacked on the end,
outputFileStream = open(filename, 'a')
#### e.g. 'aBindingExpData_04_Aug_2008_22:46'
</code>
</code>
Also don't lose track of what program generated the data, take advantage of sys.argv which gives the invoking program name and include code something like:
<code>
import sys
print >>logF, 'running script "',sys.argv[0],'"'
[http://pages.physics.cornell.edu/~myers/teaching/ComputationalMethods/python/arrays.html scipy array tip sheet]
==Data analysis==
[[Holcombe:ProgrammingInR| programming in R (data analysis)]]
[[Holcombe:PythonDataAnalysis| Python programming for data analysis]]

Revision as of 17:20, 4 July 2012

Recent members

Alex Holcombe
• Ryo Nakayama



Technical

Skills Checklist
Python Programming
Psychopy/VisionEgg Installation Notes
R analysis,plot,stats
Statistics
Buttonbox
Buttonbox with photocell
Programming Cheat Sheets



Psychopy

Mostly the lab uses PsychoPy. Some are still using VisionEgg. Both are libraries to help python code draw stuff.

Some nice easy programming exercises for Psychopy available from Gary Lupyan, developed for his postgrad psych class. Get your Psychopy programming questions answered at the mailing list.

If you're moving to Psychopy/Python from Matlab, SciPy has a good introduction to Python for Matlab Users, with a big list of equivalent expressions in the two languages.

Our psychopy and visionegg installation notes .

To understand Dani's programs, there are two steps. First, you must learn Spanish.

Python programming (outside of the Psychopy editor, as is required for VisionEgg)

Running python interactively from the Terminal alone is frustrating because you can't use arrow keys for history, no auto-complete, etc. You will probably want to use some IDE.

never have your data file overwritten again! include the following lines in your python code:

from time import localtime,strftime
timeAndDateStr = strftime("%d_%b_%Y_%H:%M", localtime())
filename = 'aBindingExpData_'    #include here whatever you want
filename = filename + timeAndDateStr  #filename will now have date time and year tacked on the end,
outputFileStream = open(filename, 'a')
#### e.g. 'aBindingExpData_04_Aug_2008_22:46'

Also don't lose track of what program generated the data, take advantage of sys.argv which gives the invoking program name and include code something like: import sys print >>logF, 'running script "',sys.argv[0],'"'

scipy array tip sheet

Data analysis

programming in R (data analysis) Python programming for data analysis