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

Noisy neurons #22

Closed TomGeorge1234 closed 1 year ago

TomGeorge1234 commented 1 year ago

I will include functionality to add noise to the neuronal firing rates. Currently, if you want noise, you best option is the add it post-hoc to the data obtained from RatInABox.

TomGeorge1234 commented 1 year ago

The ability add noise to neurons has now been added. For example:

Env = Environment()
Ag = Agent(Env)
PCs = PlaceCells(Ag)
PCs_noisy = PlaceCells(Ag,params={
                                'noise_std':0.1, #<-- amount of noise in Hz
                                })
while Ag.t < 20:
    Ag.update()
    PCs.update()
    PCs_noisy.update()
PCs.plot_rate_timeseries()
PCs_noisy.plot_rate_timeseries()
Screenshot 2023-01-31 at 11 49 47

When initialising a neuron class, the parameters params["noise_std"], params["noise_coherence_timescale"] controls how much noise, and the noise coherence timescale is added. Specifically, a randomly evolving noise vector is continually updated according to an Ornstein Uhlenbeck process with standard deviation params["noise_std"], mean of zero, and coherence timescale of params["noise_coherence_timescale"].

Note if the coherence timescale is set very short (the default is currently 0.5s), say, comparable to dt then you will effectively be adding independent noise samples at each timestep. However is the timescale is very large the noise will evolve more slowly.

For example

PCs_slownoise = PlaceCells(Ag,params={'noise_std':0.1, 
                                      'noise_coherence_time':5}) #<-- timescale of noise (5s)
PCs_fastnoise = PlaceCells(Ag,params={'noise_std':0.1, 
                                      'noise_coherence_time':0.1}) #<-- timescale of noise (0.1s)
Screenshot 2023-01-31 at 11 53 36