# Description of problem

I would like to create a demo script to show how different neuronal properties affect the neuron’s behavior by runing the simulation for 100ms and change some parameters and run another 100ms. It is fairly easy to do that with whatever variables I defined in the equation. But how do I do that for the properties defined in NeuronGroup()?

# Minimal code to reproduce problem

This is how I do if I want to change the input current. But I cannot find a way to change the parameters like threshold or reset potential, which are defined in NeuronGroup()

``````from brian2 import *

tau = 20*ms
v0 = -0.07
v_reset = -0.07
v_threshold = -0.05

eqs = '''
dv/dt = (I-(v-v0))/tau : 1 (unless refractory)
'''

G = NeuronGroup(1, eqs, threshold='v > v_threshold', reset='v = v_reset', refractory=2*ms, method='exact')
M = StateMonitor(G, 'v', record=True)
G.v=-0.07

I = 0.01
run(100*ms)
plot(M.t/ms, M.v, color='black')
I = 0.05
run(100*ms)
plot(M.t/ms, M.v, color='black')

``````

Sorry if this is too easy. I am relatively new to Brian. I have tried to read through the documentation and browse through this forum as much as I can.

Hi @cclo . I am not sure I understand completely. If you want to change the value for `v_threshold` or `v_reset`, you can do this in the same way as for the current, e.g. like this

``````# ...
run(100*ms)
plot(M.t/ms, M.v, color='black')
v_reset = -0.06
v_threshold = -0.04
run(100*ms)
plot(M.t/ms, M.v, color='black')
`````` Or do you want to change the model, e.g. have something like `v > v_threshold + rand()*0.05` instead of the original expression for the `threshold`? This would not be possible, I am afraid (except with some hacky code).

Yes. That works. I did try it before (changing variable values) but for some unkown (but probably stupid) reason I did not find it work and then I came to the concludsion that NeuronGroup() does not update its setting even you change the associated variable values. Now the problem is solved. Thanks a lot.

1 Like