Holcombe:Programming: Difference between revisions

From OpenWetWare
Jump to navigationJump to search
Line 8: Line 8:


==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
<code>rehash toolbox</code> in MATLAB is <code>reload(modulename)</code> in python
<code>clear all</code> in MATLAB is <code>[vars().__delitem__(_k) for _k in vars().keys() if not _k.startswith('_')]</code> in python
If you are running from python prompt rather than IDE, <code>execfile('myprogram.py')</code> executes codefile
Good syntax guide [http://codesyntax.netfirms.com/lang-python.htm here] ,  Explanation of how default assignment creates reference rather than new variable [http://www.gossamer-threads.com/lists/python/python/617333 here] says to use deepcopy()
[[Holcombe:VerifyTiming]] has some information about playing sounds and associated latencies


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]].
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]].
Line 31: Line 20:
  #### e.g. 'aBindingExpData_04_Aug_2008_22:46'
  #### e.g. 'aBindingExpData_04_Aug_2008_22:46'
</code>
</code>
This shell command to quit finder which can reduce occasional misses of screen refreshes:
osascript -e 'tell application "Finder" to quit'
Here is a file [[Media:Matlab-python-xref.pdf‎]] that gives equivalent code for doing array operations in MATLAB, Python, and R
<code>rehash toolbox</code> in MATLAB is <code>reload(modulename)</code> in python
<code>clear all</code> in MATLAB is <code>[vars().__delitem__(_k) for _k in vars().keys() if not _k.startswith('_')]</code> in python
If you are running from python prompt rather than IDE, <code>execfile('myprogram.py')</code> executes codefile
Good syntax guide [http://codesyntax.netfirms.com/lang-python.htm here] ,  Explanation of how default assignment creates reference rather than new variable [http://www.gossamer-threads.com/lists/python/python/617333 here] says to use deepcopy()


==Data analysis==
==Data analysis==
[[Holcombe:ProgrammingInR| programming in R (data analysis)]]
[[Holcombe:ProgrammingInR| programming in R (data analysis)]]
[[Holcombe:PythonDataAnalysis| Python programming for data analysis]]
[[Holcombe:PythonDataAnalysis| Python programming for data analysis]]

Revision as of 23:07, 8 July 2009

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 and visionegg installation notes .


Python programming

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'

This shell command to quit finder which can reduce occasional misses of screen refreshes: osascript -e 'tell application "Finder" to quit'

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

If you are running from python prompt rather than IDE, execfile('myprogram.py') executes codefile

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

Data analysis

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