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

Can't get firingrate when using import_trajectory with interpolate=False #114

Closed
PikaPei opened this issue Aug 17, 2024 · 2 comments
Closed

Comments

@PikaPei
Copy link

PikaPei commented Aug 17, 2024

Hi Tom,

Great to see RatInABox has become so wonderful!

I have a question:
When I used Ag.import_trajectory with interpolate=False, I would get nan values in neuron output firingrate list.

Here is an example:

from ratinabox.Environment import Environment
from ratinabox.Agent import Agent
from ratinabox.Neurons import *

dt = 0.01

Env = Environment(params={"dx": 0.001})

Ag = Agent(Env)

times = [0.01, 0.02, 0.03, 0.04, 0.05]
positions = [[0.1, 0.1], [0.2, 0.2], [0.3, 0.3], [0.4, 0.4], [0.5, 0.5]]
Ag.import_trajectory(times=times, positions=positions, interpolate=False)

PCs = PlaceCells(Ag)

for i in range(int(times[-1] / dt)):
    Ag.update(dt=dt)
    PCs.update()

print(PCs.history["firingrate"])

I also tried interpolate=True, but I got weird values from the beginning and the end of Ag.history["vel"].
I haven't figured out how to control it, so I change to interpolate=False.
Thank you!

@TomGeorge1234
Copy link
Collaborator

Good spot. It was a small bug originating from the fact that dt is calculated on the fly when interpolation=False but the initial time is offset to zero, as is self.t, giving dt=0 and some divide-by-error errors when trying to calculate speeds etc.

Should be fixed now in version v1.14.1, let me know if you think otherwise.

@TomGeorge1234
Copy link
Collaborator

marking as closed for now

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

2 participants