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

Egocentric BVCs, KeyError: 'vel' #18

Closed CYHSM closed 1 year ago

CYHSM commented 1 year ago

Thanks for the amazing toolbox. I was just trying to create some egocentric BVCs and I received the following error: Code:

BVCs = BoundaryVectorCells(Ag, params={"n": num_neurons, "color": "C3", "reference_frame": "egocentric"})

Error:

File ~usr/local/lib/python3.8/dist-packages/ratinabox/Neurons.py:908, in BoundaryVectorCells.__init__(self, Agent, params)
    906 locs = locs.reshape(-1, locs.shape[-1])
    907 self.cell_fr_norm = np.ones(self.n)
--> 908 self.cell_fr_norm = np.max(self.get_state(evaluate_at=None, pos=locs), axis=1)
    910 if verbose is True:
    911     print(
    912         "BoundaryVectorCells (BVCs) successfully initialised. You can also manually set their orientation preferences (BVCs.tuning_angles, BVCs.sigma_angles), distance preferences (BVCs.tuning_distances, BVCs.sigma_distances)."
    913     )

File ~usr/local/lib/python3.8/dist-packages/ratinabox/Neurons.py:984, in BoundaryVectorCells.get_state(self, evaluate_at, **kwargs)
    982     vel = self.Agent.pos
    983 else:
--> 984     vel = kwargs["vel"]
    985 vel = np.array(vel)
    986 head_direction_angle = utils.get_angle(vel)

KeyError: 'vel'
TomGeorge1234 commented 1 year ago

Thanks again for pointing it out. Fixed this.

It should be ready to go if you reinstall RatInABox from dev branch now. This will get merged to 1.x and PyPI published at next version sometime quite soon.

The latest version of RatInABox (v1.1.0 on PyPI) should include this fix.

Could you confirm you don't experience any issues then I'll close

TomGeorge1234 commented 1 year ago

Pretty sure this is fixed and pushed to the new version 1.1.0. Reopen if necessary!