Stop a certain synapse at a given time

Hi. I want to remove the effect of some of the synapses at a certain time; like they should be working until a certain time and after that they shouldn’t. Is there a straightforward way to do this?
Thank you!

one solution (not sure if it’s the most sensible or efficient) would be to have the synapse parameterized by a weight parameter, then set that weight to 0 at the desired time

1 Like

Hi. I’d say @adam’s solution is the most straightforward. In case you do not want to lose the weight information, an alternative would be to have an additional parameter in your model that is zero or one and gets multiplied with the synaptic action. If you want to deactivate all synapses of a Synapses object, the most efficient way is to set the object’s active attribute to False.

2 Likes

Thank you very much @adam. Do I need to define a function for weight in which the input variable is S.t (synaptic time)?

Thank you very much @mstimberg. Would you mind dumbing it down? :sweat_smile:
Should I check if the simulation time has reached that certain time in an If statement and have that object active to False like S.defined_object.active = False?

I haven’t tested this, so it may need some edits

t_switch_off = 3*second 

@network_operation
def switch_off_synapses(t):
    if t > t_switch_off:
        S.active=False

net.add(switch_off_synapses) # only necessary if you're manually adding components to the network

this sets up an operation to be called at each timestep to check whether you’ve exceeded the threshold time, then sets the synapses active parameter to false.

An alternate implementation would be something like

synapse_model = '''
w : volt
on_off_switch : 1
'''
synapse_on_pre = '''
v += (w*on_off_switch)
'''

S = Synapses(GroupOne, GroupTwo, model=synapse_model, on_pre=synapse_on_pre)
S.on_off_switch = 1 #sets the switch to ON
t_switch_off = 3*second 

@network_operation
def switch_off_synapses(t):
    if t > t_switch_off:
        S.on_off_switch = 0
1 Like

Hi everyone. @adam’s approach with a network_operation is very flexible, since you can do anything you want at any time point, but it is also quite inefficient if you only want to switch things off at a single time point. In such cases you could simply do something along the lines of:

# set up model
# ...
S = Synapses(...)
run(t_switch_off)  # run with synapses switched on
S.active = False
run(t_remaining) # continue with synapses switched off

And the same if you only want to switch off some of the synapses (in that case you’d replace the S.active = False with something more fine-grained, e.g. using @adam’s second code it could be something like S.on_off_switch[:, 0] = 0 #switch off all synapses targetting neuron 0).

2 Likes

Thank you very much adam. Also, in the second part, we do not need to add net.add(switch_off_synapses) at the end of the code?

Thank you very much mstimberg. I actually didn’t know that we could use run command multiple times and it apparently resumes where it left off but with new changes, right?

yeah I think you would need to manually add the network operation with net.add(... if you go with that approach

1 Like

Thanks again for your help :heart:

1 Like

Yes! A few examples use this to switch things on and off, e.g. this one for an input current: Example: Brette_Gerstner_2005 — Brian 2 2.5.4 documentation

1 Like

[Just for your information, I’m moving this thread to the #support section and mark it as answered.]