Skip to content

Commit

Permalink
basic plot of data
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin Kiggins committed Nov 10, 2018
1 parent bf7d104 commit d6b0d50
Showing 1 changed file with 6 additions and 23 deletions.
29 changes: 6 additions & 23 deletions examples/plot_rat_hippocampus_foraging.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env python
"""
Decode location from CA1 activity
Dataset: CA1 activity during foraging
==============================
This is an example of how to decode location in a free field from CA1 activity
This is an example of how to access data recorded from CA1 during open field foraging
"""

Expand All @@ -15,37 +15,20 @@
# Let's plot the path in the free field

import matplotlib.pyplot as plt
plt.plot(dataset.location['x'], dataset.location['y'], alpha=0.5)
plt.plot(dataset.location['x'], dataset.location['y'])
plt.axis('equal')
plt.show()

#########################################
# Create a feature vector for each time point in the location data
# Create a feature vector, binning spikes for each time point

from neuroglia.spike import Binner

binner = Binner(sample_times=dataset.location['time'])
response = binner.fit_transform(dataset.spikes)
print(response.head())

#########################################
# create feature
# Plot CA1 activity


from sklearn.linear_model import LinearRegression
lm = LinearRegression()

split = int(len(response)/2)

X_train = response.values[:split]
y_train = dataset.location['x'].values[:split]

lm.fit(X_train,y_train)


X_test = response.values[split:]
y_test = dataset.location['x'].values[split:-1]
y_pred = lm.predict(X_test)
plt.plot(y_test[:100])
plt.plot(y_pred[:100])
response.plot()
plt.show()

0 comments on commit d6b0d50

Please sign in to comment.