Skip to content

Commit

Permalink
hippocampus demo
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin Kiggins committed Oct 17, 2018
1 parent ff25e21 commit d2bd8c0
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
51 changes: 51 additions & 0 deletions examples/plot_rat_hippocampus_foraging.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/env python
"""
Decode location from CA1 activity
==============================
This is an example of how to decode location in a free field from CA1 activity
"""

from neuroglia.datasets import fetch_rat_hippocampus_foraging

dataset = fetch_rat_hippocampus_foraging()

#########################################
# 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.axis('equal')
plt.show()

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

from neuroglia.spike import Binner

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

#########################################
# create feature


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])
plt.show()
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
'pandas',
'xarray',
'scikit-learn',
'requests',
],
classifiers=[
'Development Status :: 2 - Pre-Alpha',
Expand Down

0 comments on commit d2bd8c0

Please sign in to comment.