-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Justin Kiggins
committed
Oct 17, 2018
1 parent
ff25e21
commit d2bd8c0
Showing
2 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters