-
Notifications
You must be signed in to change notification settings - Fork 63
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
Incorrect tuning curves for unsampled bins #334
Comments
The tuning curves are normalized by occupancy. NaNs represents bin that have never been visited. 0 indicate no spikes. You can see an example here or you can run this code : import numpy as np
import pynapple as nap
import matplotlib.pyplot as plt
dt = 0.1
features = np.vstack((np.cos(np.arange(0, 1000, dt)), np.sin(np.arange(0, 1000, dt)))).T
features = nap.TsdFrame(t=np.arange(0, 1000, dt),d=features)
ts_group = nap.TsGroup({0:nap.Ts(t=[0, 500, 999])})
tcurves2d, binsxy = nap.compute_2d_tuning_curves(
group=ts_group, features=features, nb_bins=10
)
plt.figure(figsize=(12, 6))
plt.subplot(121)
plt.plot(features[:,0], features[:,1])
tmp=ts_group[0].value_from(features)
plt.plot(tmp[:,0], tmp[:,1], 'o')
plt.title("Feature + Spikes")
plt.subplot(122)
extents = (
np.min(features[:,1]),
np.max(features[:,1]),
np.min(features[:,0]),
np.max(features[:,0]),
)
plt.imshow(tcurves2d[0].T, origin="lower", extent=extents, cmap="viridis")
plt.title("Tuning curve")
plt.show() |
I understand, and it seems to be so for 2D tuning curves.
line 141 seems to be setting NaNs to 0. In the 2D version, this line is commented. |
Good catch. In fact, it's quite rare to have a 1d feature that does not span its whole extent. This is high priority so I will bump a new version as soon as possible. Leaving it open until it is resolved. |
New version 0.7.1 is out with a fix to this issue. |
At the moment, when a particular bin of a feature is unsampled, the tuning curve functions will set the average firing rate for that bin to zero.
This seems incorrect?
We do not know if there is no firing for that bin, hence, does it not make more sense to set it to NaN?
The text was updated successfully, but these errors were encountered: