RatInABox-Lab / RatInABox

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

"I" not updated in FeedForward Neurons #99

Closed colleenjg closed 5 months ago

colleenjg commented 6 months ago

I just stumbled upon the fact that the "I" key in the inputs attribute of FeedForward Neurons is initialized with zeros when an input is added, but it is never updated thereafter. Only "I_temp" is updated when get_state() is called.

I'm wondering whether it would be useful to update "I" during the update() step (i.e., when get_state() is called with evaluate_at="last").

For example:

inputlayer["I_temp"] = I
if evaluate_at == "last":
    inputlayer["I"] = I

See https://github.com/RatInABox-Lab/RatInABox/blob/6c8f9c2a6cbb404bcb2222ac63ea4cb9e4b0a4e0/ratinabox/Neurons.py#L2635

colleenjg commented 6 months ago

@TomGeorge1234 Do you recall the rationale behind having "I" in the inputs keys?

TomGeorge1234 commented 6 months ago

Hmm, a quick search suggests it is a hangover from a very early version of FeedForwardLayer (the DendriticCompartment class in this old demo on path integration. It was likely something to do with only wanting to overwrite a variable on a online cell update but not when you plot the rate map etc. offline...or something like that.

As far as I can tell, this doesn't matter and we could get rid of "I_temp" and just have "I". Does this match your understanding?

colleenjg commented 5 months ago

Ah, I see. For my part, the most useful approach would be to update "I" only when .get_state() is called with evaluate_at="last". In this way, "I" would allow us to store the latest input firingrate from each input layer. If we use this approach, then I think we would only need keep "I_temp" if we also want to store the last input firingrates computed using .get_state(), even if it wasn't with evaluate_at="last".

TomGeorge1234 commented 5 months ago

I can't see problem with this. I just pushed a change that should implement that for you. Want to let me know if it works? It's now:

https://github.com/RatInABox-Lab/RatInABox/blob/85f2a370c80eb388e78543026d638631e88c6e24/ratinabox/Neurons.py#L2672-L2677

colleenjg commented 5 months ago

Yeah, that looks good to me!

TomGeorge1234 commented 5 months ago

Great, closing the issue :))