Skip to content

Commit

Permalink
-Add plotting for the first two eigenvectors of
Browse files Browse the repository at this point in the history
STC matrix.
-STC does not work properly, test it further
and increase efficiency.
  • Loading branch information
ycanerol committed May 16, 2017
1 parent fccadd9 commit 17a24b9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
6 changes: 3 additions & 3 deletions LNP_model
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ t = np.arange(0, total_frames*dt, dt) # Time vector
filter_time = .6 # The longest feature RGCs respond to is ~600ms
filter_length = int(filter_time/dt) # Filter is filter_length frames long

cweight = 1 # The weight of combination for the two filters
cweight = .5 # The weight of combination for the two filters


def make_noise(): # Generate gaussian noise for stimulus
return np.random.normal(0, 9, total_frames)
# stimulus=make_noise()
stimulus = make_noise()

filter_index1 = 2 # Change filter type here
filter_index2 = 1
filter_index2 = 3


def linear_filter(t, filter_index): # Define filter according to choice
Expand Down
10 changes: 9 additions & 1 deletion stc.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,17 @@ def stc(spikes, stimulus, filter_length, sta_temp):
# Snippets are inverted before being added
snpta = np.matrix(snippet-sta_temp)
covariance = covariance+(snpta.T*snpta)*spikes[i]
return covariance/(sum(spikes)+filter_length-1)
return covariance/(sum(spikes)*filter_length-1)

recovered_stc = stc(spikes, stimulus, filter_length,
sta(spikes, stimulus, filter_length))
runtime = str(datetime.now()-execution_timer).split('.')[0]
print('Duration: {}'.format(runtime))


w,v = np.linalg.eig(recovered_stc)
# column v[:,i] is the eigenvector corresponding to the eigenvalue w[i]
plt.plot(w, 'o', markersize=2)
plt.show()
plt.plot(v[:,1],'b')
plt.plot(v[:,2],'g')

0 comments on commit 17a24b9

Please sign in to comment.