RatInABox-Lab / RatInABox

A python package for modelling locomotion in complex environments and spatially/velocity selective cell activity.
MIT License
175 stars 31 forks source link

Generalise HeadDirectionCells to N directions #19

Closed TomGeorge1234 closed 1 year ago

TomGeorge1234 commented 1 year ago

Currently there are always exactly 4 HDCs encoding the N,E,S,W components of the velocity. It would be better to generalise this to N arbitrary or evenly space directions, perhaps also there could be a angular_spread parameter determining their specificity.

TomGeorge1234 commented 1 year ago

Head direction cells have now been generalised. By default n head direction cells will have direction selectivity preferences of n directions evenly spaced on the unit circle (starting at zero degrees, i.e. along the x-axis, [1,0]). Set these manually with HDCs.preferred_angles.

A new parameter "angular_spread_degrees" determines the width of the selectivity function (default 30 degrees) which is von Mises centred at the direction selectivity angle.

Example:

from ratinabox.Neurons import HeadDirectionCells

Env = Environment()
Ag = Agent(Env)
HDCs = HeadDirectionCells(Ag,params={"n":10,"angular_spread_degrees":30})

while Ag.t < 30: 
    Ag.update()
    HDCs.update()

fig, ax = plt.subplots(1,2,figsize=(5,2))
Ag.plot_trajectory(fig=fig,ax=ax[0])
HDCs.plot_rate_timeseries(fig=fig,ax=ax[1])
Screenshot 2023-01-31 at 10 24 57

Additionally, VelocityCells have been updated so they are now just a scaled subclass of HeadDirectionCells.

Currently this change is enacted on dev branch and will will pushed to 1.x or published soon.