Description of problem
Howdy Y’all,
I have a very specific use case. I have been dynamic clamping with brian2 with somewhat decent results.
However, I was testing a configuration where I would brute force build a hybrid network by overwriting the membrane potential of an in slico neuron with the membrane potential of my clamped in vitro neuron. I accomplished this by running a run_regularly call every timestep to write to the membrane potential variable.
However, I’ve encountered an issue: when the neuron spikes, the run_regularly function stops executing for a few time steps. This behavior only occurs when the variable being overwritten (the membrane potential) has the unless refractory flag set.
Minimal code to reproduce problem
from brian2 import *
#run standalone
device = get_device()
set_device('cpp_standalone', build_on_run=True)
#ramp volt
voltage = np.arange(-70, 0, 0.01)
input_volt = TimedArray(voltage*mV, dt=0.01*second)
Eqs = Equations('''
dv/dt = 0*mV/ms: volt (unless refractory)
Vcut : volt
''')
P = NeuronGroup(1, model=Eqs, threshold='v>Vcut', refractory='v>Vcut', method='euler')
P.run_regularly("v = input_volt(t)", dt=0.1*ms)
M = SpikeMonitor(P)
M2 = StateMonitor(P, ['v'], record=True)
P.Vcut = -30*mV
run(60*second, report='text')
What you have aready tried
-Removing the unless refractory flag does fix it.
Expected output (if relevant)
Neuron membrane potential climbs from -70 to 0
Actual output (if relevant)
Neuron membrane potential climbs from -70 to -30, where it gets stuck