Abstract
In a single-electrode current-clamp recording, the measured potential includes both the response of the membrane and that of the measuring electrode. The electrode response is traditionally removed using bridge balance, where the response of an ideal resistor representing the electrode is subtracted from the measurement. Because the electrode is not an ideal resistor, this procedure produces capacitive transients in response to fast or discontinuous currents. More sophisticated methods exist, but they all require a preliminary calibration phase, to estimate the properties of the electrode. If these properties change after calibration, the measurements are corrupted. We propose a compensation method that does not require preliminary calibration. Measurements are compensated offline by fitting a model of the neuron and electrode to the trace and subtracting the predicted electrode response. The error criterion is designed to avoid the distortion of compensated traces by spikes. The technique allows electrode properties to be tracked over time and can be extended to arbitrary models of electrode and neuron. We demonstrate the method using biophysical models and whole cell recordings in cortical and brain-stem neurons.
Keywords: electrode compensation, intracellular recording, patch-clamp, current-clamp
intracellular recordings in slices have been used for decades to probe the electrical properties of neurons (Brette and Destexhe 2012). These recordings are done using either sharp microelectrodes or patch electrodes in the whole cell configuration. In both cases, when a single electrode is used to pass the current and to measure the potential, the measurement is biased by the electrode. As a first approximation, the electrode can be modeled as a resistor (resistance Re). Thus the measurement is the sum of the membrane potential (Vm) and of the voltage across the electrode, which, by Ohm's law, is Re.I for a constant injected current I (in the current-clamp configuration). Therefore, the distortion due to the electrode can be significant when the electrode resistance is high compared with the membrane resistance. Sharp microelectrodes have a thin tip and therefore a high resistance (Purves 1981). The resistance of patch electrodes is usually lower, since the tip is wider, but it may be high in some situations, for example in vivo (Anderson et al. 2000; Wehr and Zador 2003) or in dendrites (Angelo et al. 2007; Davie et al. 2006) and axons (Shu et al. 2007). Perforated patch-clamp recordings, in which the membrane is perforated by antibiotics in the electrode solution to avoid cell dialysis, also have high access resistance. Low-resistance electrodes are also an issue in cells with low membrane resistance. Finally, in very long patch recordings with low-resistance electrodes, the electrode often clogs up with time, which increases the resistance.
Thus it is often necessary to compensate for the electrode bias in single-electrode recordings. The standard compensation technique is bridge balance and is generally done directly on the electrophysiological amplifier. It consists of subtracting Re.I from the uncompensated recording where Re is the estimated electrode resistance (usually manually adjusted using the response to current pulses). There are two issues with this method. First, even if Re can be accurately estimated, the electrode is not a pure resistor: it has a nonzero response time due to capacitive components. This produces artifacts in the compensated trace, as shown in Fig. 1. When a current pulse is injected (Fig. 1, top left), the bridge model overcompensates the trace at the onset of the pulse, resulting in capacitive transients of amplitude Re.I (Fig. 1, middle left). These transients become an issue when fast time-varying currents are injected, such as simulated synaptic inputs (Fig. 1, top right). In this case, capacitive transients distort the compensated trace, which may even make the detection of action potentials difficult (Fig. 1, middle right). The second issue is that the capacitive component of the electrode can make the estimation of Re difficult, given that Re cannot be estimated in the bath (it changes after impalement).
Fig. 1.

Bridge and dynamic electrode compensation methods illustrated on a patch-clamp recording in a pyramidal neuron from mouse auditory cortex. Top: injected current, starting with a current step for calibrating the bridge compensation method (left) and followed by a fluctuating current with fast transients (current B, right). Middle: bridge compensated membrane potential. Bottom: compensated trace using our technique.
A recent technique solves this problem by calibrating a model of the electrode using white noise current (Brette et al. 2008). However, as with other methods, the recordings may be corrupted if electrode properties change after calibration. To address this issue, we propose a model-based method to compensate current-clamp recordings, which does not require preliminary calibration. Instead, the electrode model is fitted offline, using the recorded responses to the injected currents, with a special error criterion to deal with neuron nonlinearities and spikes. An example of compensated trace is shown in Fig. 1 (bottom). The technique is demonstrated with biophysical neuron models and current-clamp recordings of cortical and brain-stem neurons. We also propose quantitative tests to evaluate the quality of recordings.
METHODS
Experimental Preparation and Recordings
We recorded from pyramidal cells in slices of the primary auditory cortex of mice [aged postnatal days 9–15 (P9–15)], at room temperature (25 ± 2°C), as detailed in Rossant et al. (2011c). Mice of the CBA strain aged P9–15 were decapitated under sodium-pentobarbital anesthesia in conformity with the rules set by the European Commission Council Directive (86/89/ECC) and approved by the local Swedish Animal Care and Use Committee (Permits N13/10 and N71/10). We then recorded from pyramidal cells in slices of the primary auditory cortex of mice at room temperature (25 ± 2°C), as detailed in Rossant et al. (2011c). In addition, we recorded from the ventral cochlear nucleus in mice brain-stem slices (aged P10). The principal cells of the cochlear nucleus were identified based on their voltage responses to de- and hyperpolarizing (h-) current pulses (Fujino and Oertel 2001). Whole cell current-clamp recordings were done with a MultiClamp 700B amplifier (Axon Instruments, Foster City, CA) using borosilicate glass microelectrodes with a final tip resistance of 5–10 MΩ. The pipette capacitance compensation was applied by using the amplifier circuits, but we did not apply bridge balance on the amplifier. The signals were filtered with a low-pass four-pole Bessel filter at 10 kHz, sampled at 20 kHz, and digitized using a Digidata 1422A interface (Axon Instruments). To test that the electrode compensation method correctly distinguishes electrode and neuron resistance (see Compensation of Cortical Recordings), we increased the neuron input resistance by applying the h-current blocker ZD 7288 (10 μM) to the slice bath. A small-moderate blockade of Ih, which is a large contributor of the input resistance of all cells in the ventral cochlear nucleus (Cao and Oertel 2011), gave rise to significant increases of the input resistance without affecting the spiking properties.
Electrode Compensation
We consider a linear model of the neuron and electrode. Each element is modeled as a resistor + capacitor (RC) circuit (see Fig. 2A). The equations are:
where I is the input current, Iinj is injected current, Vneuron is the Vm of the neuron, Ue is the voltage across the electrode, τm and τe are the membrane and electrode time constants, R and Re are the membrane and electrode resistance, and Vr is resting potential. The five parameters are adjusted to minimize the LP error between the model prediction, Vmodel, and the raw (uncompensated) measured trace, Vraw:
where P is a parameter (P = 0.5 is a good choice). After optimization, the compensated Vm of the cell is Vraw−Ue.
Fig. 2.

The calibration-free electrode compensation technique. A: overview of the technique. An input current is injected into a real neuron during a current-clamp in vitro recording (top). The raw trace recorded by the electrode (gray) includes the responses of both the neuron and the electrode. Simultaneously, the current (I, Iinj) is injected into a linear (nonspiking) model of the neuron and electrode (bottom). The model parameters are adjusted by an optimization procedure so as to minimize the LP error (see text) between the model trace (black) and the raw trace (gray). The model is then used to predict the electrode response and subtract it from the raw trace, yielding the compensated trace. Vmodel, membrane potential of the model prediction; Vneuron, membrane potential of the neuron; Ue, voltage across the electrode. B: compensation example. Left: raw trace (gray, filtered noise current) and full model trace (black). Right: compensated trace. C and D: compensation of large excitatory postsynaptic potentials (EPSPs) and action potentials using the mean squared error (P = 2). Left: raw (gray) and model (black) traces on a current with fast and large excitatory postsynaptic currents (current B). The inset shows a zoom on an EPSP followed by an action potential: the model overestimates the EPSP because of the spike. Right: the compensated trace, showing distorted EPSPs and action potentials. The histogram of the differences between raw trace and optimized model trace (right) peaks below 0 mV because of the long positive tail due to action potentials. E and F: same as C and D but with P = 0.5. This error criterion gives less weight to outliers such as action potentials, leading to a better estimation of the membrane potential. R, neuron resistance; Re, electrode resistance.
To perform the optimization, we use the downhill simplex algorithm (implemented as function fmin in the SciPy numerical library for Python). Since the equations are linear, the model prediction is computed by applying a two-dimensional linear filter to the injected current (see appendix). Although we used the simple model above in this paper, it may be replaced by more complex models by simply specifying the model equations in our tool. The corresponding linear filter is automatically calculated from the differential equations of the model (see appendix). For the case when the equations are not linear, we also implemented a more complex method using a generic model fitting toolbox (Rossant et al. 2011b) based on the Brian simulator (Goodman and Brette 2009) for the model simulation and on the parallel computing library Playdoh (Rossant et al. 2011a) for the optimization. Initial parameters for the optimization can be selected by the user. A good practice is to use the estimated parameters for the initial part of a recording as initial parameters for the subsequent part.
The electrode compensation software is freely available as part of the Brian simulator (http://briansimulator.org).
Currents
We injected three different types of time-varying currents.
Filtered noise.
This is a low-pass-filtered noise (Ornstein-Uhlenbeck process) with 10-ms time constant.
Current A.
This corresponds to current A in Rossant et al. (2011c). It is a sum of a background noise and exponentially decaying postsynaptic currents (PSCs). The background noise is an Ornstein-Uhlenbeck process (i.e., low-pass-filtered white noise) with time constant τN = 10 ms. The PSCs occur every 100 ms with random size: PSC(t) = αwe−t/τs, where τs = 3 ms, α = 665 pA is a scaling factor, and w is a random number between 0.04 and 1.
Current B.
This corresponds to current B in Rossant et al. (2011c). It is a sum of random excitatory and inhibitory PSCs (with time constants τe = 3 ms and τi = 10 ms, respectively) with Poisson statistics, in which “synchrony events” are included. These events occur randomly with rate λc, and for each event we pick P excitatory synapses at random and make them simultaneously fire.
Biophysical Model
In Fig. 4, we tested the compensation method in a model consisting of a neuron and an electrode. The electrode is modeled as an RC circuit. The neuron model is a biophysical single-compartment model of a type 1c neuron of the ventral cochlear nucleus, as described in Rothman and Manis (2003). The same model is used in Fig. 3A.
Fig. 4.

Test of the electrode compensation method in a biophysical model of a cochlear nucleus neuron (Rothman and Manis 2003; resistance ∼500 MΩ, time constant ∼5 ms) with a nonideal electrode (Re = 50–500 MΩ, time constant τe = 0.1 ms). A, top: a 1-s fluctuating current with large and fast transients (set 3) is injected into the biophysical model (Re = 500 MΩ). Middle: raw (gray) and fitted model (black) traces using our compensation technique (P = 0.5). The fitting procedure finds Re = 480 MΩ and τe = 0.1 ms. Bottom: compensated trace (black) and biophysical neuron model trace (dashed gray), showing a perfect fit (inset). B: scatterplot of the model and fitted Re values using 3 different 1-s currents (○: set 1, +: set 2, x: set 3; see methods) and 4 different Re values (50, 100, 200, and 500 MΩ). C: Re and R values found by the compensation technique when the actual resistance is Re = 100 MΩ (dashed line) as a function of P (current from set 1).
Fig. 3.

Robustness of the compensation method to changes in R or Re. A: estimated R (dots) and Re (crosses) in a simulated recording with a varying Re. The Rothman and Manis (2003) neuron model (type 1c) and an electrode model are simulated with a 20-s filtered noise current. After 10 s, Re is increased abruptly from 100 to 300 MΩ during the last 10 s (dashed step: actual value of Re). B: estimated R and Re in an in vitro recording with a hyperpolarization-activated current (Ih) blocker. Filtered noise current is injected into a bushy cell for 8 min. The Ih blocker ZD 788 (10 μM) is applied to the bath during the 2nd half of the stimulation, which increases R. Dotted lines are linear regressions of the estimated R in the 2 parts of the experiment.
We used three sets of currents. Set 1 is a filtered noise, which makes the neuron fire at 1–5 Hz. Set 2 is current B with P = 15 and λc = 5 Hz, which makes the neuron fire at 5–7 Hz. Set 3 is the same as set 2 but scaled to make the neuron fire at 15–20 Hz.
Spike Detection
To detect spikes in compensated traces (Fig. 5), we 1st detect all times at which dV/dt changes sign and register the value of V at these times. We build a histogram of these values (20 bins in our recordings) and split it in 2 modes according to a decision threshold that is automatically determined as follows. We 1st discard all values below the median to increase robustness. We then look at local minima in the histogram. If there is none, the middle between the median and the highest value is taken as the decision threshold. If there is only one, it is chosen as the decision threshold. If there are two or more, the detection threshold is either the middle of the longest sequence of identical local minima or the smallest local minimum. More sophisticated clustering methods could also be used, but this simple approach proved sufficient for our recordings.
Fig. 5.

A method for spike detection in an intracellular recording. A: a 30-s compensated recorded trace of a pyramidal cell in vitro, seen in phase space (dV/dt vs. V), for a filtered noise injected at the soma. Large cycles correspond to spikes. B: distribution of voltage values measured when the trajectory in phase space (A) crosses the horizontal dashed line dV/dt = 0 (local maxima and minima). Two modes appear, corresponding to fluctuations (left) and spike peaks (right). An optimal separatrix between the 2 modes is calculated (dashed vertical line). The 2 modes in the histogram are fitted to Gaussian distributions, which are used to quantify spike detection quality. C: an example of spikes detected with this method on a compensated trace (solid line). The dashed line indicates the decision threshold, and detected spike peaks are shown with filled circles.
Voltage values in the histogram are considered as spike peaks when their voltage is greater than the decision threshold. Spike detection quality can be directly assessed from the separation of the two modes using signal detection theory. Assuming that the two modes are normally distributed, we can calculate the probability that a spike peak is successfully detected (true positive) and the probability that a subthreshold peak is mistakenly classified as a spike peak (false positive) according to the following equations:
where TP/P and FP/N are the true and false positive rates, is the cumulative distribution function of a Gaussian distribution, Vs is the detection threshold, and μ1, μ2, σ2, and σ2 are the parameters of the two distributions. Spike detection is reliable when TP/P is close to 1 and FP/N is close to 0.
Quality Coefficient
A quality coefficient is calculated to assess the quality of electrode compensation based on the idea that the voltage at spike peak should not depend on the current injected after spike initiation (Fig. 6). First, we try to predict the voltage at spike peaks based on the voltage before spike initiation. For each spike, a linear regression is performed on the compensated trace in a temporal window from 10 to 2 ms before spike peak. We then compute the best linear prediction of the spike peak given the two regression parameters (intercept and slope). The quality coefficient is defined as the Pearson correlation between the prediction error and the mean input current around spike peak (2 ms before to 1 ms after).
Fig. 6.

Control of electrode compensation using spike peaks. A: illustration of the method. For each spike, a linear regression is performed on the compensated trace (top, black; uncompensated trace is in gray) in a temporal window from 10 to 2 ms before spike peak. We then compute the best linear prediction of the spike peak given the 2 regression parameters (intercept and slope). The quality coefficient is defined as the Pearson correlation between the prediction error and the mean input current around spike peak (2 ms before to 1 ms after; gray horizontal line on the bottom trace). B: LP error between the model trace and the measured trace, as a function of the model R and Re, with all other parameters fixed at their optimal values. The parameter values giving minimum error are represented by the cross. C: quality coefficient as a function of the model R and Re, with the best parameters represented by the cross.
Two-Compartment Model
In Fig. 7, we simulated a pyramidal neuron model with two compartments representing the soma and dendrites (Wang 1998) with a filtered noisy current injected at the soma. The electrode is modeled as an RC circuit with Re = 200 MΩ and τe = 0.2 ms. In Fig. 7B, the model used for compensation also has a dendritic current following the electrical circuit shown in the figure.
Fig. 7.

Test of the method with a 2-compartmental neuron model. A: a pyramidal neuron model with 2 compartments (soma and dendrite) and a linear electrode are simulated with a filtered white noise-injected current. The recorded trace (gray) is then compensated with our method (P = 0.5). The compensated trace (solid black) matches the neuron voltage (dotted) except for spikes that are filtered by the electrode. B: the same trace is compensated, but the compensation model now includes a dendritic current.
Adaptive Threshold Model
In Fig. 8, E–G, we used an exponential integrate-and-fire neuron model (Fourcaud-Trocmé et al. 2003) with adaptive threshold as described in Platkiewicz and Brette (2010, 2011). The membrane equation describing the dynamics of the membrane potential V contains a leak current and an exponential approximation of the sodium current:
where τm = 5 ms is the membrane time constant, El = −70 mV is the leak reversal potential, Δ = 1 mV characterizes the sharpness of spike initiation, and Rm = 100 MΩ is the membrane resistance. The voltage diverges quickly to infinity once it exceeds the dynamic threshold θ, which adapts to V through the following equation based on an analysis of sodium inactivation dynamics in Hodgkin-Huxley models:
where θ∞(V) = VT − kalogh∞(V) is the steady-state threshold, determined by VT = −67 mV, the minimum threshold, ka = 4.3 mV is the Boltzmann factor of the sodium activation function, and h∞ is the inactivation function:
where Vi = −69 mV is the half-inactivation voltage of sodium channels. These values ensure that the spike threshold is variable (Platkiewicz and Brette 2011).
Fig. 8.

Spike threshold measurements in a stellate cell of the cochlear nucleus. A: compensated voltage trace of a stellate cell in response to an injected fluctuating current. Spike thresholds are measured as the membrane potential when the 1st derivative exceeds 1 V/s (dots). B: spike threshold as a function of depolarization rate in the 10 ms preceding each spike when the trace is not compensated (dashed line: linear regression). C: same relationship in the bridge compensated trace. D: same relationship in the trace compensated with our method. E: simulated recording with a neuron model with adaptive spike threshold and an electrode model (Re = 60 MΩ and τe = 0.6 ms). The uncompensated recording is the solid gray curve, the compensated recording the solid black curve. The real membrane potential is shown in dotted gray, but at this scale it is only distinguishable after spikes. The dynamic spike threshold is the dashed black curve. F: spike threshold measured at spike times in the uncompensated recording vs. actual spike threshold. G: spike threshold measured at spike times in the compensated recording vs. actual spike threshold (note the different vertical scale).
RESULTS
Principle
The principle is illustrated in Fig. 2A. A time-varying current is injected into the neuron, and the raw (uncompensated) response (neuron + electrode) is recorded. We try to predict this response with a model including both the neuron and electrode. We used a simple linear model for both elements (resistor + capacitor), but it could be replaced by any parametric model. We calculate the prediction error, and we adjust the model parameters so as to reduce the error. The process is iterated until the error is minimized. When the model trace is optimally fitted to the raw recorded trace, we subtract the predicted electrode voltage from the raw trace to obtain the compensated trace.
Figure 2B shows an example of successful compensation. The optimized model trace (left, solid) tracks the measured trace (gray) but not with perfect accuracy. In particular, the action potential is not predicted by the model, which was expected since the model is linear. This is not a problem since we are only interested in correctly predicting the electrode response, which is assumed to be linear, to subtract it from the raw trace. Therefore, it is not important to predict neuronal nonlinearities as long as they do not interfere with the estimation of the electrode response. Figure 2B (right) shows the compensated trace, which is the raw trace minus the electrode part of the model response.
However, neuronal nonlinearities, for example action potentials, may interfere with the estimation of the electrode model, as is illustrated in Fig. 2C. Here, the neuron fired at a higher rate. The model parameters are adjusted to minimize the mean squared error between the model trace and the raw trace (left). To account for spikes, the linear model overestimates the electrode response (left, inset). As a result, the compensated trace is heavily distorted (right traces). The distribution of the difference between raw trace and model trace (Vraw−Vmodel) is shown on the right. The mean is 0, by construction, because the model minimizes the mean squared error. However, the histogram peaks at a negative value, which means that most of the time the model overestimates the raw trace. This is balanced by a long positive tail due to the spikes.
To solve this problem, we replace the mean square error by a different criterion which reduces the influence of this long tail, that is, of “outliers.” Instead of minimizing the mean of (Vraw−Vmodel)2, we minimize the mean of |Vraw−Vmodel|P, where P < 2. This is called the LP error criterion. In this way, the error is compressed so that large deviations (action potentials) contribute less to the total error. The result is shown in Fig. 2D with P = 0.5. The compensated trace is now much less distorted, and the distribution of differences between model and raw traces peaks near 0.
Validation with a Biophysical Model
We first test the method using a biophysical neuron model together with an RC model of the electrode (Fig. 4). To evaluate our method in a challenging situation, we used a highly nonlinear single-compartment model of cochlear nucleus neurons (Rothman and Manis 2003), which includes several types of potassium channels. This biophysical model is used to generate the raw traces but not to compensate them. That is, we still fit a simple linear model to the raw traces. The electrode time constant was τe = 0.1 ms compared with a membrane time constant of ∼5 ms.
We injected fluctuating currents (see methods) into the electrode (Fig. 4A, top) consisting of a mixture of background filtered noise and large random PSCs. Here, the neuron and electrode resistances were comparable (∼500 MΩ), and therefore the uncompensated recording was highly corrupted by the electrode (middle, gray). The solid trace shows the fit of the linear model to the raw trace (with P = 0.5). Once the electrode part of the linear model is subtracted, the compensated trace is hardly distinguishable of the true Vm of the biophysical neuron model (bottom).
We varied Re between 50 and 500 MΩ and tested the compensation technique with three different types of currents to vary the output firing rate of the neuron (between 1 and 20 Hz). In all cases, the electrode resistance was very well-estimated by the method (Fig. 4B). We then tested the influence of the error criterion (Fig. 4C). Using the mean squared error (P = 2) clearly gave inferior results even when the cell spiked at low rate. This is presumably because the neuron was highly nonlinear, which perturbed the estimation of the electrode. Best results were obtained with P ≤ 0.5 with no significant improvement below P = 0.5. Noise in real recordings could degrade performance for very low values of P, and therefore we suggest to use P = 0.5 in general.
Compensation of Cortical Recordings
We then injected fluctuating currents with large transients into cortical neurons in vitro (pyramidal cells of the mouse auditory cortex) using high-resistance patch electrodes. Because of these transients, raw traces were noisy and spikes could not be clearly distinguished (Fig. 9A, top). After compensation, traces were smoother and spikes stood out very clearly (bottom).
Fig. 9.

Test of the compensation method on real data. A: a fluctuating current (current B) is injected into a neuron of the mouse auditory cortex during a patch-clamp experiment. Top: raw recorded trace. Bottom: compensated trace. B: a 590-s long fluctuating current (current A, mean 10 pA, standard deviation 30 pA) is injected into a neuron. The trace is divided in 1-s windows, and the fitting procedure is applied independently on each window. Top: estimated R as a function of time. Bottom: estimated Re as a function of time. Recordings at times 1 and 2 are shown in C. C: raw (gray) and compensated (black) traces at times 1 (left, Re = 33 MΩ) and 2 (top right, Re = 81 MΩ). Bottom right: same as above but using the Re obtained at time 1 (Re = 33 MΩ).
One advantage of this technique is that electrode properties can be tracked over the time course of the recording. In Fig. 9B, we show the evolution of the neuron and electrode resistance, as estimated by the model, during 10 min of recording (fluctuating current was injected). The recording was divided in slices of 1 s, and each slice was independently compensated (by running the model optimization on every slice). First, we observe some variability in the neuron resistance but little variability in the estimated electrode resistance (at least for the 1st 5 min). This is a sign of a good electrode compensation because electrode properties should be stable on a short time scale, whereas the properties of the neuron should change during stimulation, as ionic channels open and close. Quantitatively, the standard deviation of the estimated Re in the 1st 5 min is σe = 11.6 MΩ. Given that the mean current is μI = 20 pA, the error in Vm estimation should be of order μI.σe = 0.23 mV.
Second, in the middle of the recording, we observe that the electrode resistance slowly increases. This is unlikely to be an artifact of our compensation technique because the neuron resistance remains stable and the estimated electrode resistance is also stable on shorter time scales. It could be, for example, because the electrode moved. This is an example where this technique is especially useful because the recordings can still be compensated even though electrode properties change, as illustrated in Fig. 9C. On the left, a compensated trace (solid) is shown superimposed on the raw trace (gray), at the beginning of the recording (1). The same is shown on the right at the end of the recording (2) with updated electrode parameters. The raw trace is now further away from the compensated trace because the electrode resistance has increased. If the electrode parameters are not updated, that is, we use the electrode properties obtained at the beginning of the recording to compensate the end of the recording, then the compensated trace is significantly different (bottom right): in particular, what looked like a postsynaptic potential preceding the spike now looks like a “spikelet,” which is presumably a residual electrode response to an injected PSC.
To check that the technique indeed correctly tracks changes in electrode resistance, we simulated an abrupt change in Re in a model recording, in which the neuron receives a fluctuating current (Fig. 3A). In the middle of the recording, Re increases from 100 to 300 MΩ (dashed step). The method correctly tracks this change, whereas the estimate of the membrane resistance R is unchanged. To check that changes in neuron properties do not perturb the method, we injected a filtered noise current in a neuron of the cochlear nucleus and pharmacologically increased the membrane resistance (Fig. 3B). These neurons strongly express a hyperpolarization-activated current named Ih (Cao and Oertel 2011). From the middle of the experiment, we apply an Ih blocker (see methods). As expected, the estimated resistance of the neuron increases sharply, whereas the estimated electrode resistance remains stable.
Spike Detection
The simplest application of the method is to detect reliably spikes in current-clamp recordings. We now describe a spike detection procedure in which the rate of errors can be evaluated (Fig. 5). Although we developed it for the present compensation technique, it could be applied in principle to any compensated recording. The procedure relies on the observation that when the recordings are plotted in phase space (dV/dt vs. V, Fig. 5A), spike peaks appear as crossings of the line dV/dt = 0 at high values of V. In a correctly compensated recording, these crossings are clearly distinct from those corresponding to subthreshold fluctuations (low values of V). Our procedure consists of computing a histogram of crossing values (Fig. 5B) and splitting it into two modes by choosing an appropriate decision threshold (see methods). Crossings above the decision threshold are considered as spike peaks (Fig. 5C). The quality of spike detection then can be estimated with signal detection theory as follows. We approximate the two modes of the histogram as normal distributions. The probability that a sample from the subthreshold distribution exceeds the decision threshold is the false alarm rate, whereas the probability that a sample from suprathreshold distribution exceeds the decision threshold is the hit rate. In the specific recording shown in Fig. 5, the distributions were very well-separated so the hit rate was near 100% and the false alarm rate was near 0%.
Quality and Stability of Electrode Compensation
The temporal stability of the estimated electrode resistance may also be used as a quality check of the compensation. To check this point, we simulated the response of a biophysical neuron model with an electrode (same as in Fig. 4) to a filtered noisy current. We then estimated the electrode and neuron resistances in each 1-s slice of a 1-min recording (Fig. 10A). The results are very similar to Fig. 9B: the neuron resistance is quite variable, whereas the electrode resistance is very stable. The estimation of Re varied by ∼10% [standard deviation/mean; 2 outliers (Re > 400 MΩ) were removed], whereas the true value was within 5% of the mean (200 vs. 192 MΩ).
Fig. 10.

Quality and stability of electrode compensation. A: estimated R (●) and Re (x) (line: actual Re of the model) as a function of time on a simulated recording with an injected noisy current (filtered noise; same model as in Fig. 4, Re = 200 MΩ). The mean firing rate was ∼8 Hz. B: action potential shapes. Top: spikes recorded in vivo in a neuron of the prefrontal cortex (Léger et al. 2005). On the right, the same spikes are shown in the phase plane (V, dV/dt; see methods). Middle: compensated spikes of a cortical neuron in response to a fluctuating current. Bottom: same as above but when the estimated Re is increased by 25%.
In a single-electrode recording, it is difficult to do an independent check of the quality of electrode compensation. Nevertheless, we suggest a simple test based on action potential shape. The shape of action potentials can vary (slightly) over time in a single cell, in particular the spike threshold and peak value (Platkiewicz and Brette 2010). However, these changes tend be coordinated, for example, spikes with a low onset tend to have a higher peak. Figure 10B (top left) shows an example of this phenomenon in a neuron of the prefrontal cortex in vivo (Léger et al. 2005). This may be explained by sodium inactivation (Platkiewicz and Brette 2011): at lower Vm, sodium channels are less inactivated, and therefore more sodium current enters the cell, which produces higher spikes. It is useful to represent spikes in a phase space, where the derivative of Vm (dVm/dt) is plotted against Vm (Fig. 10B, top right). In this representation, spikes form concentric trajectories that do not cross each other.
We found the same phenomenon in compensated traces of our in vitro recordings (Fig. 10B, middle). How would the traces look like in phase space if the electrode resistance were misestimated? It should result in random shifts of Vm (essentially proportional to the current injected at spike time) and therefore in random shifts of the spike trajectories in phase space along the horizontal direction. This horizontal jitter should make some trajectories intersect. This is indeed what happens in Fig. 10B (bottom), where we compensated the recording with an electrode resistance mistuned by 25%. Therefore, in this case, we may be relatively confident that Re was estimated with at least 25% accuracy.
We developed a more quantitative test of compensation quality based on spike shape (Fig. 6). It is based on the idea that the voltage at spike peak should not depend on the current injected after spike initiation. In a previous study, Anderson et al. (2000) used a similar principle to estimate the electrode resistance: if the voltage value at spike peak is constant, then the correlation between the measured voltage at spike peak and the injected current is precisely the residual (noncompensated) electrode resistance. The interest of this estimation method is that it only uses information based on spike shape, whereas other estimation methods (including ours) use only information in the subthreshold response. Therefore, it can be seen as an independent control. One weakness of this method is that the voltage at spike peaks is in fact not constant and depends on Vm history, as we previously mentioned. This can introduce spurious correlations between injected current and spike peak voltage, which are not indicative of poor electrode compensation. We refined this method to address this issue (Fig. 6A and methods). First, we predict the spike peak from Vm preceding the spike, using a linear regression to the preceding voltage. Second, we calculate the Pearson correlation between the current injected during the spike and the error in predicting the peak value. This correlation coefficient, which we call “quality coefficient,” should be minimal when the recording is correctly compensated. Figure 6B shows in this recording how the compensation LP error varies when the estimated electrode Re and neuron resistance R are varied. The lowest error value is achieved with Re = 103 MΩ. Figure 6C shows how the quality coefficient varies in the same recording when Re and R are varied. The lowest value is achieved with Re = 95 MΩ. These two panels confirm that these two error criteria are different in nature: the LP criterion is strongly modulated by the total resistance (electrode + neuron), whereas the quality coefficient mostly depends on the electrode resistance. For this specific recording, we may conclude that the estimation of Re should be correct within ∼10%. Note that this method based on the quality coefficient is also not perfect because it implicitly assumes that the resistance of the neuron is 0 at spike peak, which of course is not exactly true, especially in neurons with small somatic spikes.
Dendrites
One important difficulty with all single-electrode compensation methods, including the present one, is that the presence of dendrites may contribute a fast component in the response of the neuron to injected currents, potentially at the same time scale as the electrode response. With a single electrode, there is no principled way to distinguish between the two contributions, which means that an electrode compensation method may subtract both the electrode voltage and the dendritic response. In Brette et al. (2008), it was shown in a multicompartmental model of a pyramidal cell that the dendritic contribution was not large enough to degrade the quality of recordings compensated with active electrode compensation (AEC). Here, we simulated a pyramidal neuron model with two compartments representing the soma and dendrites (Wang 1998) with a filtered noisy current injected at the soma and an electrode model (Re = 200 MΩ and τe = 0.2 ms). The recording was compensated as previously, that is, the model used in the compensation procedure did not include a dendritic component (Fig. 7A). As is seen on Fig. 7A, the compensated recording is still very accurate (estimated Re was 171 MΩ). We then modified the neuron model used for the compensation procedure to include a dendritic compartment (electrical circuit shown on Fig. 7B). This improved the estimation of Re (192 MΩ). However, we should caution that there is no guarantee that adding a dendritic compartment in the compensation model will always improve the accuracy because it may depend on the morphology of the neuron, for example.
It could be that in other recordings (e.g., different cell morphologies), the dendritic component is more important, which could degrade the quality of compensation. However, as we noted, this problem is not worse than with any other single-electrode compensation method. In fact, to be more precise, dendritic and electrode responses are indistinguishable for any method based on the linear response of the circuit (neuron + electrode). This includes the present method, bridge, and discontinuous current-clamp. However, the independent control based on spike peaks that we presented above (Fig. 6) is actually based on the nonlinear response of the neuron. Therefore, it could also be used to test whether the compensation may be compromised by dendritic components.
Application: Spike Threshold In Vitro
We finish with an application of this technique to the measurement of the spike threshold (more precisely, spike onset) in response to fluctuating currents in neurons of the cochlear nucleus. In vivo, the spike threshold in many areas shows significant variability. It is negatively correlated with preceding depolarization slope (Azouz and Gray 2003; Wilent and Contreras 2005) and with the preceding interspike interval (Henze and Buzsáki 2001; see Platkiewicz and Brette 2010 for a more exhaustive overview). These properties have also been seen in cortical neurons in vitro in response to fluctuating conductances using the dynamic clamp technique (de Polavieja et al. 2005). In Fig. 8, we show similar results in a stellate cell of the cochlear nucleus using current-clamp injection of a fluctuating current (filtered noise with time constant 2 ms). This corresponds to the type of cell modeled in Fig. 4. One difficulty is that these cells tend to have short membrane time constants (∼5 ms in this cell), and therefore separating the electrode from the neuron response is more challenging.
Figure 8A shows the compensated recording. Spike onsets (black dots) were measured according to a criterion on the first derivative of Vm (dV/dt = 1 V/s). In this recording, the spike threshold distribution spanned a range of ∼12 mV, with standard deviation σ = 2.1 mV, which is comparable with in vivo measurements in the cortex (Azouz and Gray 2003; Wilent and Contreras 2005) and in the inferior colliculus, another subcortical auditory structure (Peña and Konishi 2002). This variability appeared higher in the uncompensated recording (σ = 2.9 mV) but also when bridge balance was used (σ = 2.6 mV), using the resistance value obtained by our method (Re = 45 MΩ). In addition, in both the uncompensated recording and the bridge-compensated trace, there was a small inverse correlation between spike threshold and preceding depolarization slope (Fig. 8, B and C; slope of the linear regression: −8 and −11.4 ms). This correlation was stronger when our compensation method was used (Fig. 8D; slope −18.2 ms). Thus, with our compensation method, the inverse correlation was stronger, whereas the variability in spike threshold was smaller, which suggests that this stronger correlation is indeed the result of a more accurate estimation of spike threshold.
As a complementary test, we simulated a recording with a neuron model exhibiting a dynamic spike threshold (Fig. 8E). We used a simplified single-compartment model in which the value of the spike threshold is explicitly known (Platkiewicz and Brette 2010, 2011; dashed curve in Fig. 8E). In the uncompensated recording, the spike threshold cannot be correctly measured (Fig. 8F), whereas it is correctly estimated in the compensated recording (Fig. 8G, note the different vertical scale).
DISCUSSION
We have a proposed a new method to correct the electrode bias in single-electrode current-clamp recordings. As with AEC (Brette et al. 2008), the principle is to fit a model of the measurements, that includes both the electrode and the neuron, and to subtract the predicted electrode voltage. The main difference is that it does not require any preliminary calibration, and it still works when electrode properties change during the course of the recording (on a slow time scale). In addition, thanks to a special error criterion, the estimation procedure is not very degraded by action potentials and other nonlinearities. We have also proposed a method to detect spikes reliably and an independent quality control based on analyzing spike peaks.
There are limitations, many of which are shared by other compensation methods. First, the electrode must be linear. This is a critical point, discussed in Brette et al. (2008), and it may not always be satisfied. Unfortunately, no compensation method can solve this issue because when the electrode is nonlinear, the injected current is also distorted (Purves 1981). However, with our technique, we can track the temporal changes in electrode properties and possibly detect electrode nonlinearities (which would mean that electrode properties vary with the mean injected current). In fact, it is possible in principle to incorporate nonlinearities in the electrode model, but this would require to have a precise model, which is not available at this time. Second, the technique only corrects the measured potential but not the injected current, which is still filtered by the electrode. Therefore, it is still useful to use the capacitance neutralization circuit on the amplifier so as to minimize the electrode time constant (this is a feedback circuit, which corrects the current rather than the potential). This issue is also present in double-electrode recordings. Third, although in principle the electrode and neuron time scales do not need to be well-separated, in practice it may be difficult to distinguish between neuron and electrode components that are on a similar time scale, for example fast dendritic components and electrode response. This issue is present with all single-electrode compensation techniques, which is another reason to use capacitance neutralization on the amplifier.
Another, more specific issue is the choice of the neuron and electrode models. In the experiments shown in this paper, a simple RC circuit for each element (neuron and electrode) seemed sufficient to correct the recordings. We should note that the capacitance neutralization circuit was used in these recordings (although not fully), and therefore the residual capacitance was compensated (which could be distributed along the wall of the electrode). However, it might not be sufficient in other cases. It is not a problem in itself, since it is straightforward to change the model to be optimized (in our software tool, this only means entering different equations for the model). For example, one could consider a more complex electrode model with two resistors and two capacitors. These more complex models could be used when the quality of the fit is poor or when there is a large temporal variability in estimated electrode properties.
This technique may be extended in several ways. First, although we only applied it to current-clamp recordings, it could be used in the dynamic clamp (Prinz et al. 2004) or even voltage-clamp mode (implemented, e.g., as a dynamic clamp with high gain). However, since in these modes the current depends in real-time on the estimated Vm, the electrode compensation cannot be done offline and therefore requires preliminary calibration. One possible advantage over other techniques such as AEC is that it is more robust to neuronal nonlinearities (e.g., action potentials). This property may also make it more appropriate for in vivo recordings. Finally, we suggest that this technique could be used to fit neuron models to intracellular recordings (Gerstner and Naud 2009; Jolivet et al. 2008; Rossant et al. 2011b). The current strategy is in two stages: first compensate the recordings (e.g., with bridge balance) and then fit a neuron model to the compensated trace. Instead, we suggest that a better strategy is to fit directly a model of the full experimental setup, including the neuron and the electrode, to the uncompensated recordings.
GRANTS
This work was supported by the European Research Council (ERC StG 240132) and the Swedish Research Council (Grant 80326601).
DISCLOSURES
No conflicts of interest, financial or otherwise, are declared by the author(s).
AUTHOR CONTRIBUTIONS
C.R. and R.B. conception and design of research; C.R. and B.F. analyzed data; C.R., B.F., and R.B. interpreted results of experiments; C.R. and B.F. prepared figures; B.F. and A.K.M. performed experiments; R.B. drafted manuscript; R.B. edited and revised manuscript; R.B. approved final version of manuscript.
ACKNOWLEDGMENTS
We thank Jean-François Léger for providing us with an in vivo intracellular recording of a prefrontal cortical neuron.
APPENDIX
Model Simulation with a Linear Filter
When the model of the neuron and the electrode is linear, it can be efficiently simulated using a linear filter. More specifically, let us write the model equations as , where Y is a d-dimensional vector, M a d × d matrix, B is a d-dimensional vector, and X(t) =t [x(t),0,…,0], where x(t) is the fluctuating input current. In general, the linear model can be written under this form as soon as the matrix M is invertible. Assuming that the input current is sampled at frequency F = 1/dt, we can numerically solve this equation by simulating the following discrete-time linear system: Yn+1 = AYn + Xn, where A = exp(M·dt), and we applied the following change of variables: Y←Y-B. This system can be solved using a linear filter: , where yn = Yn[i] and xn = x(n·dt)dt, and i is the index of the variable to be simulated (typically, neuron and electrode potential). The values ak can be obtained by computing the characteristic polynomial of the matrix A, PA(X) = det(X⋅Id − A) = . The values bk are obtained with bk = Tk[i,0], where .
We give an outline of the proof here. We start from the Cayley-Hamilton theorem, which states that PA(A) = 0. We multiply this equation by . We then calculate AkYn−d by induction:
and we substitute it in the equation above, which gives:
We then obtain the desired result by looking at coordinate i.
Using this technique, electrode compensation is very fast (close to real-time with sampling rate 10 kHz) even though we implemented it in Python, an interpreted language.
REFERENCES
- Anderson J, Carandini M, Ferster D. Orientation tuning of input conductance, excitation, and inhibition in cat primary visual cortex. J Neurophysiol 84: 909–926, 2000 [DOI] [PubMed] [Google Scholar]
- Angelo K, London M, Christensen SR, Häusser M. Local and global effects of I(h) distribution in dendrites of mammalian neurons. J Neurosci 27: 8643–8653, 2007 [DOI] [PMC free article] [PubMed] [Google Scholar]
- Azouz R, Gray CM. Adaptive coincidence detection and dynamic gain control in visual cortical neurons in vivo. Neuron 37: 513–523, 2003 [DOI] [PubMed] [Google Scholar]
- Brette R, Destexhe A. Intracellular recording. In: Handbook of Neural Activity Measurement. Cambridge, UK: Cambridge Univ. Press, 2012 [Google Scholar]
- Brette R, Piwkowska Z, Monier C, Rudolph-Lilith M, Fournier J, Levy M, Frégnac Y, Bal T, Destexhe A. High-resolution intracellular recordings using a real-time computational model of the electrode. Neuron 59: 379–391, 2008 [DOI] [PubMed] [Google Scholar]
- Cao XJ, Oertel D. The magnitudes of hyperpolarization-activated and low-voltage-activated potassium currents co-vary in neurons of the ventral cochlear nucleus. J Neurophysiol 106: 630–640, 2011 [DOI] [PMC free article] [PubMed] [Google Scholar]
- Davie JT, Kole MH, Letzkus JJ, Rancz EA, Spruston N, Stuart GJ, Hausser M. Dendritic patch-clamp recording. Nat Protoc 1: 1235–1247, 2006 [DOI] [PMC free article] [PubMed] [Google Scholar]
- de Polavieja GG, Harsch A, Kleppe I, Robinson HP, Juusola M. Stimulus history reliably shapes action potential waveforms of cortical neurons. J Neurosci 25: 5657–5665, 2005 [DOI] [PMC free article] [PubMed] [Google Scholar]
- Fourcaud-Trocmé N, Hansel D, van Vreeswijk C, Brunel N. How spike generation mechanisms determine the neuronal response to fluctuating inputs. J Neurosci 23: 11628–11640, 2003 [DOI] [PMC free article] [PubMed] [Google Scholar]
- Fujino K, Oertel D. Cholinergic modulation of stellate cells in the mammalian ventral cochlear nucleus. J Neurosci 21: 7372–7383, 2001 [DOI] [PMC free article] [PubMed] [Google Scholar]
- Gerstner W, Naud R. How good are neuron models? Science 326: 379–380, 2009 [DOI] [PubMed] [Google Scholar]
- Goodman DF, Brette R. The Brian simulator. Front Neurosci 3: 192–197, 2009 [DOI] [PMC free article] [PubMed] [Google Scholar]
- Henze DA, Buzsáki G. Action potential threshold of hippocampal pyramidal cells in vivo is increased by recent spiking activity. Neuroscience 105: 121–130, 2001 [DOI] [PubMed] [Google Scholar]
- Jolivet R, Schürmann F, Berger TK, Naud R, Gerstner W, Roth A. The quantitative single-neuron modeling competition. Biol Cybern 99: 417–426, 2008 [DOI] [PubMed] [Google Scholar]
- Léger JF, Stern EA, Aertsen A, Heck D. Synaptic integration in rat frontal cortex shaped by network activity. J Neurophysiol 93: 281–293, 2005 [DOI] [PubMed] [Google Scholar]
- Peña JL, Konishi M. From postsynaptic potentials to spikes in the genesis of auditory spatial receptive fields. J Neurosci 22: 5652–5658, 2002 [DOI] [PMC free article] [PubMed] [Google Scholar]
- Platkiewicz J, Brette R. A threshold equation for action potential initiation. PLoS Comput Biol 6: e1000850, 2010 [DOI] [PMC free article] [PubMed] [Google Scholar]
- Platkiewicz J, Brette R. Impact of fast sodium channel inactivation on spike threshold dynamics and synaptic integration. PLoS Comput Biol 7: e1001129, 2011 [DOI] [PMC free article] [PubMed] [Google Scholar]
- Prinz AA, Abbott LF, Marder E. The dynamic clamp comes of age. Trends Neurosci 27: 218–224, 2004 [DOI] [PubMed] [Google Scholar]
- Purves RD. Microelectrode Methods for Intracellular Recording and Ionophoresis. New York: Academic Press, 1981 [Google Scholar]
- Rossant C, Fontaine B, Goodman DF. Playdoh: a lightweight Python library for distributed computing and optimisation. J Comput Sci. First published July 6, 2011; doi:10.1016/j.jocs.2011.06.002, 2011a [Google Scholar]
- Rossant C, Goodman DF, Fontaine B, Platkiewicz J, Magnusson AK, Brette R. Fitting neuron models to spike trains. Front Neurosci 5: 9, 2011b [DOI] [PMC free article] [PubMed] [Google Scholar]
- Rossant C, Leijon S, Magnusson AK, Brette R. Sensitivity of noisy neurons to coincident inputs. J Neurosci 31: 17193–17206, 2011c [DOI] [PMC free article] [PubMed] [Google Scholar]
- Rothman JS, Manis PB. The roles potassium currents play in regulating the electrical activity of ventral cochlear nucleus neurons. J Neurophysiol 89: 3097–3113, 2003 [DOI] [PubMed] [Google Scholar]
- Shu Y, Duque A, Yu Y, Haider B, McCormick DA. Properties of action-potential initiation in neocortical pyramidal cells: evidence from whole cell axon recordings. J Neurophysiol 97: 746–760, 2007 [DOI] [PubMed] [Google Scholar]
- Wang XJ. Calcium coding and adaptive temporal computation in cortical pyramidal neurons. J Neurophysiol 79: 1549–1566, 1998 [DOI] [PubMed] [Google Scholar]
- Wehr M, Zador AM. Balanced inhibition underlies tuning and sharpens spike timing in auditory cortex. Nature 426: 442–446, 2003 [DOI] [PubMed] [Google Scholar]
- Wilent WB, Contreras D. Stimulus-dependent changes in spike threshold enhance feature selectivity in rat barrel cortex neurons. J Neurosci 25: 2983–2991, 2005 [DOI] [PMC free article] [PubMed] [Google Scholar]
