How to voltage clamp a neuron?


I see a voltage-clamp implemented via a large conductance towards the clamp potential in Example: Fig1 — Brian 2 2.4.2 documentation. Is there a more straightforward solution?



That depends a bit on the details… The example tries to model a “realistic” voltage clamp in an experiment. Do you simply want to set the voltage to a fixed value for some time? And should it also be at an arbitrary time, or is it rather for modelling e.g. the refractory period?

I want to test the implementation of a voltage-dependent plasticity model. E.g, I want to have a defined membrane voltage at the time of an incoming spike. Should I exploit Refractoriness — Brian 2 2.4.2 documentation?

Could you explain more what you mean by “a defined membrane voltage at the time of an incoming spike”? You have access to the membrane potentials of the pre- and post-synaptic cells with v_pre and v_post in the on_pre=... statement that gets triggered by an incoming spike, but I assume this is not enough for you?

I want to sweep the membrane potential and check that the plasticity rule does what it’s supposed to do. On second thought it’s Plotting of arbitrary functions - #2 by mstimberg again, but it’s somehow not so nice that I cannot test against my “full model”. It would be good if I don’t have to replace the neuron dynamics equations.

@schmitts, sorry for jumping into the conversation.

It seems you are trying to debug a part of the model (plasticity model) where voltage is a parameter. If so: segregate the plasticity model, make a postsynaptic equation like v = stim(t) : 1, use in plasticity model v_post, and create TimeArray stim with voltage sweep. If you want the voltage to be a constant: just v : 1 and (name of your NeuronGroup).v = (array of voltages to test)

I’m not sure, I got your question right, but above is my standard way to debug a code in Brian. Hope it helps.


I agree that changing the definition of v as proposed by @rth is probably the cleanest solution. If you prefer to keep your equations unchanged and you don’t care that the membrane potential is doing weird stuff before and after the incoming spike (i.e. you are only looking at your plasticity model), you can also directly assign to v_post at the start of your on_pre statements. Either based on some parameter that you add to the synapse or neuron equations, or – if you prefer to not change anything in the equations at all – even based on some calculated expression, e.g. something along the lines of v_post = -100*mV + 100*mV*j/(N_post-1) to test voltage values from -100mV to 0mV based on the post-synaptic index and the total number of cells.