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

Head direction flexibility #70

Closed
TomGeorge1234 opened this issue Jul 18, 2023 · 1 comment
Closed

Head direction flexibility #70

TomGeorge1234 opened this issue Jul 18, 2023 · 1 comment

Comments

@TomGeorge1234
Copy link
Collaborator

Egocentric representations (e.g. HeadDirectionCells and egocentric BoundaryVectorCells) require the agents head direction to calculate their firing rates. Currently the head direction of the Agent is assumed to just be the normalised velocity. This is a little restrictive. It would be better if there was a separate variable which could, in theory, be independent from velocity. Here's what I propose:

A new variable Agent.head_direction : np.ndarray(shape=(2,). By default Agent.head_direction is updated to be equal to the (normalised) Agent.velocity at each time step. However, if a new input parameter ("head_direction_smoothing_timescale" defaulting to zero) is non-zero then the head direction can be equal to the velocity vector smoothed by an exponential kernel. This should allow head_direction` to be less noisy even if the velocity vector is noisy.

In the future users could generalise this further and even have entirely independent dynamics for the head direction vector.

@TomGeorge1234
Copy link
Collaborator Author

TomGeorge1234 commented Jul 18, 2023

To clarify for @mehulrastogi:

  • Head direction should be a variable called Agent.head_direction.

  • It should be saved to the history dictionary each timestep, just like Ag.pos and Ag.velocity

  • Inside the Agent params dictionary there should be a new param called head_direction_smoothing_timescale : float (in the equation below this is $\tau$). This defaults to $0.0$.

  • Update the doc string to clarify what this param does

  • Within Agent.update() there should be a call to a function called self.update_head_direction(dt)

  • The update rule should be as follows (where $\hat{v}$ is the normalised velocity vector):
    $$hd = (1 - \frac{dt}{\tau}) \cdot hd + \frac{dt}{\tau} \hat{v}$$
    then normalise it
    $$hd = \frac{hd}{|hd|}$$
    Note: you'll need a catch for if $\tau==0$ when the update should just be $hd = \hat{v}$ or else you'll get divide by zero error. Even better would be an additional warning if $\tau$ is non-zero but smaller than $dt$ as this is when the equation breaks down. This warning should strongly advise then to increase $\tau$ or decrease $dt$ to avoid numerical problems but otherwise probably let them go ahead.

  • This change should then reflected in the following Neurons classes which use head direction:

  • ObjectVectorCells
  • BoundaryVectorCells
  • HeadDirectionCells
  • It would be nice to keep support for 1D too even though here head direction is trivial, just a 1D array either [1.0] (forward) or [-1.0] (backwards).

Thanks! Let me know if you run into any troubles

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