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

Integrated tuning distributions BVC class #46

Closed jquinnlee closed 1 year ago

jquinnlee commented 1 year ago

Integrated tuning distribution options to determine preferred wall distances from params argument "pref_wall_dist_distribution". Allows user to select from uniform (new default), Rayleigh (previous default), normal, and delta distributions that will be used to generate wall distances for all BVCs in this class.

jquinnlee commented 1 year ago

Hey Tom,

Before I push any changes can you clarify the concern further? If I were to use: np.uniform(low=0, high=-.15, size=10) this will return 10 values uniformly distributed (flat) between 0 and -.15.

To get around the possible issue withself.Agent.Environmnet.scale in those environments with weird aspect ratios and allowing negative values for self.pref_wall_dist(which I think your wanting to allow?), what would you think of this:

if self.pref_wall_dist_distribution == 'uniform':
            dists = np.array([self.Agent.Environmnet.scale, self.pref_wall_dist * 2])
            self.tuning_distances = np.random.uniform(low=0, high=dists[np.argmin(np.abs(dists))], size=self.n)

Let me know if I am understanding your concerns or not, happy to make whatever changes meet your goals! The main concern I have with the function you suggested is that it will return a truncated normal distribution, and not a uniform distribution (which is the option I suggest adding).

TomGeorge1234 commented 1 year ago

Oh sorry!! I mean the "normal" not the "uniform" option. The "normal" function could return a negative wall preference which mustn't be allowed.

So the uniform option should just be as you wrote it but with wall_pref_dist instead of self.Agent.Environment.scale:

if self.pref_wall_dist_distribution == 'uniform':
            self.tuning_dists = np.random.uniform(low=0,high=wall_pref_dist, n=self.n)
if self.pref_wall_dist_distribution == 'normal':
          # the code I wrote in my first response using scipy.truncnorm 

My bad, apologies for the confusion

TomGeorge1234 commented 1 year ago

closing, instead merged #47