## 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.

- 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 *R*_{e}). Thus the measurement is the sum of the membrane potential (*V*_{m}) and of the voltage across the electrode, which, by Ohm's law, is *R*_{e}.*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 *R*_{e}.*I* from the uncompensated recording where *R*_{e} is the estimated electrode resistance (usually manually adjusted using the response to current pulses). There are two issues with this method. First, even if *R*_{e} 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 *R*_{e}.*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 *R*_{e} difficult, given that *R*_{e} cannot be estimated in the bath (it changes after impalement).

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 *I*h, 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. 2*A*). The equations are:
*I* is the input current, *I*_{inj} is injected current, *V*_{neuron} is the *V*_{m} of the neuron, *U*_{e} is the voltage across the electrode, τ_{m} and τ_{e} are the membrane and electrode time constants, *R* and *R*_{e} are the membrane and electrode resistance, and *V*_{r} is resting potential. The five parameters are adjusted to minimize the L^{P} error between the model prediction, *V*_{model}, and the raw (uncompensated) measured trace, *V*_{raw}:
*P* is a parameter (*P* = 0.5 is a good choice). After optimization, the compensated *V*_{m} of the cell is *V*_{raw}−*U*_{e}.

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. 3*A*.

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/d*t* 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.

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:
*V*_{s} 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).

### 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 *R*_{e} = 200 MΩ and τ_{e} = 0.2 ms. In Fig. 7*B*, the model used for compensation also has a dendritic current following the electrical circuit shown in the figure.

### 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:
_{m} = 5 ms is the membrane time constant, *E*_{l} = −70 mV is the leak reversal potential, Δ = 1 mV characterizes the sharpness of spike initiation, and *R*_{m} = 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:
_{∞}(*V*) = *V*_{T} − *k*_{a}log*h*_{∞}(*V*) is the steady-state threshold, determined by *V*_{T} = −67 mV, the minimum threshold, *k*_{a} = 4.3 mV is the Boltzmann factor of the sodium activation function, and *h*_{∞} is the inactivation function:
*V*_{i} = −69 mV is the half-inactivation voltage of sodium channels. These values ensure that the spike threshold is variable (Platkiewicz and Brette 2011).

## RESULTS

### Principle

The principle is illustrated in Fig. 2*A*. 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 2*B* 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 2*B* (*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. 2*C*. 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 (*V*_{raw}−*V*_{model}) 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 (*V*_{raw}−*V*_{model})^{2}, we minimize the mean of |*V*_{raw}−*V*_{model}|^{P}, where *P* < 2. This is called the L^{P} 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. 2*D* 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. 4*A*, *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 *V*_{m} of the biophysical neuron model (*bottom*).

We varied *R*_{e} 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. 4*B*). We then tested the influence of the error criterion (Fig. 4*C*). 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. 9*A*, *top*). After compensation, traces were smoother and spikes stood out very clearly (*bottom*).

One advantage of this technique is that electrode properties can be tracked over the time course of the recording. In Fig. 9*B*, 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 *R*_{e} in the 1st 5 min is σ_{e} = 11.6 MΩ. Given that the mean current is μ_{I} = 20 pA, the error in *V*_{m} 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. 9*C*. 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 *R*_{e} in a model recording, in which the neuron receives a fluctuating current (Fig. 3*A*). In the middle of the recording, *R*_{e} 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. 3*B*). These neurons strongly express a hyperpolarization-activated current named *I*h (Cao and Oertel 2011). From the middle of the experiment, we apply an *I*h 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/d*t* vs. *V*, Fig. 5*A*), spike peaks appear as crossings of the line dV/d*t* = 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. 5*B*) 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. 5*C*). 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. 10*A*). The results are very similar to Fig. 9*B*: the neuron resistance is quite variable, whereas the electrode resistance is very stable. The estimation of *R*_{e} varied by ∼10% [standard deviation/mean; 2 outliers (*R*_{e} > 400 MΩ) were removed], whereas the true value was within 5% of the mean (200 vs. 192 MΩ).

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 10*B* (*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 *V*_{m}, 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 *V*_{m} (d*V*_{m}/d*t*) is plotted against *V*_{m} (Fig. 10*B*, *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. 10*B*, *middle*). How would the traces look like in phase space if the electrode resistance were misestimated? It should result in random shifts of *V*_{m} (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. 10*B* (*bottom*), where we compensated the recording with an electrode resistance mistuned by 25%. Therefore, in this case, we may be relatively confident that *R*_{e} 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 *V*_{m} 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. 6*A* and methods). First, we predict the spike peak from *V*_{m} 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 6*B* shows in this recording how the compensation L^{P} error varies when the estimated electrode *R*_{e} and neuron resistance *R* are varied. The lowest error value is achieved with *R*_{e} = 103 MΩ. Figure 6*C* shows how the quality coefficient varies in the same recording when *R*_{e} and *R* are varied. The lowest value is achieved with *R*_{e} = 95 MΩ. These two panels confirm that these two error criteria are different in nature: the L^{P} 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 *R*_{e} 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 (*R*_{e} = 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. 7*A*). As is seen on Fig. 7*A*, the compensated recording is still very accurate (estimated *R*_{e} was 171 MΩ). We then modified the neuron model used for the compensation procedure to include a dendritic compartment (electrical circuit shown on Fig. 7*B*). This improved the estimation of *R*_{e} (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 8*A* shows the compensated recording. Spike onsets (black dots) were measured according to a criterion on the first derivative of *V*_{m} (dV/d*t* = 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 (*R*_{e} = 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. 8*D*; 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. 8*E*). 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. 8*E*). In the uncompensated recording, the spike threshold cannot be correctly measured (Fig. 8*F*), whereas it is correctly estimated in the compensated recording (Fig. 8*G*, 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 *V*_{m}, 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 **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/d*t*, we can numerically solve this equation by simulating the following discrete-time linear system: **Y**_{n+1} = **AY**_{n} + **X**_{n}, where **A** = exp(**M**·d*t*), and we applied the following change of variables: **Y**←**Y**-**B**. This system can be solved using a linear filter: *y*_{n} = **Y**_{n}[*i*] and *x*_{n} = *x*(*n*·d*t*)d*t*, and *i* is the index of the variable to be simulated (typically, neuron and electrode potential). The values *a*_{k} can be obtained by computing the characteristic polynomial of the matrix **A**, *P _{A}*(

*X*) = det(

*X*⋅

*I*d −

**A**) =

*b*

_{k}are obtained with

*b*

_{k}=

*T*

_{k}[

*i*,0], where

We give an outline of the proof here. We start from the Cayley-Hamilton theorem, which states that *P*_{A}(**A**) = 0. We multiply this equation by **A**^{k}**Y**_{n−d} by induction:
*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.

- Copyright © 2012 the American Physiological Society