Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

consider using a gaussian KDE to estimate spatial rate #16

Open
lepmik opened this issue Dec 7, 2020 · 1 comment
Open

consider using a gaussian KDE to estimate spatial rate #16

lepmik opened this issue Dec 7, 2020 · 1 comment

Comments

@lepmik
Copy link
Member

lepmik commented Dec 7, 2020

scipy.stats.gaussian_kde

@lepmik
Copy link
Member Author

lepmik commented Feb 23, 2021

Working example, but has issues with edges, consider using some these boundary conditions

from scipy.interpolate import interp1d
from scipy.stats import gaussian_kde

sx = interp1d(t, x)(spike_times)
sy = interp1d(t, y)(spike_times)
    
X, Y = np.meshgrid(xbins, ybins)
positions = np.vstack([X.ravel(), Y.ravel()])

xy = np.vstack([x, y])
s_xy = np.vstack([sx, sy])

bw = 0.2

kernel = gaussian_kde(s_xy, bw_method=bw)
smap = np.reshape(kernel(positions), X.shape)

kernel = gaussian_kde(xy, bw_method=bw)
omap = np.reshape(kernel(positions), X.shape)

omap = np.flipud(np.rot90(omap))
smap = np.flipud(np.rot90(smap))
rmap = smap / omap

fig, (ax1, ax2, ax3) = plt.subplots(1,3)
ax1.imshow(omap)
ax2.imshow(smap)
ax3.imshow(rmap)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant