Holcombe:Programming: Difference between revisions

From OpenWetWare
Jump to navigationJump to search
No edit summary
No edit summary
Line 7: Line 7:
==Installing Visionegg and Psychopy==
==Installing Visionegg and Psychopy==
*WINDOWS: Psychopy installation. It is easier to intall Enthought Python Distribution that contains all the necessary dependencies than to install at hand one by one the dependencies. Using Enthought, however, I found incompatibilities with Visionegg. Installing the dependencies at hand I did not have problems to run both programs in the same computer.   
*WINDOWS: Psychopy installation. It is easier to intall Enthought Python Distribution that contains all the necessary dependencies than to install at hand one by one the dependencies. Using Enthought, however, I found incompatibilities with Visionegg. Installing the dependencies at hand I did not have problems to run both programs in the same computer.   
*OSX confusingly has two places for Python, /System/Library/... and also /Library/... You want to use /Library version. Some [http://wiki.python.org/moin/MacPython/Leopard python installation instructions]
*OSX confusingly has two places for Python, /System/Library/... and also /Library/... You want to use /Library version. Some [http://wiki.python.org/moin/MacPython/Leopard python installation instructions], [http://stackoverflow.com/questions/118813/how-do-i-uninstall-python-from-osx-leopard-so-that-i-can-use-the-macports-versi related issue]
==Python programming==
==Python programming==
Here is a file [[Media:Matlab-python-xref.pdf‎]] that gives equivalent code for doing array operations in MATLAB, Python, and R
Here is a file [[Media:Matlab-python-xref.pdf‎]] that gives equivalent code for doing array operations in MATLAB, Python, and R

Revision as of 03:20, 15 December 2008

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


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

Mostly the lab uses VisionEgg (also see mailing list and PsychoPy python libraries to help draw stuff.

Our psychopy notes.

Installing Visionegg and Psychopy

  • WINDOWS: Psychopy installation. It is easier to intall Enthought Python Distribution that contains all the necessary dependencies than to install at hand one by one the dependencies. Using Enthought, however, I found incompatibilities with Visionegg. Installing the dependencies at hand I did not have problems to run both programs in the same computer.
  • OSX confusingly has two places for Python, /System/Library/... and also /Library/... You want to use /Library version. Some python installation instructions, related issue

Python programming

Here is a file Media:Matlab-python-xref.pdf‎ that gives equivalent code for doing array operations in MATLAB, Python, and R

rehash toolbox in MATLAB is reload(modulename) in python

clear all in MATLAB is [vars().__delitem__(_k) for _k in vars().keys() if not _k.startswith('_')] in python

Good syntax guide here , Explanation of how default assignment creates reference rather than new variable here says to use deepcopy()

Here Media:AudioAndUSBnotesWithPython.oo3 is the file with all my notes on different ways to play a sound in Python and the associated latencies and standard deviations of the latencies--Alex O. Holcombe 05:15, 25 June 2008 (UTC)

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'

Data analysis

R data analysis

programming in R (data analysis)

Python data analysis

Can be done in Python use SciPy which includes matplotlib (ref)

See the HowTo and Cookbook

loadtxt seems to return recarray explanation