MatLab has some interesting functions not in Python, or so I believe.
MatLab has a function "find" that when passed a vector returns a vector containing the indices of the non-zero values. In Python one has to use a comprehension to do the same with a list.
MatLab:
a=[10 20 0 30]
find(a)
Python:
a=[10, 20, 0, 30]
[i for (i,v) in enumerate(a) if v!=0]
This begins to highlight MatLab's basic concept of vectors and matrices as opposed to Python's implementation of lists. If you want to work more naturally with vectors in Python you need to import numpy. Without importing numpy one has to do things like this:
MatLab:
a=[1 2 3 4]
a(a > 2)
b=find(a > 2)
x=1
a(b-x)
mean(a)
sin(a)
Python:
a=[1,2,3,4]
[v for v in a if v > 2]
b=[i for (i,v) in enumerate(a) if v > 2]
x=1
[a[i-x] for i in b]
float(sum(a))/len(a)
import math
map(math.sin,a)
So when trying to find the Spike Triggered Average I was glad I was working in Octave rather than Python. The Spike Triggered Average averages the postsynaptic potential, I suppose at the soma, for some arbitrarily sliced length of time prior to neuron producing spikes when exposed to Gaussian white noise. By graphing the STA one can sometimes spot features that tells one something about what the neuron is doing.
No comments:
Post a Comment