Summary
Calcium imaging data promises to transform the field of neuroscience by making it possible to record from large populations of neurons simultaneously. However, determining the exact moment in time at which a neuron spikes, from a calcium imaging data set, amounts to a non-trivial deconvolution problem which is of critical importance for downstream analyses. While a number of formulations have been proposed for this task in the recent literature, in this article, we focus on a formulation recently proposed in Jewell and Witten (2018. Exact spike train inference via
optimization. The Annals of Applied Statistics12(4), 2457–2482) that can accurately estimate not just the spike rate, but also the specific times at which the neuron spikes. We develop a much faster algorithm that can be used to deconvolve a fluorescence trace of 100 000 timesteps in less than a second. Furthermore, we present a modification to this algorithm that precludes the possibility of a “negative spike”. We demonstrate the performance of this algorithm for spike deconvolution on calcium imaging datasets that were recently released as part of the
challenge (http://spikefinder.codeneuro.org/). The algorithm presented in this article was used in the Allen Institute for Brain Science’s “platform paper” to decode neural activity from the Allen Brain Observatory; this is the main scientific paper in which their data resource is presented. Our
implementation, along with
and
wrappers, is publicly available.
code is available on
and
, and
wrappers are available on
; see https://github.com/jewellsean/FastLZeroSpikeInference.
Keywords: Calcium imaging, Changepoint detection, Neuroscience, Nonconvex optimization
1. Introduction
Due to recent advances in calcium imaging technology, it has become possible to record from large populations of neurons simultaneously in behaving animals (Dombeck and others, 2007; Ahrens and others, 2013; Prevedel and others, 2014). These data result in a fluorescence trace for each neuron.
However, most downstream analyses require not a fluorescence trace, but instead a measure of the neuron’s activity over time. Consequently, a number of unsupervised and—more recently—supervised methods have been developed to infer neural activity on the basis of the fluorescence trace (Yaksi and Friedrich, 2006; Holekamp and others, 2008; Sasaki and others, 2008; Dyer and others, 2010, 2013; Grewe and others, 2010; Vogelstein and others, 2009, 2010; Pnevmatikakis and others, 2013; Deneux and others, 2016; Friedrich and Paninski, 2016; Theis and others, 2016; Friedrich and others, 2017; Jewell and Witten, 2018).
In this article, we make use of a generative model that connects the observed fluorescence trace
to the underlying and unobserved calcium concentration
, and the unknown spike times (Vogelstein and others, 2010; Friedrich and Paninski, 2016; Friedrich and others, 2017). This model assumes that the observed fluorescence is a noisy version of the underlying calcium, which exponentially decays, unless there is a spike, in which case there is an instantaneous increase in the calcium concentration, as follows:
![]() |
(1.1) |
where
, and where
indicates the presence of a spike at the
th timestep. At most timesteps
, corresponding to no spike, and the calcium will decay exponentially at a rate governed by the parameter
, which is assumed known. For simplicity, in what follows, we assume that the intercept
is equal to zero. However, this is easy to relax; see Section 2.4 for a straight-forward extension, and Section 3 for practical considerations. Moreover, we set
equal to one, since the problems we will solve are scale-invariant. That is, the value of
does not affect the scientific conclusions.
Under the additional assumption that the errors
are normally distributed, model (1.1) suggests estimating the concentration by solving the following constrained
optimization problem
![]() |
(1.2) |
where
is a non-negative tuning parameter that controls the tradeoff between how closely the calcium concentration matches the fluorescence trace,
, and the number of non-zero spikes,
. The solution to this optimization problem directly provides an estimate for the spike times; that is, if
, then we infer a spike at time
. We note that this problem is over-parameterized, in the sense that knowing
determines
.
While (1.2) follows from the biological process described in (1.1), the
penalty makes the problem nonconvex and thus seemingly intractable. Consequently, rather than solving (1.2), prior approaches have solved a convex relaxation to (1.2) (Vogelstein and others, 2010; Friedrich and Paninski, 2016; Friedrich and others, 2017), where the
penalty is replaced by an
penalty.
In recent work, Jewell and Witten (2018) showed that it is possible to efficiently solve the related nonconvex optimization problem
![]() |
(1.3) |
obtained by removing the positivity constraint,
, from (1.2). The positivity constraint enforces the biological property that a firing neuron can only cause the calcium concentration to increase. Nonetheless, despite the slight loss in physical interpretability caused by the omission of the positivity constraint, Jewell and Witten (2018) showed that solving (1.3) leads to improved performance over existing deconvolution approaches that perform a convex relaxation of (1.2). In particular, the method of Jewell and Witten (2018) provides an accurate estimate of the specific timesteps at which a neuron fires.
Unfortunately, the algorithm proposed in Jewell and Witten (2018) for solving (1.3) is too slow to conveniently run on large-scale data. For traces of 100 000 timesteps, the implementation runs in a few minutes for a single value of the tuning parameter
; in practice the user must apply the algorithm over a fine grid of values of
, leading potentially to hours of computation time for a single trace. Furthermore, a single experiment could result in hundreds or thousands of fluorescence traces (Ahrens and others, 2013; Vladimirov and others, 2014).
In this article, we develop a fast algorithm for solving problem (1.3); for traces of 100 000 timesteps our implementation runs in less than a second. Furthermore, this new algorithm can easily accommodate the positivity constraint that was omitted from (1.3); in other words, we can directly solve problem (1.2). Additionally, we exploit ideas from Haynes and others (2017) to efficiently “choose” good values of
; that is, values of
where the solution to (1.3) changes.
The algorithm we develop to solve (1.2) was used to obtain the key scientific results in the Allen Institute’s main scientific paper from the Allen Brain Observatory (de Vries and others, 2018). Additionally, the Allen Institute for Brain Science recently released an update to their software development kit that provides users with the output from our algorithm for close to 60 000 neurons during different experimental conditions.
In what follows, we introduce our new algorithm for solving (1.2) and (1.3) in Section 2. We compare its performance in Section 3 to a convex relaxation of (1.2) on a number of calcium imaging datasets that were recently released as part of the
challenge (http://spikefinder.codeneuro.org/). We close with a discussion in Section 4.
2. A fast functional pruning algorithm for solving problems (1.3) and (1.2)
2.1. A review of Jewell and Witten (2018)
Jewell and Witten (2018) point out that the
optimization problem (1.3) is equivalent to a changepoint detection problem,
![]() |
(2.4) |
where
![]() |
(2.5) |
In problem (2.4), we select the optimal changepoints
and the number of changepoints
such that the cost of segmenting the data into
exponentially decaying regions is minimal, where (2.5) is the cost associated with the region that spans the
th to
th timesteps. Problems (2.4) and (1.3) are equivalent in the sense that
and all other
.
To solve the changepoint problem, Jewell and Witten (2018) exploit a simple recursion (Jackson and others, 2005),
![]() |
(2.6) |
where
is the optimal cost of segmenting the data
, and where we define
. This results in an algorithm with computational complexity
, which can be substantially improved by noticing that the minimization on the right hand side of (2.6) can be performed over a smaller set
without sacrificing the global optimum (Killick and others, 2012); details are provided in Jewell and Witten (2018). As mentioned in the introduction, the algorithm runs in a few minutes for traces of length 100 000, and yields the global optimum to (1.3). We note that the recursion (2.6) does not naturally lead to an algorithm to solve (1.2); this is discussed in further detail in Section 2.3.
2.2. Functional pruning for solving (1.3)
2.2.1. Motivation for functional pruning.
In order to motivate the potential for a much faster algorithm for solving (1.3) than the one proposed in Jewell and Witten (2018), consider Figure 1a.
Fig. 1.
Algorithm 1: (a) motivation and (b) example. (a) A simple example to show that there are only a few possible values for the most recent changepoint before timestep 40. We consider solving for the most recent changepoint, given data
, for each possible value of the calcium concentration at the
th timestep,
. For each possible value of
, we display the estimated calcium concentration going back in time to the most recent changepoint before timestep 40. The colors indicate the time of the most recent changepoint. In this example, there are only three possibilities for the most recent changepoint:
. For example,
, and
. (b) Evolution of
and
for Example 1. The left-hand panels display the functions
and
, and the right-hand panels show the function
, which is the minimum of those two functions. Rows index the timesteps,
. The functions are colored based on the timestep of the most recent changepoint, that is, the value of
corresponding to
. Top: When
,
; this corresponds to the region
. Center: When
,
is the minimum of two quantities:
, which corresponds to the most recent changepoint being at timestep zero, and
, which corresponds to the most recent changepoint being at timestep one. These two functions are shown on the left-hand side, and
) is shown on the right-hand side. Bottom: When
,
is calculated similarly; see Example 1 for additional details.
In this figure, we are interested in determining the optimal cost of segmenting the data up to time
, that is, calculating
in (2.6). Instead of directly applying the recursion (2.6), we consider a slightly different question: What is the optimal most recent changepoint before the 40th timestep, conditional on, the unknown calcium concentration
? Given the previously stored values
, and the data
, it is straightforward to calculate the best most recent changepoint
, as
, for any value of the calcium concentration
.
Figure 1a displays the most recent changepoint
as a function of
. We observe that regardless of the value of the calcium at the current timestep—and consequently, regardless of the fluorescence values
—the only possible times for the most recent changepoint before the 40th timestep are 20, 37, and 39; that is,
for all possible
.
However, the algorithm proposed in Jewell and Witten (2018) does not exploit the fact that 20, 37, and 39 are the only possible times for the most recent changepoint before the 40th timestep: the minimization in (2.6) is performed over the set
, or else over a slightly smaller set
using ideas from Killick and others (2012). This suggests that by viewing the cost of segmenting the data up until the
th timestep as a function of the calcium at the
th timestep, we could potentially develop an algorithm that is much faster than the one in Jewell and Witten (2018) in that it would only require performing the minimization in (2.6) over
. The idea of using this type of conditioning was first suggested by Rigaill (2015) and Maidstone and others (2017), albeit to speed up algorithms for detecting changepoints in a different class of models.
2.2.2. The functional pruning algorithm.
To begin, we substitute the cost function
into the recursion (2.6), in order to obtain
![]() |
(2.7) |
where
![]() |
(2.8) |
and
![]() |
(2.9) |
In words,
is the cost of partitioning the data up until time
, given that the most recent changepoint was at time
, and the calcium at the
th timestep equals
.
is the optimal cost of partitioning the data up until time
, given that the calcium at the
th timestep equals
.
The following proposition will prove useful in what follows.
Proposition 1
For
defined in (2.9), the following recursion holds:
(2.10)
The proof of Proposition 1 is in Appendix S1 of the supplementary material available at Biostatistics online. The recursion in (2.10) encompasses two possibilities: either there is a changepoint at the
st timestep, and we must determine the optimal cost up to that time,
, or there is no changepoint at the
st timestep,
. The recursion in (2.10) is reminiscent of (2.6), and raises the following question: can we use (2.10) as the basis for a recursive algorithm for solving the problem of interest, (1.3)? At first, it appears almost hopeless, since the recursion (2.10) involves a function of
, a real-valued parameter. However, as we will see, it turns out that
and
are simple functions of
that are easy to analytically manipulate.
Observe that, by definition (2.9), the optimal cost
takes the form
![]() |
(2.11) |
where
; this is the set of values for the calcium at the
th timestep such that the most recent changepoint occurred at time
. Furthermore, by inspection of (2.8), we see that
is itself a quadratic function of
for all
. Thus,
is in fact piecewise quadratic. This means that in order to efficiently store the function
, we must simply keep track of the regions
, as well as the three coefficients (constant, linear, quadratic) that define the quadratic function corresponding to each region. We will now present a small toy example illustrating how the recursion (2.10) can be used to build up optimal cost functions, each of which is piecewise quadratic.
Example 1
Consider the simple dataset
with
and
. We start with
, which is just a quadratic centered around
,
Then, at the next time point, we form
based on (2.10),
Again, using the recursion (2.10) we obtain the next optimal cost function,
We note that
is defined over just
and
. This example is displayed in Figure 1b.
Although we have shown how to efficiently build optimal cost functions
from
, it remains to establish that these cost functions can be used to determine the optimal changepoints, that is, the values of
that solve (1.3). These can be obtained by finding the value of
that satisfies
![]() |
(2.12) |
for
until
is obtained. Full details are provided in Algorithm 1. To summarize, we have developed a recursive algorithm for solving (1.3) using the recursions in Proposition 1.
Algorithm 1:
A functional pruning algorithm for solving (1.3)
Example 2
“Example 1 revisited”
We return to Example 1 to illustrate how (2.12) can be used to determine the optimal changepoints. In the interest of simplicity, we assume that
; in other words, we have observed all of the data. Then,
, where
Therefore, the most recent changepoint is
. In fact, since the most recent changepoint is at timestep 0, we say that there are no changepoints.
Algorithm 1 is an instance of the class of functional pruning algorithms proposed in Maidstone and others (2017).
2.2.3. Computational time of functional pruning.
We saw in Example 1 that Proposition 1 can lead to a recursive algorithm for solving the problem of interest (1.3). At first glance, since
is piecewise quadratic with
regions (2.11), and our recursive algorithm requires computing
, it appears that a total of
operations must be performed in order to deconvolve a fluorescence trace of length
. Critically, however, this is not the case. This is because, in practice,
is piecewise quadratic with substantially fewer than
regions, as we saw in Figure 1a. To see this, recall from (2.11) that the
th region up to timestep
is defined as
. However, if
is the empty set—that is, if there is no
such that
—then
is, in fact, not a function of the
th region.
In practice,
will often be the empty set. For instance, see Figure 1a. We note that in this example, at timestep
, the optimal cost function is only a function of three regions,
![]() |
In a similar way, in Example 1, we saw that
was a function of two regions.
Therefore, though its worst-case performance is upper-bounded by
, in practice, Algorithm 1 is typically much faster than this. In Appendix S6 of the supplementary material available at Biostatistics online, we show that the maximum number of regions,
, is a small fraction of
; for
, fewer than 30 regions are required.
Furthermore, by slightly modifying Theorem 6.1 of Maidstone and others (2017), we can show that Algorithm 1 is no worse than the algorithm proposed in Jewell and Witten (2018). In fact, as shown in Figure 2, Algorithm 1 is typically up to a thousand times faster than that of Jewell and Witten (2018) on a fluorescence trace of length 100 000. In simulations, our
implementation of Algorithm 1 runs in less than one second on traces of length 100 000.
Fig. 2.
Timing comparisons between three algorithms for solving (1.2) and (1.3) with
. Functional pruning approach used in Algorithm 1 and Algorithm S8.1 of the supplementary material available at Biostatistics online (purple), and two algorithms from Jewell and Witten (2018): one based on recursion (2.6) (Optimal partitioning), and one based on an improvement to (2.6) that makes use of ideas from Killick and others (2012) (Inequality pruning). Fifty sample datasets are simulated according to (1.1) with coefficient
, decay parameter
, normal errors
, Poisson distributed spikes
where
, and initial calcium value
. Standard errors are on average
of the average computation time. Panels correspond to different values of
. Timing results were obtained on an Intel Xeon E5-2620 2.0 GHz processor.
2.3. An efficient algorithm to solve the constrained problem (1.2)
As stated in the introduction, our main interest is to solve (1.2) for the global optimum. Problem (1.2) differs from problem (1.3) in that there is an additional constraint that enforces biological reality: firing neurons can only cause an increase, but not a decrease, in the calcium concentration. The algorithm in Jewell and Witten (2018) cannot be used to solve (1.2), because it relies on the recursion in (2.6), which does not allow for any dependence in the calcium concentration before and after a changepoint. Thus, at the time of this writing, there are no algorithms available to efficiently solve (1.2) for the global optimum.
In this section, we utilize a simple modification, due to Hocking and others (2017), to the functional recursion (2.10) that ensures that the constraint
is satisfied. First, recall from (2.10) that
, where we take the minimum over two terms, which result from adding an additional point
to the current segment,
, and adding a new candidate changepoint at
and starting a new segment at the
th timestep,
.
In the latter case, if there is a spike at the
th timestep, then in order to enforce the positivity constraint,
, the term
in (2.10) needs to be modified to
Therefore, we replace (2.10) with
![]() |
(2.13) |
and we replace (2.8) with
![]() |
(2.14) |
We note that this is a slight abuse of notation since
and
take on different definitions depending on the optimization problem ((1.2) or (1.3)). Equations (2.13) and (2.14) can be used to develop an efficient recursive algorithm to solve problem (1.2). Details of the algorithm itself are included in Appendix S2 of the supplementary material available at Biostatistics online. A continuation of Example 1 that solves (1.2) is included in Appendix S5 of the supplementary material available at Biostatistics online. Figure 2 shows the running time of solving (1.2).
2.4. Solving (1.1) for non-zero intercept
Thus far, we have considered (1.1) with
. To accommodate the possibility of nonzero baseline calcium, we consider the problem
![]() |
(2.15) |
Instead of directly solving (2.15) with respect to
, we consider a fine grid of values for
, and solve (1.2) with
using Algorithm S8.1 of the supplementary material available at Biostatistics online, for each value of
considered. The solution to (2.15) is the set
corresponding to the value of
that led to the smallest value of the objective, over all values of
considered.
2.5. Solving (1.1) with additional spike constraints
The methods used to solve (1.2) and (1.3) can also be used to solve the related nonconvex problem
![]() |
(2.16) |
proposed in Friedrich and others (2017). In Appendix S4 of the supplementary material available at Biostatistics online, we examine this proposal more closely. Remarkably, we show that Algorithm S8.1 of the supplementary material available at Biostatistics online can be generalized to solve
![]() |
(2.17) |
exactly! We note that this is equivalent to (2.16) by taking
.
3. Real data experiments
In this section, we illustrate the performance of the solution to (1.2) for spike deconvolution across a number of datasets, which were aggregated as part of the recent
challenge (http://spikefinder.codeneuro.org/). Each dataset consists of both calcium and electrophysiological recordings for a single cell. As part of the
challenge, all data recordings were standardized by resampling to 100 Hz and linear trends were removed from the calcium trace via preprocessing steps described in Theis and others (2016).
Throughout this section, due to computation considerations, the solutions to (1.2) and (1.3) are obtained using slight modifications of Algorithm 1 and Algorithm S8.1 of the supplementary material available at Biostatistics online. These modifications are described in Appendix S3.1 of the supplementary material available at Biostatistics online. Additionally, since the
data removed linear trends from the raw calcium trace, we do not estimate
in (1.1). Instead, we set
; our empirical results suggest that estimation of
may not be necessary.
In our experiments, we will treat the spikes ascertained using electrophysiological recording as the “ground truth”, and will quantify the ability of spike deconvolution algorithms to recover these ground truth spikes on the basis of the calcium recordings. The data sets differ in terms of the choice of calcium indicator (GCaMP5, GCaMP6, jRCAMP, jRGECO, OGB), scanning technology (AOD, galvo, and resonant), and circuit under investigation (V1 and retina).
Throughout this section, we compare our proposal (1.2) to a recent approach from the literature that employs an
(convex) relaxation to (1.2),
![]() |
(3.18) |
proposed by Friedrich and Paninski (2016) and Friedrich and others (2017). Friedrich and others (2017) developed a very fast algorithm to solve (3.18); in simulated examples their algorithm solves (3.18) approximately 40–60
faster than Algorithm 1 and 40–900
faster than Algorithm S8.1 of the supplementary material available at Biostatistics online. This is not surprising, since (3.18) is a convex problem, whereas (1.2) and (1.3) are nonconvex problems. Moreover, in practical applications, Algorithm 1 and Algorithm S8.1 of the supplementary material available at Biostatistics online are often fast enough. Indeed, de Vries and others (2018) uses Algorithm S8.1 of the supplementary material available at Biostatistics online to deconvolve traces from nearly 60 000 neurons.
Since the solution to (3.18) often results in many small non-zero elements of
, we consider post-thresholding. That is, given
that solve (3.18), and a threshold
, we set
; in other words, we conclude that a spike is present only if
.
In Section 3.1, we compare our proposed approach (1.2) to (3.18) on data from the
challenge. We describe our experimental approach in Section 3.1.1. Section 3.1.2 illustrates these methods for a single cell, and in Section 3.1.3, we examine results for all datasets considered in the
challenge. In Section 3.2, we illustrate on a real-data example that solving (1.2) gives superior estimates than solving (1.3). In Section 3.3, we compare the estimated increase in calcium due to a spike (using (1.2)) to the actual number of recorded spikes (based on the ground truth electrophysiological recordings).
code to reproduce all experiments is available on GitHub at https://github.com/jewellsean/fast-nonconvex-experiments.
3.1. Comparison of (1.2) to (3.18) on data from the
challenge
3.1.1. Description of methods for Sections 3.1.2–3.1.3.
We now describe the methods that will be used in Sections 3.1.2–3.1.3. Our main objective is to accurately estimate the times at which spikes occur. Thus, we use two measures that directly compare two spike trains, both of which have been used extensively in the neuroscience literature (Quiroga and Panzeri, 2009; Reinagel and Reid, 2000; Gerstner and others, 2014): (i) van Rossum distance with timescale parameter
(van Rossum, 2001; Houghton and Kreuz, 2012) and (ii) Victor-Purpura distance with cost parameter
(Victor and Purpura, 1997, 1996). We also use an additional measure: (iii) the correlation between two downsampled spike trains; details of this measure are provided in Theis and others (2016). As we will see, measures (i) and (ii) are sensitive to the timing of spikes, whereas measure (iii) is somewhat insensitive to the timing of the spikes, and instead quantifies the similarity between the spike rates.
To analyze the performances of the proposals (1.2) and (3.18) over a single fluorescence trace, we take a training/test set approach. Given a fluorescence trace of length
, the first
timesteps are used in the training set, and the remainder are used for the test set. We solve (1.2) and (3.18) for a range of values of the tuning parameter
on the training set; in the case of (3.18) we also use a range of threshold values
.
For all tuning parameter values considered, we apply the three measures mentioned earlier to the estimated and true spike trains, and select the tuning parameter values that optimize these measures on the training set. We then solve (1.2) and (3.18) on the test set with the selected values of the tuning parameters, and evaluate test set performance.
As pointed out by Pachitariu and others (2018), estimating the decay rate
in (1.1) is difficult. Therefore, as in Pachitariu and others (2018), we categorize calcium indicators into three groups based on their decay properties. As in Vogelstein and others (2010), within each calcium indicator rate category, we set
, where
is 1 / (frame rate), and
is a time-scale parameter based on the category, defined as
![]() |
For example, in Figure 3, GCaMP6f is classified as a fast indicator and the data is recorded at 100Hz. Therefore, we take
.
Fig. 3.
Illustrative example for cell 13, GCaMP6f, V1, from Chen and others (2013) after preprocessing; see Theis and others (2016). Different spike measures are displayed in each row. Left: Performances of the post-thresholded solution to (3.18) and the solution to (1.2). Right: The cell’s fluorescence trace is displayed in grey. The estimated spikes on the test set from the “best” choice of the tuning parameter
, as determined by either van Rossum, Victor-Purpura, or a correlation-based measure on the training set, are displayed under the fluorescence trace. The true spike times, as determined using electrophysiological recording, are shown in black. The colors in the left-hand panels correspond to the colors in the right-hand panel.
In practice, users typically do not have the benefit of a training set to select the tuning parameter value
to solve (1.2) or (1.3). Therefore, we recommend using the procedure proposed in de Vries and others (2018), which selects
based on the firing rate, decay rate
, and estimated signal-to-noise ratio.
3.1.2. Results for a single cell.
In Figure 3, we illustrate this procedure for cell 13, GCaMP6f, V1, from Chen and others (2013). Each row corresponds to one of the measures described in Section 3.1.1. The left column displays these measures on the training set, for the solution to (1.2) with different values of
, and for the post-thresholded solution to (3.18) with different values of
and
. The right column shows the fluorescence trace along with the estimated spikes, on the test set, using tuning parameters selected on the training set.
There are a number of important observations to draw from Figure 3. As measured by van Rossum and Victor-Purpura, the estimated spikes from (1.2) are much more accurate than those estimated (and post-thresholded) using the convex relaxation (3.18). This agrees with our visual inspection of the right hand panel: the estimated spikes from problem (1.2) more closely match the number and timings of the true spikes than those estimated from problem (3.18).
In contrast, if performance is measured by correlation, then the estimated spikes obtained from (3.18) result in slightly better performance than the estimated spikes from (1.2). However, in the training set there are 75 true spikes, whereas (3.18) outperforms (1.2) when approximately 200 spikes are estimated. Therefore, selecting the tuning parameter for (3.18) based on correlation leads to a substantial overestimate of the number of spikes, and therefore, poor overall accuracy in the number and timing of the spikes. This pattern has been observed in other
regularization problems (Zou, 2006; Maidstone and others, 2018), and persists across cells in the
data (results not shown).
To summarize, when van Rossum and Victor-Purpura distance are used to evaluate performance, our proposal (1.2) substantially outperforms the approach in (3.18). When performance is evaluated using correlation, the performance of (3.18) is slightly better than that of (1.2); however, this better performance is achieved when far too many spikes are estimated, indicating that correlation is a poor choice for quantifying the accuracy of spike detection.
3.1.3. Results for all datasets in the
challenge.
In this section, we examine the performance of the solutions to (1.2) and (3.18) on all datasets collected as part of the
challenge. For the ten datasets included in this challenge, Table S1 of the supplementary material available at Biostatistics online tabulates the calcium indicator; circuit; publishing authors; average, minimum, and maximum fluorescence trace length; the number of cells measured; and the time-scale classification. In total, there are 174 traces, each of which contains fewer than 100,000 timesteps. We analyze these 174 cells as described in Section 3.1.1.
Figure 4a compares the test set performance, with respect to the van Rossum, Victor-Purpura, and correlation measures, for each of the 174 cells. As measured by the van Rossum and Victor-Purpura distance, the solution to (1.2) outperforms the solution to (3.18). However, under the correlation measure, the solution to (3.18) achieves higher correlations than the solution to (1.2). These results are consistent with those on a single cell presented in Section 3.1.2, where it was shown that van Rossum and Victor-Purpura accurately estimate spike times, whereas correlation yields a cruder measure of spike rate and encourages overestimation of the number of spikes.
Fig. 4.
Results for all datasets in the
challenge. (a) Optimal van Rossum, Victor-Purpura, and correlation measures for our proposal, (1.2), and a competing proposal, (3.18). Small values of the van Rossum and Victor-Purpura measures suggest accurate estimation of the timing and number of spikes, whereas a large value of the correlation measure suggests accurate estimation of the spike rate, though perhaps an overestimate of the number of spikes. Each dot represents the performance of (1.2) and (3.18) on a single cell, for each of the 174 cells. Cells are colored based on the dataset from which they were obtained (see Table S1 of the supplementary material available at Biostatistics online). (b) Large increases in the estimated spike magnitude,
, are associated with more true spikes, as measured by electrophysiology, at the
th timestep. For each cell, we transform the spike magnitudes into percentiles, and then compare the percentile of
to the true number of spikes within a 0.1 second window of
. Left: For each cell in each of the ten datasets, we display each timestep for which a spike is estimated to occur; however, to avoid overplotting, hexagonal bins are used to represent points covered by the hexagon; darker colors indicate more points. The black curve represents the loess fit across all of the points. Right: Loess curves along with
confidence intervals for each dataset. Cells are colored based on the dataset from which they were obtained (see Table S1 of the supplementary material available at Biostatistics online). Details are provided in Section 3.3.
3.2. The solution to (1.2) outperforms the solution to (1.3)
As mentioned earlier, in this article, we have developed not only an algorithm for solving (1.3) that is much faster than the algorithm proposed in Jewell and Witten (2018), but also an algorithm for solving (1.2), which cannot be solved using techniques from Jewell and Witten (2018). By incorporating the fact that a firing neuron causes an increase, but never a decrease, in the calcium concentration, the estimated spikes from problem (1.2) are closer to the ground truth spikes than the estimated spikes from (1.3). In practice, the solutions to (1.2) and (1.3) are typically quite similar; however, the solution to (1.2) benefits from greater interpretability. See Appendix S8 of the supplementary material available at Biostatistics online for an example.
3.3. Comparison of the estimated spike magnitudes from (1.2) to the true number of spikes.
The data from the
challenge was resampled to 100 Hz before we downloaded it. At this sampling frequency, since one timestep is just
th of a second, there are very few timesteps with more than one true spike. Nonetheless, for instances where there is more than one spike in a single timestep, we wish to ask the question: Do larger values of the estimated spike magnitudes,
, correspond to more true spikes (as measured by electrophysiology) in the
th timestep?
Figure 4b investigates whether there is a relationship between the estimated spike magnitude
and the number of spikes measured by electrophysiology at the
th timestep. Because the estimated spike magnitude of
is not directly comparable across cells, for each cell we transform the magnitudes into percentiles. We then compare the percentile of
to the true number of spikes within a 0.1 second window of
. Figure 4b displays the percentiles and the number of spikes across all 174 traces on a test set; tuning parameters were chosen to optimize the van Rossum distance on a training set. The left panel displays a loess curve fit to all ten datasets, and the right panel shows the loess curves along with
confidence intervals for each dataset. As expected, a larger value of
is associated with more spikes in the ground truth data.
4. Discussion
Determining the times at which a neuron fires from a calcium imaging dataset is a challenging and important problem. In this article, we build upon the nonconvex approach for spike deconvolution proposed in Jewell and Witten (2018). Though Jewell and Witten (2018) proposed a tractable algorithm for solving the nonconvex problem, it is prohibitively slow to run on large populations of neurons for which long recordings are available. The algorithm proposed in this paper solves the optimization problem of Jewell and Witten (2018) for fluorescence traces of 100 000 timesteps in less than a second. Moreover, Algorithm S8.1 of the supplementary material available at Biostatistics online overcomes a limitation of Jewell and Witten (2018) by avoiding “negative” spikes; that is, a decrease in the calcium concentration due to a spike. We show that these algorithms have excellent performance, relative to existing convex relaxations, as quantified by the van Rossum and Victor-Purpura measures, on datasets collected as part of the
challenge (http://spikefinder.codeneuro.org/). Moreover, Algorithm S8.1 of the supplementary material available at Biostatistics online was recently used to decode data from nearly
neurons in the Allen Institute for Brain Science’s “platform paper” for the Allen Brain Observatory (de Vries and others, 2018).
In this article, we assume that the calcium concentration decays exponentially according to a first-order auto-regressive model. Although this is typically a good approximation, there are datasets for which—due to different experimental conditions—spike times estimated from (1.2) and (1.3) are systematically biased due to model misspecification. In future work, we propose to extend the functional pruning framework to more general calcium models.
In this article, we focus on developing point estimates of the times at which a neuron spikes. However, it is also of interest to propagate uncertainty from the deconvolution procedure to downstream analyses that rely on the spike times. It remains an open question to define the notion of confidence associated with a set of estimated spikes.
Supplementary Material
Acknowledgments
We thank Michael Buice, Peter Ledochowitsch, and Michael Oliver at the Allen Institute for Brain Science and Ilana Witten at Princeton for helpful conversations. Conflict of Interest: None declared.
Funding
S.J. received funding from the Natural Sciences and Engineering Research Council of Canada. T.D.H. is partially supported by the Natural Sciences and Engineering Research Council of Canada (RGPGR 448167-2013), and by Canadian Institutes of Health Research (EP1-120608 and EP1-120609). This work was partially supported by Engineering and Physical Sciences Research Council Grant EP/N031938/1 to P.F., and National Science Foundation CAREER DMS-1252624, National Institutes of Health grants DP5OD009145, R01DA047869, and R01EB026908, and a Simons Investigator Award in Mathematical Modeling of Living Systems to D.W.
References
- Ahrens M. B., Orger M. B., Robson D. N., Li J. M. and Keller P. J. (2013). Whole-brain functional imaging at cellular resolution using light-sheet microscopy. Nature Methods 10, 413–420. [DOI] [PubMed] [Google Scholar]
- Chen T.-W., Wardill T. J., Sun Y., Pulver S. R., Renninger S. L., Baohan A., Schreiter E. R., Kerr R. A., Orger M. B., Jayaraman V.. and others (2013). Ultrasensitive fluorescent proteins for imaging neuronal activity. Nature 499, 295–300. [DOI] [PMC free article] [PubMed] [Google Scholar]
- de Vries S. E. J., Lecoq J., Buice M. A., Groblewski P. A., Ocker G. K., Oliver M., Feng D., Cain N., Ledochowitsch P., Millman D.. and others (2018). A large-scale, standardized physiological survey reveals higher order coding throughout the mouse visual cortex. bioRxiv:359513. doi: 10.1101/359513. [DOI] [PMC free article] [PubMed] [Google Scholar]
- Deneux T., Kaszas A., Szalay G., Katona G., Lakner T., Grinvald A., Rózsa B. and Vanzetta I. (2016). Accurate spike estimation from noisy calcium signals for ultrafast three-dimensional imaging of large neuronal populations in vivo. Nature Communications 7, 12190. [DOI] [PMC free article] [PubMed] [Google Scholar]
- Dombeck D. A., Khabbaz A. N., Collman F., Adelman T. L. and Tank D. W. (2007). Imaging large-scale neural activity with cellular resolution in awake, mobile mice. Neuron 56, 43–57. [DOI] [PMC free article] [PubMed] [Google Scholar]
- Dyer E. L., Duarte M. F., Johnson D. H. and Baraniuk R. G. (2010). Recovering spikes from noisy neuronal calcium signals via structured sparse approximation. In: Vigneron V., Zarzoso V., Moreau E., Gribonval R. and Vincent E. (editors), Latent Variable Analysis and Signal Separation. Berlin, Heidelberg: Springer Berlin Heidelberg, pp. 604–611. [Google Scholar]
- Dyer E. L., Studer C., Robinson J. T. and Baraniuk R. G. (2013). A robust and efficient method to recover neural events from noisy and corrupted data. In: Neural Engineering (NER), 2013 6th International IEEE/EMBS Conference on IEEE. San Diego, CA, USA: IEEE, pp. 593–596. [Google Scholar]
- Friedrich J. and Paninski L. (2016). Fast active set methods for online spike inference from calcium imaging. In: Lee D.D., Sugiyama M., Luxburg U.V., Guyon I. and Garnett R. (editors), Advances In Neural Information Processing Systems. Barcelona, Spain: Curran Associates, Inc., pp. 1984–1992. [Google Scholar]
- Friedrich J., Zhou P. and Paninski L. (2017). Fast online deconvolution of calcium imaging data. PLoS Computational Biology 13, e1005423. [DOI] [PMC free article] [PubMed] [Google Scholar]
- Gerstner W., Kistler W. M., Naud R. and Paninski L. (2014). Neuronal Dynamics: From Single Neurons to Networks and Models of Cognition. Cambridge: Cambridge University Press. [Google Scholar]
- Grewe B. F., Langer D., Kasper H., Kampa B. M. and Helmchen F. (2010). High-speed in vivo calcium imaging reveals neuronal network activity with near-millisecond precision. Nature Methods 7, 399–405. [DOI] [PubMed] [Google Scholar]
- Haynes K., Eckley I. A. and Fearnhead P. (2017). Computationally efficient changepoint detection for a range of penalties. Journal of Computational and Graphical Statistics 26, 134–143. [Google Scholar]
- Hocking T. D., Rigaill G., Fearnhead P. and Bourque G. (2017). A log-linear time algorithm for constrained changepoint detection. arXiv preprint arXiv:1703.03352. [Google Scholar]
- Holekamp T. F., Turaga D. and Holy T. E. (2008). Fast three-dimensional fluorescence imaging of activity in neural populations by objective-coupled planar illumination microscopy. Neuron 57, 661–672. [DOI] [PubMed] [Google Scholar]
- Houghton C. and Kreuz T. (2012). On the efficient calculation of van rossum distances. Network: Computation in Neural Systems 23, 48–58. [DOI] [PubMed] [Google Scholar]
- Jackson B., Scargle J. D., Barnes D., Arabhi S., Alt A., Gioumousis P., Gwin E., Sangtrakulcharoen P., Tan L. and Tsai T. T. (2005). An algorithm for optimal partitioning of data on an interval. IEEE Signal Processing Letters 12, 105–108. [Google Scholar]
-
Jewell S. and Witten D. (2018). Exact spike train inference via
optimization. The Annals of Applied Statistics 12, 2457–2482. [DOI] [PMC free article] [PubMed] [Google Scholar] - Killick R., Fearnhead P. and Eckley I. A. (2012). Optimal detection of changepoints with a linear computational cost. Journal of the American Statistical Association 107, 1590–1598. [Google Scholar]
-
Maidstone R., Fearnhead P. and Letchford A. (2018). Detecting changes in slope with an
penalty. Journal of Computational and Graphical Statistics, doi: 10.1080/10618600.2018.1512868. [DOI] [Google Scholar] - Maidstone R., Hocking T., Rigaill G. and Fearnhead P. (2017). On optimal multiple changepoint algorithms for large data. Statistics and Computing 27, 519–533. [DOI] [PMC free article] [PubMed] [Google Scholar]
- Pachitariu M., Stringer C. and Harris K. D. (2018). Robustness of spike deconvolution for calcium imaging of neural spiking. Journal of Neuroscience 38, 7976–7985. [DOI] [PMC free article] [PubMed] [Google Scholar]
- Pnevmatikakis E. A., Merel J., Pakman A. and Paninski L. (2013). Bayesian spike inference from calcium imaging data. In: Signals, Systems and Computers, 2013 Asilomar Conference on IEEE. pp. 349–353. doi: 10.1109/ACSSC.2013.6810293. [DOI] [Google Scholar]
- Prevedel R., Yoon Y.-G., Hoffmann M., Pak N., Wetzstein G., Kato S., Schrödel T., Raskar R., Zimmer M., Boyden E. S.. and others (2014). Simultaneous whole-animal 3D imaging of neuronal activity using light-field microscopy. Nature Methods 11, 727–730. [DOI] [PMC free article] [PubMed] [Google Scholar]
- Quiroga R. Q. and Panzeri S. (2009). Extracting information from neuronal populations: information theory and decoding approaches. Nature Reviews Neuroscience 10, 173. [DOI] [PubMed] [Google Scholar]
- Reinagel P. and Reid R. C. (2000). Temporal coding of visual information in the thalamus. Journal of Neuroscience 20, 5392–5400. [DOI] [PMC free article] [PubMed] [Google Scholar]
- Rigaill G. (2015). A pruned dynamic programming algorithm to recover the best segmentations with 1 to k_max change-points. Journal de la Société Française de Statistique 156, 180–205. [Google Scholar]
- Sasaki T., Takahashi N., Matsuki N. and Ikegaya Y. (2008). Fast and accurate detection of action potentials from somatic calcium fluctuations. Journal of Neurophysiology 100, 1668–1676. [DOI] [PubMed] [Google Scholar]
- Theis L., Berens P., Froudarakis E., Reimer J., Rosón M. R., Baden T., Euler T., Tolias A. S. and Bethge M. (2016). Benchmarking spike rate inference in population calcium imaging. Neuron 90, 471–482. [DOI] [PMC free article] [PubMed] [Google Scholar]
- van Rossum M. C. (2001). A novel spike distance. Neural Computation 13, 751–763. [DOI] [PubMed] [Google Scholar]
- Victor J. D. and Purpura K. P. (1996). Nature and precision of temporal coding in visual cortex: a metric-space analysis. Journal of Neurophysiology 76, 1310–1326. [DOI] [PubMed] [Google Scholar]
- Victor J. D. and Purpura K. P. (1997). Metric-space analysis of spike trains: theory, algorithms and application. Network: Computation in Neural Systems 8, 127–164. [Google Scholar]
- Vladimirov N., Mu Y., Kawashima T., Bennett D. V., Yang C.-T., Looger L. L., Keller P. J., Freeman J. and Ahrens M. B. (2014). Light-sheet functional imaging in fictively behaving zebrafish. Nature Methods 11, 883. [DOI] [PubMed] [Google Scholar]
- Vogelstein J. T., Packer A. M., Machado T. A., Sippy T., Babadi B., Yuste R. and Paninski L. (2010). Fast nonnegative deconvolution for spike train inference from population calcium imaging. Journal of Neurophysiology 104, 3691–3704. [DOI] [PMC free article] [PubMed] [Google Scholar]
- Vogelstein J. T., Watson B. O., Packer A. M., Yuste R., Jedynak B. and Paninski L. (2009). Spike inference from calcium imaging using sequential monte carlo methods. Biophysical Journal 97, 636–655. [DOI] [PMC free article] [PubMed] [Google Scholar]
- Yaksi E. and Friedrich R. W. (2006). Reconstruction of firing rate changes across neuronal populations by temporally deconvolved ca2+ imaging. Nature Methods 3, 377–383. [DOI] [PubMed] [Google Scholar]
- Zou H. (2006). The adaptive lasso and its oracle properties. Journal of the American Statistical Association 101, 1418–1429. [Google Scholar]
Associated Data
This section collects any data citations, data availability statements, or supplementary materials included in this article.










































